Random sanity?

Simon Marlow simonmar at microsoft.com
Mon Jul 23 05:40:17 EDT 2001


> I wonder if this output from 4.08.2 is sane:
> 
> $ ./main.exe
> IO Monad
> [3,4,1,3,8,0,0,1,0,1]
> ST Monad
> [51130784,51130912,51131040,51131168,51131296,51131424,5113155
> 2,51131680,511
> 31808,51131936]
> unsafePerformIO
> [4,4,4,4,4,4,4,4,4,4]

There was a bug in unsafeIOToST in 4.08.2 (and 5.00.2) which is the
cause of the strange output above.  The bug will be fixed in the
upcoming 5.02, or alternatively you can use the correct definition in
your code:

  import PrelST
  import PrelBase ( unsafeCoerce# )

  unsafeIOToST        :: IO a -> ST s a
  unsafeIOToST (IO io) = ST $ \ s -> (unsafeCoerce# io) s

Cheers,
	Simon




More information about the Glasgow-haskell-bugs mailing list