repositories
/
cc1516.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cba53fe
)
working on tuping function application
author
pimjager
<pim@pimjager.nl>
Wed, 13 Apr 2016 11:14:53 +0000
(13:14 +0200)
committer
pimjager
<pim@pimjager.nl>
Wed, 13 Apr 2016 11:14:53 +0000
(13:14 +0200)
examples/varEx.spl
patch
|
blob
|
history
sem.icl
patch
|
blob
|
history
diff --git
a/examples/varEx.spl
b/examples/varEx.spl
index
9182da2
..
fbecf04
100644
(file)
--- a/
examples/varEx.spl
+++ b/
examples/varEx.spl
@@
-20,6
+20,7
@@
var n = m + 2;
//var o = v + 2;
//var p = !v;
//var o = v + 2;
//var p = !v;
+var q = facR(3);
facR(n) :: Int -> Int {
return 5;
facR(n) :: Int -> Int {
return 5;
diff --git
a/sem.icl
b/sem.icl
index
cd415c5
..
8c40fb5
100644
(file)
--- a/
sem.icl
+++ b/
sem.icl
@@
-74,7
+74,9
@@
where
pure (vds, fds)
semFunDecl :: FunDecl -> Env FunDecl
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
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
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
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
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
Just t = unify t fs
unifyApp :: Type [Expr] -> Env Type