gigaparsec
is a refreshed implementation of a parser combinator library in the parsec
style.
It has the following aims:
- Be approachable for beginners -- both those new to parser combinators and new to Haskell itself. Good documentation and resources are a key priority.
- Be complete, with a well-rounded API including support for highly-configurable lexing combinators, and generic expression parsing functionality.
- Be modern, with first-class support for the patterns outlined in Design Patterns for Parser Combinators (Functional Pearl). It also strives for API compatibility with Scala
parsley
, to allow for easy porting of both parsers, knowledge, and learning materials. - Be efficient -- while it may not be quite as fast as
megaparsec
, we hope that it will still remain reasonably efficient, as least more thanparsec
, whilst still providing additional benefits.
To achieve these aims, some departures have been made
from many of the classic parsec
-style implementations:
gigaparsec
'sParsec
type is simple: only one type-parameter. There are a few consequences of this:Parsec
does not have aParsecT
variant: occasionally, people may wish to thread other monads through a parser, however, most of the practical use-cases of this can be captured usinggigaparsec
's state and references, implemented withreference-threads
. The exception here isIO
operations.Parsec
cannot generate the type of the input stream: currently, the input is assumed to beString
. In future, however, it may be possible to specify an implementation for the input without resorting to noise in the type-signatures.Parsec
cannot specify a custom error type to be carried through parsing. In practice, a rich typeclass-driven API can be used to format error messages in the desired way, as well as change their types at the point of callingparse
.
- The common
try
combinator has been more appropriately named as theatomic
combinator: this is consistent with theparsley
naming, and we believe that this name better embodies the combinator's purpose. - Creating new primitive combinators is not endorsed by the library: while the capacities to make them have been exposed, they are not made part of the public API to allow freedom for the maintainers to continue to innovate and improve the internals -- this includes continued optimisation.
Current HEAD
documentation can be found here: for
stable documentation please consult Hackage directly.
gigaparsec
adheres strictly to Haskell PVP, with the following early-semver
-esque caveat:
- Versions
0.M.m.p
are to be treated as pre-release, with high-volatility. While the major componentM
will still be bumped for every major change, it is likely that there will be high turnover for these major bumps until the library hits1.0.0.0
, which will be considered more stable. Changes in these bumps are likely to be more disruptive than usual. - Additionally, anything within
Text.Gigaparsec.Internal
and its submodules is exempt from the PVP policy, and may change at any time. While you are free to rely on these internals if you need to, this is strongly discouraged, and we will make no attempt to keep them internally consistent, especially within the0.M.n.p
series.
gigaparsec
is built with cabal.
Use cabal build
to build, and cabal test
for testing.