| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Debug.Hoed.TH
Documentation
debug :: Q [Dec] -> Q [Dec] Source #
A handy TH wrapper for debugging functions, offering more information than obs
debug [d|
quicksort [] = []
quicksort (x:xs) = quicksort lt ++ [x] ++ quicksort gt
where (lt, gt) = partition (<= x) xs
|]
expands to:
quicksort = observe "quicksort" quicksort'
quicksort' [] = []
quicksort' (x:xs) = quicksort lt ++ [x] ++ quicksort gt
where (observe "lt" -> lt, observe "lt" -> gt) = partition (<= x) xs
The additional information may lead to unnecessary questions in algorithmic
debugging, obs is the recommended wrapper for that purpose.
obs :: Q [Dec] -> Q [Dec] Source #
A handy TH wrapper for observing functions.
obs [d|
trimPat :: Exp S -> Pat S -> Pat S
trimPat vs = filterPat ((member freeVars vs) . void)
|]
is equivalent to:
trimPat = observe "trimPat" trimPat' trimPat' vs = filterPat ....
obs accepts multiple declarations, and all the functions
inside will be wrapped as above, while the rest of declarations
will stay unchanged. As such it can be used to observe entire modules.