MyNixOS website logo
Description

A preprocessor for the debug package.

A preprocessor to automate the instrumentation of a module for the debug package

Travis Build Status Hackage Stackage Nightly

debug-pp

A preprocessor for streamlining the debug instrumentation of a module or a package.

Description

debug-pp is a Haskell source preprocessor that performs the steps a programmer would need to follow in order to debug a module with the debug package. That is:

  • append an import for the Debug module, and
  • wrap the body in a debug splice using a TH declaration quasiquote.

Usage

usage: debug-pp [FILENAME] [SOURCE] [DEST]
Instrument Haskell module for debugging from SOURCE (derived from FILENAME) and write
standard Haskell to DEST.
If no FILENAME, use SOURCE as the original name.
If no DEST or if DEST is `-', write to standard output.
If no SOURCE or if SOURCE is `-', read standard input.

To instrument a module, add the following pragma to the top of the file:

{-# OPTIONS -F -pgmF debug-pp #-}

To instrument an entire program, add the following line to your stack descriptor, or if you don't use stack, to your cabal descriptor:

ghc-options: -F -pgmF debug-pp

In both cases you will also need to modify your Cabal descriptor in order to:

  • add a dependency on the debug package, and
  • add a build tool depends on debug-pp (required Cabal 2.0) :
Library
  ...
  build-tool-depends: debug-pp:debug-pp

Configuration

The tool is customizable to some extent. It tries to find a config file in the following order:

  1. .debug-pp.yaml in the current directory (useful for per-directory settings)
  2. .debug-pp.yaml in the nearest ancestor directory (useful for per-project settings)
  3. debug-pp/config.yaml in the platform’s configuration directory (on Windows, it is %APPDATA%, elsewhere it defaults to ~/.config and can be overridden by the XDG_CONFIG_HOME environment variable; useful for user-wide settings)
  4. .debug-pp.yaml in your home directory (useful for user-wide settings)
  5. The default settings.

Use debug-pp --defaults > .debug-pp.yaml to dump a well-documented default configuration to a file, this way you can get started quickly.

The configuration options include:

  • Exclude modules by name.
  • Instrument the main function to launch a web browser upon completion.
  • Select which language extensions are included automatically.
  • Configure the debug-hoed instrumentation to include e.g. deriving Generic and Observable instances

Motivation

  • Debugging individual functions is often impractical due to the declaration groups restriction of Template Haskell. Therefore, it's often easier to debug an entire module.

  • However, error messages are much worse for TH quoted code. Errors like Not in scope: data constructor Foo in line X become Not in scope: Foo, in the TH quotation ENTIRE MODULE HERE.

  • Personally, quoting/unquoting the module by hand is annoying. Having a preprocessor do this for me is convenient, and can be easily tied to a Cabal flag or a stack command line arg.

Metadata

Version

0.1.1

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows