[Haskell-beginners] Applicative Parsec

Matthias Guedemann matthias.guedemann at ovgu.de
Fri Nov 6 13:20:11 EST 2009

Hi Brent,

thanks for the illustrative example.  

> For example, consider parsing a file which contains a positive
> integer, followed by that many letters.  For example,
>   3xyz
>   12abcdefghijkl
> are two instances of this format.  In order to parse this, a monadic
> interface is required, since the result of parsing the number must be
> used to decide how many things to parse after that.

I see, but as long as I want to parse context free grammars, it is

> However, for *many* purposes, an Applicative parsing interface is all
> you need.  And if Applicative is enough, it's usually nicer/more
> elegant than Monad. (And using the least powerful/most general thing
> that works for your purpose is usually good style anyway.)

I agree, and EBNF practically translates itself (modulo some try lookaheads)

best regards,
                                            ___  __    __
Dipl. Inf. Matthias Guedemann              / __\/ _\  /__\
Computer Systems in Engineering           / /   \ \  /_\
Otto-von-Guericke Universitaet Magdeburg / /___ _\ \//__
Tel.: 0391 / 67-19359                    \____/ \__/\__/

More information about the Beginners mailing list