remove Prim constructor from Expr

This commit is contained in:
crumbtoo
2023-11-14 12:33:06 -07:00
parent 650e0a3cfe
commit a259d5c42b
2 changed files with 16 additions and 23 deletions

View File

@@ -9,15 +9,16 @@ import Data.String
----------------------------------------------------------------------------------
data Expr = Var Name
| Con Int Int
| Con Int Int -- Con Tag Arity
| Let Rec [Binding] Expr
| Case Expr [Alter]
| Lam [Name] Expr
| App Expr Expr
| Prim Prim
| IntE Int
deriving Show
data Prim = IntP Int
data Prim = PrimConstr Int Int -- PrimConstr Tag Arity
| IntP Int
| IntAddP
| IntSubP
| IntMulP
@@ -56,7 +57,7 @@ instance IsString Expr where
instance Pretty Expr where
prettyPrec (Var k) = withPrec maxBound $ IStr k
prettyPrec (Prim n) = prettyPrec n
prettyPrec (IntE n) = withPrec maxBound $ IStr (show n)
prettyPrec (Con _ _) = undefined
prettyPrec (Let r bs e) = withPrec 0 $
IStr (if r == Rec then "letrec " else "let ")