This commit is contained in:
+18
-15
@@ -20,19 +20,20 @@ type Name = Text
|
||||
data Prim = PrimAdd | PrimSub | PrimMul | PrimDiv
|
||||
deriving (Show, Generic)
|
||||
|
||||
data Val
|
||||
= ValInt Int
|
||||
| ValNil
|
||||
| ValPrim Prim
|
||||
| ValLambda (List Name) Exp
|
||||
| ValVar Name
|
||||
data Lit
|
||||
= LitInt Int
|
||||
| LitNil
|
||||
| LitBool Bool
|
||||
deriving (Show, Generic)
|
||||
|
||||
data Exp
|
||||
= ExpLet (NonEmpty (Name, Exp)) Exp
|
||||
| ExpApply Exp (List Exp)
|
||||
| ExpBegin (List Exp)
|
||||
| ExpVal Val
|
||||
| ExpLit Lit
|
||||
| ExpPrim Prim
|
||||
| ExpLambda (List Name) Exp
|
||||
| ExpVar Name
|
||||
deriving (Show, Generic)
|
||||
|
||||
|
||||
@@ -45,24 +46,26 @@ instance SexpIso Prim where
|
||||
$ With (. sym "/")
|
||||
$ End
|
||||
|
||||
instance SexpIso Val where
|
||||
instance SexpIso Lit where
|
||||
sexpIso = match
|
||||
$ With (. sexpIso)
|
||||
$ With (. sym "nil")
|
||||
$ With (. sexpIso)
|
||||
$ With lam
|
||||
$ With (. symbol)
|
||||
$ End
|
||||
where
|
||||
lam q = q . list
|
||||
( el (sym "lambda")
|
||||
>>> el (sexpIso @(List Name))
|
||||
>>> el sexpIso )
|
||||
|
||||
instance SexpIso Exp where
|
||||
sexpIso = match
|
||||
$ With (. Gyehoek.Sexp.let_ symbol sexpIso sexpIso)
|
||||
$ With (\app -> app . list (el sexpIso >>> rest sexpIso))
|
||||
$ With (\bgn -> bgn . list (el (sym "begin") >>> rest sexpIso))
|
||||
$ With (<<< sexpIso)
|
||||
$ With (. sexpIso)
|
||||
$ With (. sexpIso)
|
||||
$ With (. lam)
|
||||
$ With (. symbol)
|
||||
$ End
|
||||
where
|
||||
lam = list
|
||||
( el (sym "lambda")
|
||||
>>> el (sexpIso @(List Name))
|
||||
>>> el sexpIso )
|
||||
|
||||
Reference in New Issue
Block a user