unsafePerformIO

David Sabel dsabel@stud.uni-frankfurt.de
Wed, 9 Oct 2002 14:07:09 +0200


----- Original Message -----
From: "Simon Marlow" <simonmar@microsoft.com>
Sent: Tuesday, September 24, 2002 2:58 PM
Subject: RE: unsafePerformIO

[...]


> As for sharing, we currently don't provide any guarnatees, although we
> should.  It is currently the case that if you write
>
> a = unsafePerformIO (putStr "hello")
> b = unsafePerformIO (putStr "hello")
>
> and both a and b are evaluated, then you may get either one or two
> "hello"s on stdout.  You can currently make things more deterministic by
> (a) adding NOINLINE pragmas for a and b, and (b) using the flag -fno-cse
> to disable common sub-expression elimination.  Then you'll get exactly
> two instances of "hello" on stdout, although we won't guarantee that
> behaviour for ever.  At some point we'll fix it so that unsafePerformIO
> applications are never duplicated or coalesced.


Are there any (short) examples available where using of unsafePerformIO
leads to unexpected behaviour,
especially an example with the terms a and b from above?

with best regards, David

-------------
JWGU Frankfurt