[Haskell-cafe] Parsec Vs. src exts

Stephen Tetley stephen.tetley at gmail.com
Sun Feb 3 09:27:08 CET 2013


On 2 February 2013 20:08, Sean Cormican <seancormican1 at gmail.com> wrote:

> Can anybody provide me with some guidance on whether to try and create the
> parser using Parsec or if haskell-src is a better option.
> In the case that haskell-src is a better option, are there any tutorials or
> documents that I would benefit from reading?

As Roman Cheplyaka says, go with Haskell-src-exts...

Haskell-src-exts parses real Haskell - including most (if not all?)
GHC extensions. If you were wanting to analyze 'in the wild' Haskell
projects you might also want to use CPPHS as many Haskell projects use
the CPP preprocessor.

Once you have chosen the appropriate parse function (I remember that
haskell-src-exts provides quite a few) there is not much work to using
haskell-src-exts.

Writing your own parser with Parsec would be quite a lot of work. But
it would it might be an advantage if you want, say, custom error
reporting. Also, if your micro-Haskell is not actually a proper subset
of Haskell, then you would have to write your own parser.

The original distribution of Parsec (available from Dann Leijen's
legacy page at the Utrecht University) has parsers for two small
functional languages Mondrian and Henk that are syntactically quite
close to Haskell. These are useful starting points if you choose the
Parsec route.



More information about the Haskell-Cafe mailing list