summaryrefslogtreecommitdiff
path: root/src/PGF/Expr.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-10-14 14:34:08 +0000
committeraarne <aarne@cs.chalmers.se>2008-10-14 14:34:08 +0000
commite4dc63f6657153da1a8c906f669581905f054e4a (patch)
treeafc76783d1b890e7420cc3eabc15d882fedcb299 /src/PGF/Expr.hs
parentec2d7e2299cb7d1d9c786d7d8afdbcc8a526e50d (diff)
rudimentary abstract syntax type checker and solver in PGF
Diffstat (limited to 'src/PGF/Expr.hs')
-rw-r--r--src/PGF/Expr.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/PGF/Expr.hs b/src/PGF/Expr.hs
index 51a076d36..55bd90441 100644
--- a/src/PGF/Expr.hs
+++ b/src/PGF/Expr.hs
@@ -4,7 +4,7 @@ module PGF.Expr(readTree, showTree, pTree, ppTree,
tree2expr, expr2tree,
-- needed in the typechecker
- Value(..), Env, eval,
+ Value(..), Env, eval, apply,
-- helpers
pIdent,pStr
@@ -188,6 +188,7 @@ data Value
| VMeta Int
| VLit Literal
| VClosure Env Expr
+ deriving (Show,Eq,Ord)
type Env = Map.Map CId Value
@@ -197,7 +198,10 @@ eval env (EApp e1 e2) = apply (eval env e1) (eval env e2)
eval env (EAbs x e) = VClosure env (EAbs x e)
eval env (EMeta k) = VMeta k
eval env (ELit l) = VLit l
+eval env e = VClosure env e
apply :: Value -> Value -> Value
apply (VClosure env (EAbs x e)) v = eval (Map.insert x v env) e
apply v0 v = VApp v0 v
+
+