From: pimjager Date: Wed, 13 Apr 2016 11:14:53 +0000 (+0200) Subject: working on tuping function application X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;ds=sidebyside;h=fcb2ca9a7905e5f02431ebad7ac54dba256493e9;p=cc1516.git working on tuping function application --- diff --git a/examples/varEx.spl b/examples/varEx.spl index 9182da2..fbecf04 100644 --- a/examples/varEx.spl +++ b/examples/varEx.spl @@ -20,6 +20,7 @@ var n = m + 2; //var o = v + 2; //var p = !v; +var q = facR(3); facR(n) :: Int -> Int { return 5; diff --git a/sem.icl b/sem.icl index cd415c5..8c40fb5 100644 --- a/sem.icl +++ b/sem.icl @@ -74,7 +74,9 @@ where pure (vds, fds) semFunDecl :: FunDecl -> Env FunDecl -semFunDecl f = pure f +semFunDecl fd=:(FunDecl p f _ mt vds stmts) = 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 @@ -114,13 +116,11 @@ typeExpr (EmptyListExpr p) = freshIdent >>= \frsh-> let t = IdType frsh in putIdent frsh t >>| pure t typeExpr (FunExpr p (FunCall f es)) = gets (\(st, r)->'Map'.get f st) >>= \mt-> case mt of - Nothing = undef + Nothing = let t = IdType f in putIdent f t >>| pure t Just t = unifyApp t es -//ignore field selectors typeExpr (VarExpr p (VarDef ident fs)) = gets (\(st, r)->'Map'.get ident st) >>= \mt->case mt of Nothing = liftT $ Left $ UndeclaredVariableError p ident - //let t = IdType ident in putIdent ident t >>| pure t Just t = unify t fs unifyApp :: Type [Expr] -> Env Type