Industrial-strength monadic parser combinator library
Go to file
2015-10-03 17:00:29 +02:00
benchmarks Fix another typo. 2015-09-29 23:40:02 +02:00
old-tests Add #if for Data.Either isRight and isLeft 2015-10-03 17:00:29 +02:00
tests Add #if for bool in tests 2015-10-03 17:00:29 +02:00
Text Add #if for bool :: a -> a -> Bool -> a. 2015-10-03 16:52:20 +02:00
.gitignore Update .gitignore 2015-09-23 00:08:58 +03:00
.travis.yml add more Cabal/GHC combinations to test 2015-10-01 15:35:29 +06:00
AUTHORS.md extend the list of contributors 2015-10-01 15:54:43 +06:00
CHANGELOG.md update changelog 2015-10-01 15:55:38 +06:00
LICENSE.md renamed ‘MegaParsec’ → ‘Megaparsec’, close #10 2015-08-01 22:24:45 +06:00
megaparsec.cabal remove obsolete information from ‘.cabal’ file 2015-10-01 16:59:38 +06:00
megaparsec.ebal use two threads for local testing 2015-08-09 00:49:30 +06:00
README.md Add compatibility to base-4.7.0.x 2015-09-30 20:18:25 +02:00
Setup.hs Initial import 2008-01-13 17:53:15 +00:00

Megaparsec

License BSD3 Hackage Build Status Coverage Status

This is industrial-strength monadic parser combinator library. Megaparsec is a fork of Parsec library originally written by Daan Leijen.

Megaparsec is different from Parsec in the following ways:

  • Better error messages. We test our error messages using dense QuickCheck tests. Good error messages are just as important for us as correct return values of our parsers. Megaparsec will be especially useful if you write compiler or interpreter for some language.

  • Some quirks and “buggy features” (as well as plain bugs) of original Parsec are fixed. There is no undocumented surprising stuff in Megaparsec.

  • Better support for Unicode parsing in Text.Megaparsec.Char.

  • Megaparsec has more powerful combinators and can parse languages where indentation matters.

  • Comprehensive QuickCheck test suite covering nearly 100% of our code.

  • We have benchmarks to detect performance regressions.

  • Better documentation, with 100% of functions covered, without typos and obsolete information, with working examples. Megaparsec's documentation is well-structured and doesn't contain things useless to end user.

  • Megaparsec's code is clearer and doesn't contain “magic” found in original Parsec.

Megaparsec vs Parsec

There are good reasons to use Parsec:

  • You need to work with legacy code or with older versions of GHC (< 7.8).

And that's it. In other cases you should prefer Megaparsec for your own sake. If you think you have a reason to use Parsec other than listed here, open an issue. We are glad to hear from you.

Megaparsec vs Parsers

There is parsers package, which is great. You can use it, but consider the following:

  • It depends on both Attoparsec and Parsec, which means you always grab useless code installing it. This is ridiculous, by the way, because this package is supposed to be useful for parser builders, so they can write basic core functionality and get the rest “for free”. But with these useful functions you get two more parsers as dependencies.

  • It currently has a bug in definition of lookAhead for various monad transformers like StateT, etc. which is visible when you create backtracking state via monad stack, not via built-in features. See #27.

We intended to use Parsers library in Megaparsec at some point, but aside from already mentioned flaws the library has different conventions for naming of things, different set of “core” functions, etc., different approach to lexer. So it didn't happen, Megaparsec has minimal dependencies, it is feature-rich and self-contained.

Contributing

Issues (bugs, feature requests or otherwise feedback) may be reported in the GitHub issue tracker for this project.

Pull requests are also welcome (and yes, they will get attention and will be merged quickly if they are good, we are progressive folks).

Spread the Word

Many people still don't know about Megaparsec, you can help the project by writing about it in a blog, creating a tutorial or something like that. This is highly appreciated.

License

Copyright © 2015 Megaparsec contributors
Copyright © 2007 Paolo Martini
Copyright © 19992000 Daan Leijen

Distributed under BSD3 license.