There seems to be a consensus that you should use Parsec as an applicative rather than a monad. What are the benefits of applicative parsing over monadic parsing?
Monads are strictly a more featureful abstraction than Applicatives. You could write
instance (Monad m) => Applicative m where
pure = return
(<*>) = ap
But there is no way to write
instance (Applicative a) => Monad a where
return = pure
(>>=) = ???
So yes, it is essentially a matter of style. I imagine if you use Because Applicative is a strictly smaller interface than Monad, this means that return
and ap
, then there should be no performance loss over using pure
and <*>
.<*>
can sometimes be more highly optimized than ap
. (But with clever GHC rewrite rules, one can often achieve the same optimizations regardless.)
Is monadic parsing out?
Since Monads are a subset of Applicatives, I would conclude that applicative parsing is a subset of monadic parsing.