cabal-version: 2.2 name: symantic-parser version: 0.0.0.20210101 synopsis: Parser combinators staged using Typed Template Haskell description: This is a work-in-progress experimental library to generate parsers, leveraging Tagless-Final combinators and Typed Template Haskell. . This is an alternative but less powerful/reviewed implementation of [ParsleyHaskell](https://github.com/J-mie6/ParsleyHaskell). See the paper by Jamie Willis, Nicolas Wu, and Matthew Pickering, admirably well presented at ICFP-2020: [Staged Selective Parser Combinators](https://icfp20.sigplan.org/details/icfp-2020-papers/20/Staged-Selective-Parser-Combinators). . Main differences are: . * Tagless-final and DefaultSignatures are used instead of tagfull-final to handle recursion schemes, this avoids constructing and deconstructing as much tags when transforming combinators or instructions. And structures/simplifies the code by avoiding to define custom traversals (traverseCombinator) or custom fix-point data-types (Fix4) and associated utilities (cata4) when introducing new index-types. Note that the extensibility of combinators, a great feature of tagless-final, is not really achievable when using the optimizing pass which requires a comprehensive initial encoding. * No dependency on dependant-map by keeping observed sharing inside 'def' and 'ref' combinators, instead of passing by a DependantMap. * No dependency on GHC plugins: lift-plugin and idioms-plugin, because those are plugins hence introduce a bit of complexity in the build process, but most importantly they are experimental and only cosmetic, 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 (yet) and do not feel confortable to maintain them in case their authors abandon them. * Error messages based upon the farthest input position reached (not yet implemented in Parsley). * License is GPL-3.0-or-later not BSD-3-Clause. . Goals are: . * For me to understand ParsleyHaskell, and find a manageable balance between simplicity of the codebase and features of the parser. * To support parsing tree-like data structures (like XML or HTTP routes) instead of just string-like data structures, which is doable with megaparsec, but is hard and less principled when it comes to optimizing, like merging alternatives. . TODO: . * Factorize input size checks (like Parsley's piggy bank). * Error messages also based upon: [A Parsing Machine for Parsing Expression Grammars with Labeled Failures](https://dl.acm.org/doi/10.1145/2851613.2851750) * Registers? license: GPL-3.0-or-later author: Julien Moutinho maintainer: Julien Moutinho bug-reports: Julien Moutinho copyright: Julien Moutinho stability: experimental category: Parsing extra-source-files: .envrc Makefile cabal.project default.nix flake.nix shell.nix extra-tmp-files: build-type: Simple tested-with: GHC==9.0.0 source-repository head type: git location: git://git.sourcephile.fr/haskell/symantic-parser flag dump-core description: Dump GHC's Core in HTML manual: True default: False flag dump-splice description: Dump code generated by Template Haskell manual: True default: False common boilerplate default-language: Haskell2010 default-extensions: BangPatterns, DataKinds, FlexibleContexts, FlexibleInstances, GADTs, GeneralizedNewtypeDeriving, LambdaCase, MultiParamTypeClasses, NamedFieldPuns, NoImplicitPrelude, RankNTypes, RecordWildCards, ScopedTypeVariables, TypeApplications, TypeFamilies, TypeOperators ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -fhide-source-paths -freverse-errors library import: boilerplate hs-source-dirs: src exposed-modules: Symantic.Univariant.Letable Symantic.Univariant.Trans Symantic.Parser Symantic.Parser.Grammar Symantic.Parser.Grammar.Combinators Symantic.Parser.Grammar.Dump Symantic.Parser.Grammar.Fixity Symantic.Parser.Grammar.ObserveSharing Symantic.Parser.Grammar.Optimize Symantic.Parser.Grammar.Write Symantic.Parser.Haskell Symantic.Parser.Machine Symantic.Parser.Machine.Dump Symantic.Parser.Machine.Generate Symantic.Parser.Machine.Input Symantic.Parser.Machine.Instructions build-depends: base >=4.10 && <5, array, bytestring, containers, ghc-prim, hashable, template-haskell >= 2.16, text, transformers, unordered-containers test-suite symantic-parser-test import: boilerplate type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Main.hs other-modules: Golden Golden.Grammar -- Golden.Utils -- Golden.Parsers -- HUnit -- QuickCheck default-extensions: ViewPatterns ghc-options: build-depends: symantic-parser, base >= 4.10 && < 5, bytestring >= 0.10, containers >= 0.5, deepseq >= 1.4, directory >= 1.3, filepath >= 1.4, hashable >= 1.2.6, process >= 1.6, strict >= 0.4, tasty >= 0.11, tasty-golden >= 2.3, -- tasty-hunit, template-haskell >= 2.16, -- temporary >= 1.3, text >= 1.2, -- time >= 1.9, transformers >= 0.4, -- QuickCheck >= 2.0, -- tasty-quickcheck, unix >= 2.7, unordered-containers if flag(dump-core) build-depends: dump-core ghc-options: -fplugin=DumpCore if flag(dump-splice) ghc-options: -ddump-splices -ddump-to-file