hledger-lib-1.2: Core data types, parsers and functionality for the hledger accounting tools

Safe Haskell | None
Language | Haskell2010

Hledger.Utils.Debug

Description

Debugging helpers

Synopsis

- pprint :: Show a => a -> IO ()
- traceWith :: (a -> String) -> a -> a
- ptrace :: String -> TextParser m ()
- debugLevel :: Int
- dbg0 :: Show a => String -> a -> a
- dbg1 :: Show a => String -> a -> a
- dbg2 :: Show a => String -> a -> a
- dbg3 :: Show a => String -> a -> a
- dbg4 :: Show a => String -> a -> a
- dbg5 :: Show a => String -> a -> a
- dbg6 :: Show a => String -> a -> a
- dbg7 :: Show a => String -> a -> a
- dbg8 :: Show a => String -> a -> a
- dbg9 :: Show a => String -> a -> a
- dbg0IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg1IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg2IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg3IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg4IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg5IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg6IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg7IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg8IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg9IO :: (MonadIO m, Show a) => String -> a -> m ()
- tracePrettyAt :: Show a => Int -> String -> a -> a
- tracePrettyAtIO :: (MonadIO m, Show a) => Int -> String -> a -> m ()
- dbgppshow :: Show a => Int -> String -> a -> a
- dbgExit :: Show a => String -> a -> a
- pdbg :: Int -> String -> TextParser m ()
- dbglog :: Show a => String -> a -> a
- module Debug.Trace
- ppShow :: Show a => a -> String

# Documentation

pprint :: Show a => a -> IO () Source #

traceWith :: (a -> String) -> a -> a Source #

Trace (print to stderr) a showable value using a custom show function.

ptrace :: String -> TextParser m () Source #

Parsec trace - show the current parsec position and next input, and the provided label if it's non-null.

debugLevel :: Int Source #

Global debug level, which controls the verbosity of debug output on the console. The default is 0 meaning no debug output. The `--debug` command line flag sets it to 1, or `--debug=N` sets it to a higher value (note: not `--debug N` for some reason). This uses unsafePerformIO and can be accessed from anywhere and before normal command-line processing. When running with :main in GHCI, you must touch and reload this module to see the effect of a new --debug option. After command-line processing, it is also available as the `debug_` field of `CliOpts`. {--} {--}

dbg0 :: Show a => String -> a -> a Source #

Convenience aliases for tracePrettyAt.

dbg1 :: Show a => String -> a -> a Source #

Pretty-print a message and the showable value to the console when the debug level is >= 1, then return it. Uses unsafePerformIO.

dbg2 :: Show a => String -> a -> a Source #

dbg3 :: Show a => String -> a -> a Source #

dbg4 :: Show a => String -> a -> a Source #

dbg5 :: Show a => String -> a -> a Source #

dbg6 :: Show a => String -> a -> a Source #

dbg7 :: Show a => String -> a -> a Source #

dbg8 :: Show a => String -> a -> a Source #

dbg9 :: Show a => String -> a -> a Source #

dbg0IO :: (MonadIO m, Show a) => String -> a -> m () Source #

Convenience aliases for tracePrettyAtIO. Like dbg, but convenient to insert in an IO monad. XXX These have a bug; they should use traceIO, not trace, otherwise GHC can occasionally over-optimise (cf lpaste a few days ago where it killed/blocked a child thread).

dbg1IO :: (MonadIO m, Show a) => String -> a -> m () Source #

dbg2IO :: (MonadIO m, Show a) => String -> a -> m () Source #

dbg3IO :: (MonadIO m, Show a) => String -> a -> m () Source #

dbg4IO :: (MonadIO m, Show a) => String -> a -> m () Source #

dbg5IO :: (MonadIO m, Show a) => String -> a -> m () Source #

dbg6IO :: (MonadIO m, Show a) => String -> a -> m () Source #

dbg7IO :: (MonadIO m, Show a) => String -> a -> m () Source #

dbg8IO :: (MonadIO m, Show a) => String -> a -> m () Source #

dbg9IO :: (MonadIO m, Show a) => String -> a -> m () Source #

tracePrettyAt :: Show a => Int -> String -> a -> a Source #

Pretty-print a message and a showable value to the console if the debug level is at or above the specified level. dbtAt 0 always prints. Otherwise, uses unsafePerformIO.

tracePrettyAtIO :: (MonadIO m, Show a) => Int -> String -> a -> m () Source #

dbgppshow :: Show a => Int -> String -> a -> a Source #

print this string to the console before evaluating the expression, if the global debug level is at or above the specified level. Uses unsafePerformIO. dbgtrace :: Int -> String -> a -> a dbgtrace level | debugLevel >= level = trace | otherwise = flip const

Print a showable value to the console, with a message, if the debug level is at or above the specified level (uses unsafePerformIO). Values are displayed with show, all on one line, which is hard to read. dbgshow :: Show a => Int -> String -> a -> a dbgshow level | debugLevel >= level = ltrace | otherwise = flip const

Print a showable value to the console, with a message, if the debug level is at or above the specified level (uses unsafePerformIO). Values are displayed with ppShow, each field/constructor on its own line.

dbgExit :: Show a => String -> a -> a Source #

Like dbg, then exit the program. Uses unsafePerformIO.

pdbg :: Int -> String -> TextParser m () Source #

Print a message and parsec debug info (parse position and next input) to the console when the debug level is at or above this level. Uses unsafePerformIO. pdbgAt :: GenParser m => Float -> String -> m ()

dbglog :: Show a => String -> a -> a Source #

Like dbg, but writes the output to "debug.log" in the current directory. Uses unsafePerformIO. Can fail due to log file contention if called too quickly ("*** Exception: debug.log: openFile: resource busy (file is locked)").

module Debug.Trace

ppShow :: Show a => a -> String #

Convert a generic value into a pretty `String`, if possible.