Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carstenkoenig/gadtparser
parsing GADT-style expression trees
https://github.com/carstenkoenig/gadtparser
doctest generalized-algebraic-data-type haskell megaparsec parsing
Last synced: 13 days ago
JSON representation
parsing GADT-style expression trees
- Host: GitHub
- URL: https://github.com/carstenkoenig/gadtparser
- Owner: CarstenKoenig
- License: bsd-3-clause
- Created: 2019-08-22T11:59:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-22T12:00:02.000Z (over 5 years ago)
- Last Synced: 2024-11-29T17:45:10.809Z (2 months ago)
- Topics: doctest, generalized-algebraic-data-type, haskell, megaparsec, parsing
- Language: Haskell
- Size: 23.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GADT Parser
simple but complete example on how to parse GADT-style expressions
```haskell
data Expr (res :: Type) where
IntE :: Int -> Expr Int
AddE :: Expr Int -> Expr Int -> Expr Int
BoolE :: Bool -> Expr Bool
IsNullE :: Expr Int -> Expr Bool
IfE :: Expr Bool -> Expr res -> Expr res -> Expr res
```using [Megaparsec](https://www.stackage.org/haddock/lts-14.2/megaparsec-7.0.5/Text-Megaparsec.html)
see the [GADT-Module](./src/lib/GADT) for details.
There is also a simple [ADT implementation](./src/lib/ADT) for comparision.
## Build / Run / Test
This repository uses [hpack](https://hackage.haskell.org/package/hpack) and is tested with [stack](https://docs.haskellstack.org/en/stable/README/).
- Clone this repository
- `cd` into the project folder
- run
- `stack build` to build
- `stack run` to run a simple "REPL" for the DSL
- `stack test` to run the parser specs and doctests
I tried to document the modules so `stack haddock --open` should give you a nice
looking documentation.