[Haskell-cafe] Any ideas on what this should generate and not generate...?

David McBride toad3k at gmail.com
Wed Jun 28 18:48:56 UTC 2017


http://hackage.haskell.org/package/base-4.9.1.0/docs/Debug-Trace.html#v:traceM

My sense is that you should probably be using traceIO rather than the
pure trace functions.  The pure functions do not sequence with respect
to IO and once the expression you are tracing has been fully
evaluated, they will never take effect again.

On Wed, Jun 28, 2017 at 11:16 AM, Jurriaan Hage <J.Hage at uu.nl> wrote:
> We had a strange phenomenon while debugging a large compiler.
> This is the smallest example, but we have seen this behavior in our own monad.
>
> module TracEx where
>
> import Debug.Trace
>
> runit :: IO ()
> runit = traceShow "Bla" $ do
>   traceShow "Bloe” runit
>
>
> and this generates
> Bla
> Bloe
>
> and then it hangs. Nothing else is generated.
> We are guessing this has to do with optimisations of some kind.
>
> And what about
>
> runit :: IO ()
> runit = traceShow "Bla" $ do
>   n <- traceShow "Num" print 2
>   traceShow "Bloe” runit
>
> Now we get
> Bla
> Num
> 2
> Bloe
> 2
> Bloe
> 2
>> No more Bla and no more Num.
>
> Any ideas whether this is a bug or a feature?
>
> Jur and Tibor
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.


More information about the Haskell-Cafe mailing list