tools: handy monadic trace
This commit is contained in:
parent
334974dedd
commit
70bd8bb569
@ -269,10 +269,14 @@ showforest = concatMap showtree
|
||||
strace :: Show a => a -> a
|
||||
strace a = trace (show a) a
|
||||
|
||||
-- | labelled trace - like strace, with a newline and a label prepended
|
||||
-- | labelled trace - like strace, with a label prepended
|
||||
ltrace :: Show a => String -> a -> a
|
||||
ltrace l a = trace (l ++ ": " ++ show a) a
|
||||
|
||||
-- | monadic trace - like strace, but works as a standalone line in a monad
|
||||
mtrace :: (Monad m, Show a) => a -> m a
|
||||
mtrace a = strace a `seq` return a
|
||||
|
||||
-- | trace an expression using a custom show function
|
||||
tracewith f e = trace (f e) e
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user