
3 Nov
2010
3 Nov
'10
2:19 a.m.
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...