Re:Haskell, Monads and Purity
by gamegoblin on Saturday October 04, 2014 @01:50AM
(#8408895)
Something I like to do is:
import Debug.Trace
wtf v x = trace (show x) v
someFunction x = anotherFunction x `wtf` x
This allows me to tack `wtf` onto the end of otherwise unchanged expressions to do print debugging
If we have the following function:
and we want to add debugging, we can do: The above will print the value of x before throwing an error due to division by zero. You don't have to make foo return an IO Int or change any other aspect of your program.