[Haskell-cafe] unsafeSTToIO and stToIO

Ross Paterson ross at soi.city.ac.uk
Wed Apr 29 18:55:55 EDT 2009


On Wed, Apr 29, 2009 at 05:26:46PM -0400, Xiao-Yong Jin wrote:
> Between the following two functions
> 
> stToIO        :: ST RealWorld a -> IO a
> stToIO (ST m) = IO m
> 
> unsafeSTToIO :: ST s a -> IO a
> unsafeSTToIO (ST m) = IO (unsafeCoerce# m)
> 
> All I can see is that the safe one uses RealWorld instead of
> an arbitrary thread s used in the unsafe one.  I really
> don't understand the difference between these two.  Why is
> the one without RealWorld unsafe?

Here's an example:

http://www.mail-archive.com/glasgow-haskell-bugs@haskell.org/msg03555.html


More information about the Haskell-Cafe mailing list