[Haskell-cafe] State monad strictness - how?

Yitzchak Gale gale at sefer.org
Wed Jan 10 13:45:45 EST 2007


Wow! Now we are talking!

Josef Svenningsson wrote:
> So instead of:
> newtype State s a = State { runState :: (s -> (a, s)) }
> we have:
> newtype StateP p s a = StateP { runStateP :: (s -> p a s) }
> Now, instantiating this with different pair types with different
> strictness properties will give us total control over strictness for
> state and value.

Beautiful!

Iavor Diatchki wrote:
> The state transformer inherits its behavior from the underlying
> monad. For example: StateT Int IO is strict, but StateT Int Id
> is lazy.

Fantastic!

I'm drooling. When can we get stuff like this into MTL?
And maybe it is finally time for me to bite the bullet and
try out monadLib again (is it still CPS? gulp).

Now let's attack Data.* libraries...

-Yitzchak


More information about the Haskell-Cafe mailing list