Proposal: Make StateT in mtl lazy
haskell at list.mightyreason.com
Thu Feb 1 09:00:31 EST 2007
Simon Marlow wrote:
> Neil Mitchell wrote:
>>> 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
> 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 leak.
> 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.
It is foreseeable that complicated Monads mighty have more intermediate levels
of Strictness (in the tuple, in the return value, in part of the state ...).
The module name space accommodates this better than counting primes on State''',
and the "import qualified" syntax makes changing imports transparent to the rest
of the file.
More information about the Libraries