Proposal: Make StateT in mtl lazy

Simon Marlow simonmarhaskell at
Thu Feb 1 08:35:02 EST 2007

Neil Mitchell wrote:
> Hi
>> If we're going to have a strict StateT then it would make sense to have
>> a strict State too. Control.Monad.State.Strict perhaps? (and likewise
>> for the other mtl monads, where appropriate).
> For foldl we have foldl and foldl'. Why not State and State' ? I'm not
> a particular fan of changing the imports to get different sets of
> behaviours...

So if you want (gasp!) strictness you have to pay the Prime Tax :-)

I'm not keen on having a bias implied by the naming convention: State' suggests 
that this is a special/modified version of State, whereas I think both versions 
are equally useful.  Using lazy when you wanted strict can result in a space 
leak, using strict when you wanted lazy can result in a stack overflow or a time 

I don't mind so much a bias in the module names: e.g. Control.Monad.State could 
be the lazy version, Control.Monad.State.Strict the strict version, that's much 
less intrusive.


More information about the Libraries mailing list