[Haskell] Re: Converting a 'streaming' monad into a list
Iavor Diatchki
iavor.diatchki at gmail.com
Sun Dec 31 14:37:48 EST 2006
hi,
On 12/30/06, Ross Paterson <ross at soi.city.ac.uk> wrote:
> On Sat, Dec 30, 2006 at 10:31:30PM +0000, Chris Kuklewicz wrote:
> > But WriterT is not lazy enough. So I put a lazier version up on the wiki:
> >
> > http://haskell.org/haskellwiki/New_monads/LazyWriterT
>
> Interesting. Writer is lazy but WriterT Identity isn't. I imagine that
> both lazy and strict variants would be useful. Same for State/StateT.
this is because of the pattern matching on pairs in the do notation
(in the definition of bind). in the writer monad the definition uses
let. it can be fixed by using ~ in the do notation and the extra
lazyness is useful when working with mfix. in my library i have also
experimented with various combinations of seq (on output) and ~ to
reduce the number of space leaks but i am not sure which is the best
solution yet.
-iavor
More information about the Haskell
mailing list