
gracjanpolak:
Chaddaï Fouché
writes: 2008/7/22 Luke Palmer
: A little formal reasoning reveals that sequence1 = sequence2 exactly when (>>=) is strict in its left argument. There are four common monads which are _not_: Identity, Reader, Writer, State (and RWS by extension).
Still if that makes that much of a difference, maybe we could envision putting a sequence' in the library ?
Yes, in my experiments this is to be or not to be. Stack space is limited. Also processing time goes down by 800%, so it is a big deal sometimes.
Incomplete list of functions affected:
sequence mapM foldM Text.ParserCombinators.Parsec.Combinator(many1,sepBy,endBy,manyTill) Text.ParserCombinators.ReadP(many,many1,count,sepBy,endBy,manyTill) ...
As far as I know sequence could be specialized to IO monad and use my transformation.
How do I reason if >>= for parsers is lazy in its first argument?
How about adding Control.Monad.Strict for the strict package? http://hackage.haskell.org/cgi-bin/hackage-scripts/package/strict