profiling and strictness (was: Re: [Haskell-cafe] An interesting paper from Google)

Evan Laforge qdunkan at gmail.com
Tue Nov 2 22:19:03 EDT 2010


> If this is accurate, why would anyone want to use the lazy State?

To answer my own question, if you want a monad stack to produce lazy
output.  E.g. if you want to lazily produce data but also have
exceptions and state:

ErrorT e (LazyWriterT w (LazyStateT s Identity))

AFAIK this is the only way to do it.  They must all be lazy and the
order of the monads is essential.

Then the output can be read from 'w', and only when it is exhausted
may you look at whether there was an exception or the final state, as
both of those are strict in the monad.

I'll be doing some experiments to see if the laziness introduces
excessive leakiness and if so how that can be fixed.  Or perhaps more
laziness will cure leakiness...


More information about the Haskell-Cafe mailing list