
16 Mar
2013
16 Mar
'13
4:40 a.m.
* Niklas Hambüchen
I would agree that what attoparsec does for <|> of Alternative and mplus for MonadPlus is correct since e.g. the mplus laws say that a failure must be identity and therefore the following alternatives must be considered. I also find it very convenient that attoparsec works this way, and prefer it to what parsec does by default.
empty/mzero are indeed identities in Parsec. What doesn't hold is the law v >> mzero = mzero But this one is often violated:
flip runState 0 $ runMaybeT mzero (Nothing,0)
flip runState 0 $ runMaybeT $ lift (modify (+1)) >> mzero (Nothing,1)
Roman