RE: [Haskell] line-based interactive program

13 Jul
2005
13 Jul
'05
10:46 a.m.
On 08 July 2005 18:22, Olaf Chitil wrote:
In fact, unsafeInterleaveIO shows up limitations of the IO monad. Without this strange primitive (what is actually unsafe about it?)
Just picking up on this point: unsafeInterleaveIO is so named because it lets you write programs that don't obey the usual laws. For example: main = do r <- newIORef 0 a <- unsafeInterleaveIO $ readIORef r b <- unsafeInterleaveIO $ do writeIORef r 42; return 0 print (a + b) if you change (a + b) to (b + a), you get a different answer. Cheers, Simon
7251
Age (days ago)
7251
Last active (days ago)
0 comments
1 participants
participants (1)
-
Simon Marlow