[Haskell-cafe] Monadic parser vs. combinator parser

wren ng thornton wren at freegeek.org
Thu Jan 31 23:38:40 CET 2013


On 1/30/13 7:21 AM, Jan Stolarek wrote:
> I will be writing a parser in Haskell and I wonder how to approach the problem. My first thought
> was to use monadic parser, e.g. like the one described by Hutton and Meijer in "Monadic Parsing
> in Haskell" functional pearl. But then I stumbled upon this:
>
> https://github.com/alephnullplex/cradle/tree/master/code/src/Lbach/Parser
>
> Monadic parser seems extremely verbose and not very straightforward compared to this one.

Psst,

     result :: a -> Parser a
     (+>)   :: Parser a -> (a -> Parser b) -> Parser b

cf.

     return :: Monad parser => a -> parser a
     (>>=)  :: Monad parser => parser a -> (a -> parser b) -> parser b

You just lose the nice do-notation is all.

-- 
Live well,
~wren



More information about the Haskell-Cafe mailing list