simple but complete example on how to parse GADT-style expressions
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
see the GADT-Module for details.
There is also a simple ADT implementation for comparision.
This repository uses hpack and is tested with stack.
- Clone this repository
cd
into the project folder- run
stack build
to buildstack run
to run a simple "REPL" for the DSLstack 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.