syntax: Syntax descriptions for unified parsing and pretty-printing.
syntax
allows you to write a single syntax description and instantiate is both as a parser and a pretty printer.
The interface is based on a custom Functor/Applicative/Monad hierarchy, provided by the 'semi-iso' package. You fmap using
a semi-isomorphism instead of function. A semi-isomorphism is a isomorphism that can fail in both directions, with slightly
weakened laws. It is worth to note that Iso
s and Prism
s from lens
are valid semi-isomorphisms :)
Once you write a description you can, for example turn it into an Attoparsec parser, or into a Data.Syntax.Printer.Text.Printer
.
See syntax-example
and syntax-example-json
for examples, syntax-attoparsec
and syntax-printer
for a parser/printer implementation.
The library was inspired by:
Rendel, Tillmann, and Klaus Ostermann. "Invertible syntax descriptions: unifying parsing and pretty printing." ACM Sigplan Notices. Vol. 45. No. 11. ACM, 2010.
TODO:
Research relative monads and relative monad transformers. Indent is basically a Reader monad over a syntax. How would a State monad look?
Try to implement Haskell layout rule.
Combinators for binary data formats, vectors.
Better error messages.
Maybe an implementation of do notation for SemiIsoMonad with QuasiQuoters, like the codo notation for comonads.
Downloads
- syntax-0.3.0.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.2.1.0, 0.3.0.0, 1.0.0.0 |
---|---|
Dependencies | base (>=4 && <5), lens (>=4), mono-traversable, scientific (>=0.3), semi-iso (>=0.5.0), text [details] |
License | MIT |
Copyright | Paweł Nowak 2014 |
Author | Paweł Nowak |
Maintainer | Paweł Nowak <pawel834@gmail.com> |
Category | Data |
Source repo | head: git clone git@github.com:Pawel834/syntax.git |
Uploaded | by pawel834 at 2014-11-30T16:01:18Z |
Distributions | |
Reverse Dependencies | 4 direct, 0 indirect [details] |
Downloads | 5097 total (13 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs uploaded by user Build status unknown [no reports yet] |