[jhc] Monad.ST

Henning Thielemann jhc at henning-thielemann.de
Sun Nov 15 15:13:58 EST 2009


On Sun, 15 Nov 2009, Isaac Dupree wrote:

> well, it would be nice for such a "portable" implementation to exist...

Voila
   http://darcs.haskell.org/packages/statethread/

It compiles, but I have not tested any program that uses it. Even with 
simplest examples using storablevector it depends largely on fortune 
whether they run or crash. So no chance to make reliable statements about 
something more complex.

> However, unsafePerformIO is often slower than an ST implementation has the 
> potential to be (e.g. in GHC unsafePerformIO contains lots of safe-guards, 
> each of which has been added after painful experience but which are not 
> needed for ST itself).

unsafePerformIO is needed only once per ST block, namely for runST. That 
should not be too often.


More information about the jhc mailing list