From 3d65732efb079082e24e29383b24f0e9968100cf Mon Sep 17 00:00:00 2001 From: pimjager Date: Wed, 13 Apr 2016 19:34:09 +0200 Subject: [PATCH] small cleanup --- sem.icl | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sem.icl b/sem.icl index 0335e74..e41f5ca 100644 --- a/sem.icl +++ b/sem.icl @@ -96,13 +96,10 @@ where semFunDecl :: FunDecl -> Env FunDecl semFunDecl fd=:(FunDecl p f args mt vds stmts) = (case mt of - Nothing = let t = IdType f in putIdent f t >>| pure t//typeFun f args + Nothing = let t = IdType f in putIdent f t >>| pure t Just t = putIdent f t >>| pure t) >>= \ft -> mapM_ semVarDecl vds >>| mapM_ (checkStmt $ resultType ft) stmts >>| pure fd - //case mt of -// Nothing = let t = IdType f in putIdent f t >>| pure fd -// Just t = putIdent f t >>| pure fd semVarDecl :: VarDecl -> Env VarDecl semVarDecl (VarDecl pos type ident ex) = unify type ex @@ -118,9 +115,6 @@ checkStmt t r=:(FunStmt (FunCall f es)) = typeFun f es >>| pure r checkStmt VoidType r=:(ReturnStmt Nothing) = pure r checkStmt t r=:(ReturnStmt (Just e)) = unify t e >>| pure r -all :: [Bool] -> Bool -all as = foldr (&&) True as - typeExpr :: Expr -> Env Type typeExpr (IntExpr _ _) = pure IntType typeExpr (CharExpr _ _) = pure CharType @@ -158,7 +152,7 @@ buildFunctionType frsh [] = let t = IdType frsh in putIdent frsh t >>| pure t buildFunctionType frsh [e:es] = (->>) <$> typeExpr e <*> buildFunctionType frsh es unifyApp :: Type [Expr] -> Env Type -unifyApp t [] = pure t //whoop whoop, functions can return functions +unifyApp t [] = pure t unifyApp (tf1 ->> tf2) [t1:ts] = unify tf1 t1 >>| unifyApp tf2 ts unifyApp t1 t2 = liftT $ Left $ UnifyError zero t1 (IdType "[expressions, FIXME]") -- 2.20.1