strange behaviour

David Sabel dsabel@stud.uni-frankfurt.de
Mon, 11 Aug 2003 11:44:41 +0200


Hi,

the following "toy" program has a strange behaviour,
when compiling with ghc5.04.3 an no optimisation (-O0)

module Main(main) where

import System.IO.Unsafe

main = case unsafePerformIO (print "test") of
        () -> main
        

ok, probably I use unsafePerformIO in an "unsafe" way and so on,
but executing the program prints infinitely often "test" on the screen,
but I think it would be correct to do so one time?

I think it has something to do with exporting main, because the
following program

module Main(main) where

import System.IO.Unsafe

main = seq f (return ())

f = case unsafePerformIO (print "test") of
     () -> f

behaves ok.

Does someone, what's the reason for this?

Thanks,
  David