[Haskell-cafe] State monad strictness - how?

Yitzchak Gale gale at sefer.org
Wed Jan 10 09:32:44 EST 2007


Hi Josef,

Josef Svenningsson wrote:
> ...the fun doesn't end there. There are other strictness properties
> to consider.

Could be. But after using mtl heavily for a few years now,
I find that in practice the only one where have felt the need
for control over strictness is >>=, like Dean's example.

> Take the state monad for example. Should it be strict or
> lazy in the state that it carries around? What about the value
> component? I think the answer to these questions are the same as for
> monadic strictness above: both strict and lazy variants are useful.

Are those really needed? Can't the strictness of the state be
fully controlled by seq with runState, get, and put, and by
choosing lazy or strict >>=? And similarly with value?

As opposed to >>=, where there is no way to control
its strictness from outside the Monad instance declaration.

> Now, the challenge here is to design a library which doesn't explode
> in size from all the various possibilities for strictness or laziness.

The same challenge exists in many of the Data.* libraries.
I think this is very important.

> In fact I did once bite the bullet and came up with a library that
> does all this. Though I haven't released it publicly yet. I never took
> the time to polish the code to the point where I wouldn't be
> embarrassed about showing it to others.
> If you kick me hard enough I might release the library.

My boot is not long enough :). But I would love to see
what you did.

Regards,
Yitz


More information about the Haskell-Cafe mailing list