[Haskell-cafe] A valuable new combinator for Parsec?

Maxime Henrion mux at FreeBSD.org
Mon Mar 12 06:24:48 EDT 2007


	Hello all,


While using the very nice "option" combinator of Parsec recently, it
seemed to me that it would be useful to have a more specific kind of
combinator for optional tokens that wraps the token into a Maybe type.

So, that gives:

pmaybe :: GenParser tok st a -> GenParser tok st (Maybe a)
pmaybe p = option Nothing (p >>= return . Just)

I've been using it happily with some code of mine.  Do people think
that it would be generally useful to have in Parsec?

Cheers,
Maxime


More information about the Haskell-Cafe mailing list