[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
evaluated.

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
actions:

    trace "yyy" (return ())

HTH,
Tom


More information about the Haskell-Cafe mailing list