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

Jurriaan Hage J.Hage at uu.nl
Wed Jun 28 15:16:46 UTC 2017


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





More information about the Haskell-Cafe mailing list