My point here is to know, what's the reason for the different
behaviour, rather than discussing the
correctness of using unsafePerformIO.
The reason is this: GHC uses a lazy evaluation strategy, as opposed to
fully-lazy. Under lazy evaluation, the unsafePerformIO expression in
your example
On 2003-08-11 at 11:44+0200 David Sabel wrote:
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
PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, August 11, 2003 12:40 PM
Subject: RE: strange behaviour
My point here is to know, what's the reason for the different
behaviour, rather than discussing the
correctness of using unsafePerformIO.
The reason is this: GHC uses a lazy evaluation
On 2003-08-11 at 11:44+0200 David Sabel wrote:
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
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
It's correct behaviour to print test any number of
times. Haskell is non-strict, which only means that things
aren't evaluated unless needed. It's not (defined to be)
lazy, which would mean that named expressions would be
evaluated at most once (though ghc meets this). It's also
not