[Haskell-cafe] unsafeSTToIO and stToIO

Xiao-Yong Jin xj2106 at columbia.edu
Wed Apr 29 17:26:46 EDT 2009


Hi,

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?

I tried google, but couldn't find anything helpful.
-- 
    c/*    __o/*
    <\     * (__
    */\      <


More information about the Haskell-Cafe mailing list