[Haskell-beginners] Parsec Library Questions

Kim-Ee Yeoh ky3 at atamo.com
Tue Jan 22 21:42:23 CET 2013


On Tue, Jan 22, 2013 at 7:52 PM, Sean Cormican <seancormican1 at gmail.com>wrote:

> 2. Can anyone recommend if this is a good source to learn to use the
> Parsec Library or if there are any other recommended documents I would
> benefit from ?
>

I think Daan wrote a lucid if slightly  bitrotted parsec tutorial (and not
just parsec itself) that many library users can benefit from. In addition,
it gives a good glimpse of the thinking behind the library design. If only
more libraries on hackage were similarly documented.

For a grasp of the evolution from the pre- to the post-monad picture, I'd
also recommend the following sources cited in the tutorial. The Monad and
MonadPlus instances act as familiar sugar over the otherwise more brittle
code that results from working with the combinators directly. The sugar is
translated away eventually, so it's still necessary to grasp the underlying
higher-order functions.

Graham Hutton. (1992)
Higher-order functions for parsing.
Journal of Functional Programming 2: 232-343.
http://www.cs.nott.ac.uk/Department/Staff/gmh/parsing.ps.

Graham Hutton and Erik Meijer. (1996)
Monadic Parser Combinators.
Technical report NOTTCS-TR-96-4. Department of Computer Science, University
of Nottingham.
http://www.cs.nott.ac.uk/Department/Staff/gmh/monparsing.ps.

And also the chapter in Hutton's textbook.

It's also useful to know that parser combinators vs parser generators (like
yacc and happy) are good examples of shallow- vs deeply-embedded DSLs. Many
of the relative advantages of each aren't specific to parsing but apply
generally to the shallow vs deep divide. <---- Digressing further, let me
just note that much of the knowledge of DSL design and implementation is
folklore for which there's no good source of information. One could do
worse than take parsing as a case study and go from there.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130123/ecc451a6/attachment.htm>


More information about the Beginners mailing list