symantic-parser: Parser combinators statically optimized and staged via typed meta-programming

[ agpl, library, parsing ] [ Propose Tags ]

This is a work-in-progress experimental library to generate parsers, leveraging Tagless-Final interpreters and Typed Template Haskell staging.

This is an alternative but less powerful/reviewed implementation of ParsleyHaskell. See the paper by Jamie Willis, Nicolas Wu, and Matthew Pickering, admirably well presented at ICFP-2020: Staged Selective Parser Combinators.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
dump-core

Dump GHC's Core in HTML

Disabled
dump-splices

Dump code generated by Template Haskell

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.0.20210101, 0.0.0.20210102, 0.1.0.20210201, 0.2.0.20210703, 0.2.1.20210803
Change log ChangeLog.md
Dependencies array, base (>=4.10 && <5), bytestring, containers, ghc-prim, hashable, template-haskell (>=2.16), text, transformers, unordered-containers [details]
License GPL-3.0-or-later
Copyright Julien Moutinho <julm+symantic-parser@sourcephile.fr>
Author Julien Moutinho <julm+symantic-parser@sourcephile.fr>
Maintainer Julien Moutinho <julm+symantic-parser@sourcephile.fr>
Category Parsing
Bug tracker Julien Moutinho <julm+symantic-parser@sourcephile.fr>
Source repo head: git clone git://git.sourcephile.fr/haskell/symantic-parser
Uploaded by julm at 2021-02-01T10:52:51Z
Distributions
Downloads 477 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]

Readme for symantic-parser-0.1.0.20210201

[back to package description]

Main differences with respect to ParsleyHaskell

  • Extensible primitive grammar combinators, including their underlying optimization passes, by leveraging reciprocal injections between a tagless-final encoding of syntaxes (aka. type-classes) and a corresponding tagful-initial encoding to pattern-match syntaxes (aka. data-instances). This enable a very principled, yet flexible source code. Moreover DefaultSignatures are supplied to succinctly derive new semantics (aka. type-class-instances) using automatic transformations.

  • Error messages based upon the farthest input position reached (not yet implemented in ParsleyHaskell).

  • Minimal input length checks ("horizon" checks) required for a successful parsing are factorized using a different static analysis than ParsleyHaskell's "piggy bank" which I've not understood well. This analyis can see beyond calls to subroutines, but maybe ParsleyHaskell's analysis can also be adjusted to do the same. Both analysis are not well documented and studied.

  • No dependency upon GHC plugins: lift-plugin and idioms-plugin, because those are plugins hence introduce a bit of complexity in the build processes using this parser, but most importantly they are experimental and mostly cosmetics, since they only enable a cleaner usage of the parsing combinators, by lifting Haskell code in pure to integrate the TemplateHaskell needed. I do not understand them that much and do not feel confortable to maintain them come the day that their authors abandon them.

  • No dependency upon dependent-map by keeping observed sharing inside def and ref combinators, instead of passing by a DMap. And also when introducing the join-points optimization, where fresh TemplateHaskell names are also directly used instead of passing by a DMap.

  • No support for general purpose registers in the Machine producing the TemplateHaskell splices (maybe it will come if I need and understand what's done in ParsleyHaskell).

  • License is GPL-3.0-or-later not BSD-3-Clause.

Main goals

  • For me to better understand ParsleyHaskell, and find a manageable balance between simplicity of the codebase and features of the parser. And by doing so, challenging and showcasing symantic techniques.

  • To support the parsing of tree-like data structures instead of only string-like data structures. Eg. to validate XML using RelaxNG in symantic-xml or to perform routing of HTTP requests in symantic-http-server. This is currently done in those packages using megaparsec, but megaparsec is not conceived for such input, and is less principled when it comes to optimizing, like merging alternatives.