diff options
| author | aarne <aarne@cs.chalmers.se> | 2009-01-30 16:52:38 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2009-01-30 16:52:38 +0000 |
| commit | 241e13247d4520fedabbc41fead3054d4d95114f (patch) | |
| tree | 9bfc38bb5a56d841b4f3964a2fb877d4c7443c44 /src/PGF/Expr.hs | |
| parent | 92bb971ea3e13a69e74c078af7c16f0c95ee0a63 (diff) | |
metavariables made unique in type checking
Diffstat (limited to 'src/PGF/Expr.hs')
| -rw-r--r-- | src/PGF/Expr.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/PGF/Expr.hs b/src/PGF/Expr.hs index c586aae8c..eee489100 100644 --- a/src/PGF/Expr.hs +++ b/src/PGF/Expr.hs @@ -10,7 +10,10 @@ module PGF.Expr(Tree(..), Literal(..), Value(..), Env, eval, apply,
-- helpers
- pStr,pFactor
+ pStr,pFactor,
+
+ -- refresh metavariables
+ newMetas
) where
import PGF.CId
@@ -250,4 +253,11 @@ apply :: Value -> Value -> Value apply (VClosure env (EAbs x e)) v = eval (Map.insert x v env) e
apply v0 v = VApp v0 v
-
+--- use composOp and state monad...
+newMetas :: Expr -> Expr
+newMetas = fst . metas 0 where
+ metas i exp = case exp of
+ EAbs x e -> let (f,j) = metas i e in (EAbs x f, j)
+ EApp f a -> let (g,j) = metas i f ; (b,k) = metas j a in (EApp g b,k)
+ EMeta _ -> (EMeta i, i+1)
+ _ -> (exp,i)
|
