dan.doel at gmail.com
Mon Aug 24 23:59:18 EDT 2009
On Monday 24 August 2009 11:36:18 pm Bulat Ziganshin wrote:
> Hello Samuel,
> Tuesday, August 25, 2009, 4:36:31 AM, you wrote:
> > Shouldn't Control.Monad.ST export ioToST :: IO a -> ST RealWorld a, as
> > defined in GHC.IO?
> no. ST is a subset of IO monad with a limited set of operators
> guaranteeing referential transparence, as a result runST is a pure
> operation. if you provide ability to run in ST monad arbitrary
> operations, this guarantee will break. there are pother way to do the
> same - use IO operations and unsafePerformIO
The proposed ioToST yields a value of type 'ST RealWorld a', which is not
usable with runST, as it is not sufficiently polymorphic, and thus cannot be
used to write unsafePerformIO.
The only way you can eventually do anything with a value of the above type
(short of unsafeCoerce and such) is to use stToIO to put it back into IO, and
run it from main.
More information about the Libraries