Stricter WriterT monad transformer

Evan Laforge qdunkan at gmail.com
Fri Oct 5 23:09:01 CEST 2012


On Fri, Oct 5, 2012 at 2:04 PM, Gabriel Gonzalez <gabriel439 at gmail.com> wrote:
> Here's the problem: WriterT always leaks space.  I've tested three ways to
> fix the space leak, and only one works:
>
> * [DOES NOT WORK] Add a strictness annotation to the Monad instance for
> WriterT
> * [DOES NOT WORK] Use the StateT monad transformer *without* a strictness
> annotation
> * [WORKS] Use the StateT monad transformer *with* a strictness annotation

Long ago, I had the same problem, and went through the same three
attempts before settling on the last one.  With help from kind people
on haskell-cafe (probably findable in the archives).

So I support putting it in libraries along with comments about why, so
that future generations need not go through the same process.  Then we
can tell them about how we had to walk in the snow both ways uphill
fighting space leaks with bare hands while they just have to read
about it.

For the same reason I support State.modify' :)



More information about the Libraries mailing list