Gregory Crosswhite schrieb:
I would venture that the condition under which unsafeIOtoST would be safe is if 
all of the computations you are performing in the IO monad are only changing 
state that is local to the computation within the ST monad in which you are 
running.  (For example, if there were no STRef type then you could emulate it 
using IORefs, and this would be safe since the IORefs couldn't leak outside of 
the ST monad.)
This is the way I implemented ST and STRef for JHC:
  http://code.haskell.org/~thielema/statethread/


On Apr 6, 2010, at 5:30 PM, Roman Leshchinskiy wrote:


In fact, the only safe-ish use for it I have found is to use Storable-related 
functions in ST, hoping that the instances don't actually use any real IO 
functionality. Arguably, this shouldn't be necessary as Storable should live in 
ST anyway.

But Storable in ST monad would be still dangerous, because pointers may point to non-allocated memory or point outside of an array.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to