[Haskell-cafe] trace function

tpledger at ihug.co.nz tpledger at ihug.co.nz
Wed Jul 19 17:44:35 EDT 2006

Alexander Vodomerov wrote:
> import Debug.Trace
> main = do
>   putStrLn "xxx"
>   return (trace "yyy" ())
>   putStrLn "zzz"
> only xxx and zzz is displayed. yyy is missing.
> Why trace is not working?

Nothing uses the value of (trace "yyy" ()), so it is never

Try this instead, which uses the value for a pattern match:

    () <- return (trace "yyy" ())

Or this, which makes the trace part of the sequence of IO

    trace "yyy" (return ())


More information about the Haskell-Cafe mailing list