@@ -53,12 +53,21 @@ makeConstructors types = Map.fromList builtins
54 list t = (types ! "_List") <| t
54 list t = (types ! "_List") <| t
55 maybe t = (types ! "Maybe") <| t
55 maybe t = (types ! "Maybe") <| t
56+ bool = types ! "Bool"
58+ float = types ! "Float"
57 inst :: Int -> Int -> ([Type] -> ([Type], Type)) -> IO (Int, [Variable], [Type], Type)
60 inst :: Int -> Int -> ([Type] -> ([Type], Type)) -> IO (Int, [Variable], [Type], Type)
58 inst kind numTVars tipe = do
61 inst kind numTVars tipe = do
59− vars <- forM [1..numTVars] $ \_ -> flexibleVar
62+ vars <- forM [1..numTVars] $ \_ -> flexibleVar
60− let (args, result) = tipe (map VarN vars)
63+ let (args, result) = tipe (map VarN vars)
61− return (kind, vars, args, result)
64+ return (kind, vars, args, result)
66+ nmbr :: Int -> (Type -> ([Type], Type)) -> IO (Int, [Variable], [Type], Type)
69+ let (args, result) = tipe (VarN var)
70+ return (kind, [var], args, result)
63 tupleCtor n =
72 tupleCtor n =
64 let name = "_Tuple" ++ show n
73 let name = "_Tuple" ++ show n
@@ -69,6 +78,12 @@ makeConstructors types = Map.fromList builtins
69 , ("Just" , inst 1 1 $ \ [t] -> ([t], maybe t))
78 , ("Just" , inst 1 1 $ \ [t] -> ([t], maybe t))
70 , ("[]" , inst 0 1 $ \ [t] -> ([], list t))
79 , ("[]" , inst 0 1 $ \ [t] -> ([], list t))
71 , ("::" , inst 2 1 $ \ [t] -> ([t, list t], list t))
80 , ("::" , inst 2 1 $ \ [t] -> ([t, list t], list t))
81+ , ("div" , inst 2 0 $ \ [] -> ([int, int], int))
82+ , ("/" , inst 2 0 $ \ [] -> ([float, float], float))
83+ , ("+" , nmbr 2 $ \t -> ([t, t], t))
84+ , ("-" , nmbr 2 $ \t -> ([t, t], t))
85+ , ("*" , nmbr 2 $ \t -> ([t, t], t))
86+ , ("otherwise", inst 0 0 $ \ [] -> ([], bool))
72 ] ++ map tupleCtor [0..9]
87 ] ++ map tupleCtor [0..9]