The strictness of Control.Monad.State.Strict has to do with the strictness of the tuple constructor, not of the state per se. The dichotomy between Lazy and Strict comes from the competing desires to fake products as categorical products that don't introduce _|_'s of their own and the lifted products we have in Haskell which do. The former leads you to the .Lazy model, the latter leads you to the .Strict model. The former is nicer for certain lazy knot tying tricks. The latter is easier to reason about when you start throwing fmap _|_'s around.
Is there a reason there is no `modify` operation in
Control.Monad.State.Strict (and the transformers analogue) which is
truly strict in the state? That is,
modify' :: Monad m => (a -> a) -> StateM a m ()
modify' f = get >>= (\x -> put $! f x)
While this is admittedly not a difficult piece of code to write, even
the suggestion in the documentation that `modify` isn't as strict as one
might think would likely save many man-hours of debugging (especially
for those who are less familiar with the language, for whom, speaking
from experience, strictness issues can pose a major hurdle to adoption)
In general it would be nice if the notion of strictness were better
addressed in the major libraries' documentation. It's a nuanced
issue which is not fully captured by a ".Lazy" or ".Strict" in the
module name.
Just a thought.
Thanks,
- Ben
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries