Added default functions, isEmpty does not typecheck...
[cc1516.git] / sem.icl
diff --git a/sem.icl b/sem.icl
index af49fdf..0da9c77 100644 (file)
--- a/sem.icl
+++ b/sem.icl
@@ -48,11 +48,17 @@ instance zero Gamma where
 variableStream :: [TVar]
 variableStream = map toString [1..]
 
+defaultGamma :: Gamma //includes all default functions
+defaultGamma = extend "print" (Forall ["a"] ((IdType "a") ->> VoidType))
+                $ extend "isEmpty" (Forall ["a"] (ListType (IdType "a") ->> BoolType))
+                $ extend "read" (Forall [] (IntType ->> (ListType CharType)))
+                zero
+
 sem :: AST -> Either [SemError] AST
 sem (AST fd) = case foldM (const $ hasNoDups fd) () fd 
                        >>| foldM (const isNiceMain) () fd
                        >>| hasMain fd
-                    >>| evalStateT (type fd) (zero, variableStream) of
+                    >>| evalStateT (type fd) (defaultGamma, variableStream) of
        Left e = Left [e]
     Right (_,fds) = Right (AST fds)
 where