4 ms·
You can. You use a function called `trace` in module Debug.Trace in the standard library. For instance, if you defined f x y = g (x + y) then you could i
by justinpombrio 13y ago
You can. You use a function called `trace` in module Debug.Trace in the standard library.
For instance, if you defined
f x y = g (x + y)
then you could instead write
f x y = trace "calling f" (g (x + y))
to insert a debug statement.
(dllthomas linked to the library but didn't point out how it works, and unrealistically expected people to like, follow the link or something. argv_empty is correct that side effects cannot be obtained without either wrapping functions in the IO monad or calling unsafePerformIO. Debug.Trace.trace calls unsafePerformIO behind the scenes.)