RE: strange behaviour

2003-08-14 Thread Simon Marlow
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

Re: strange behaviour

2003-08-14 Thread Jon Fairbairn
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

Re: strange behaviour

2003-08-14 Thread David Sabel
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

Re: strange behaviour

2003-08-14 Thread David Sabel
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

strange behaviour

2003-08-11 Thread David Sabel
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

RE: strange behaviour

2003-08-11 Thread Simon Marlow
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