[Haskell-cafe] Custom monad using ST

Edward Kmett ekmett at gmail.com
Thu Mar 10 01:23:08 CET 2011

On Wed, Mar 9, 2011 at 6:21 PM, Yves Parès <limestrael at gmail.com> wrote:

> Well, I want to hide the fact that I'm using ST, so if I can hide the
> existential type 's' it is better.

In practice if you want to actually _use_ ST you'll find you'll need to let
the world escape into your type. Otherwise you won't be able to create and
pass around any STRefs or arrays and use them later. The universal
quantification inside of MyST's definition will keep you from holding on to

BTW, does someone know why the ST default implementation (the one exposed by
> Control.Monad.ST) is strict, whereas those of State et Writer are lazy?

Mostly because of the principle of least surprise. It makes it act more like

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110309/550d354c/attachment.htm>

More information about the Haskell-Cafe mailing list