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 resusing 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
cdinto the project folder- run
stack buildto buildstack runto run a simple "REPL" for the DSLstack testto run the parser specs and doctests
I tried to document the modules so stack haddock --open should give you a nice
looking documentation.