diff options
| author | krasimir <krasimir@chalmers.se> | 2009-06-19 14:37:58 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2009-06-19 14:37:58 +0000 |
| commit | 3db76063a4f2ff0d806540680579d4805493e7a3 (patch) | |
| tree | 0d9c191b5a17b28b4c9305669d4abd1228c8381e /src | |
| parent | bc4d9df645bd154d511fc28af43a0a9a567c4bc3 (diff) | |
in splitContraints the values first have to be reduced
Diffstat (limited to 'src')
| -rw-r--r-- | src/PGF/TypeCheck.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/PGF/TypeCheck.hs b/src/PGF/TypeCheck.hs index 4ab6d58c1..a450c4ed7 100644 --- a/src/PGF/TypeCheck.hs +++ b/src/PGF/TypeCheck.hs @@ -33,7 +33,7 @@ typecheck pgf e = case inferExpr pgf (newMetas e) of inferExpr :: PGF -> Expr -> Err Expr inferExpr pgf e = case infer pgf emptyTCEnv e of - Ok (e,_,cs) -> let (ms,cs2) = splitConstraints cs in case cs2 of + Ok (e,_,cs) -> let (ms,cs2) = splitConstraints pgf cs in case cs2 of [] -> Ok (metaSubst ms e) _ -> Bad ("Error in tree " ++ showExpr e ++ " :\n " ++ prConstraints cs2) Bad s -> Bad s @@ -117,12 +117,17 @@ prConstraints cs = unwords -- work more on this: unification, compute,... -splitConstraints :: [(Value,Value)] -> ([(Int,Expr)],[(Value,Value)]) -splitConstraints = mkSplit . partition isSubst . regroup . map reorder where +splitConstraints :: PGF -> [(Value,Value)] -> ([(Int,Expr)],[(Value,Value)]) +splitConstraints pgf = mkSplit . partition isSubst . regroup . map reorder . map reduce where reorder (v,w) = case w of VMeta _ _ -> (w,v) _ -> (v,w) + reduce (v,w) = (whnf v,whnf w) + + whnf (VClosure env e) = eval (getFunEnv (abstract pgf)) env e -- should be removed when the typechecker is improved + whnf v = v + regroup = groupBy (\x y -> fst x == fst y) . sort isSubst cs@((v,u):_) = case v of |
