aboutsummaryrefslogtreecommitdiff
path: root/backend/CC/Backend/Dumb.hs
diff options
context:
space:
mode:
Diffstat (limited to 'backend/CC/Backend/Dumb.hs')
-rw-r--r--backend/CC/Backend/Dumb.hs24
1 files changed, 17 insertions, 7 deletions
diff --git a/backend/CC/Backend/Dumb.hs b/backend/CC/Backend/Dumb.hs
index 3210dab..822fb84 100644
--- a/backend/CC/Backend/Dumb.hs
+++ b/backend/CC/Backend/Dumb.hs
@@ -7,10 +7,20 @@ import CC.Context
builtins :: Builtins
-builtins = Builtins . Map.fromList $
- [ ("print", TFun TInt (TTup []))
- , ("fst", TFun (TTup [TyVar 1, TyVar 2]) (TyVar 1))
- , ("snd", TFun (TTup [TyVar 1, TyVar 2]) (TyVar 2))
- , ("_add", TFun TInt (TFun TInt TInt))
- , ("_sub", TFun TInt (TFun TInt TInt))
- , ("_mul", TFun TInt (TFun TInt TInt)) ]
+builtins =
+ let values = Map.fromList
+ [ ("print", TInt ==> TTup [])
+ , ("fst", TTup [t1, t2] ==> t1)
+ , ("snd", TTup [t1, t2] ==> t2)
+ , ("_add", TInt ==> TInt ==> TInt)
+ , ("_sub", TInt ==> TInt ==> TInt)
+ , ("_mul", TInt ==> TInt ==> TInt) ]
+ prelude = "type Nil = ()\n\
+ \type Cons a = (a, List a)\n\
+ \alias List a = { Nil | Cons a }\n"
+ in Builtins values prelude
+ where
+ t1 = TyVar Instantiable 1
+ t2 = TyVar Instantiable 2
+ infixr ==>
+ (==>) = TFun