1 Feb 2007 01:22
Re: Proposal: Make StateT in mtl lazy
Ian Lynagh <igloo <at> earth.li>
2007-02-01 00:22:08 GMT
2007-02-01 00:22:08 GMT
On Wed, Jan 31, 2007 at 04:06:07PM +0000, 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'.
Right, and I'd guess about a dozen other functions dotted around the
core libraries.
> Why not State and State' ?
(refering to type names, not module names)
This would also presumably give us
runState' evalState' ...
runStateT' evalStateT' ...
Existing examples of using .Strict/.Lazy modules are:
Control.Monad.ST.Lazy
Control.Monad.ST.Strict
Data.STRef.Lazy
Data.STRef.Strict
Data.ByteString
Data.ByteString.Lazy
(Continue reading)
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.
Cheers,
Simon
RSS Feed