> The following program (ghc-4.02):
> 
> > f :: [Int] -> Int
> > f (i:is) | trace "0" False = error []
> > f is     | trace "1" False = error []
> > f is = f $ tail is
> 
> > main = putStr $ show $ f [0]
> 
> Outputs:
> 
> 1
> 
> Fail: Prelude.tail: empty list
> 
> wheras it should have output:
> 
> 0
> 1
> 
> Fail: Prelude.tail: empty list

If I rearrange the definition of main a little:

  > main = f [0] `seq` return ()

I get

  > 0
  > 1
  > 1

  > Fail: Prelude.tail: empty list

with the latest GHC, which seems ok to me.  

With the original definition of main, I get a deadlock.  This is due to the
locking of stdout: the putStr already has the lock on stdout when the trace
wants to write something, and everything stops.  We're looking into a fix
for this.

Cheers,
        Simon

Reply via email to