@@ -25,12 +25,15 @@ data UInfo = UI Int Injs Fails
2525unify :: Context -> Env -> TT Name -> TT Name -> TC ([(Name, TT Name)],
2626 Injs, Fails)
2727unify ctxt env topx topy
28− = case runStateT
29− (un' False [] (normalise ctxt env topx) (normalise ctxt env topy))
30− (UI 0 [] []) of
31− OK (v, UI _ inj fails) -> return (filter notTrivial v, inj, reverse fails)
32−-- OK (_, UI s _ ((_,_,f):fs)) -> tfail $ CantUnify topx topy f s
33− Error e -> tfail e
28+ = -- case runStateT (un' False [] topx topy) (UI 0 [] []) of
29+ -- OK (v, UI _ inj []) -> return (filter notTrivial v, inj, [])
30+ let topxn = normalise ctxt env topx
31+ topyn = normalise ctxt env topy in
32+ case runStateT (un' False [] topxn topyn)
33+ (UI 0 [] []) of
34+ OK (v, UI _ inj fails) -> return (filter notTrivial v, inj, reverse fails)
35+-- OK (_, UI s _ ((_,_,f):fs)) -> tfail $ CantUnify topx topy f s
36+ Error e -> tfail e
3437 where
3538 notTrivial (x, P _ x' _) = x /= x'
3639 notTrivial _ = True
@@ -76,18 +79,19 @@ unify ctxt env topx topy
7679 un' fn bnames (App fx ax) (App fy ay)
7780 = do uplus -- do the second one if the first adds any errors
7881 (do hf <- un' True bnames fx fy
79− let ax' = normalise ctxt env (substNames hf ax)
80− let ay' = normalise ctxt env (substNames hf ay)
82+ let ax' = hnormalise hf ctxt env (substNames hf ax)
83+ let ay' = hnormalise hf ctxt env (substNames hf ay)
8184 ha <- un' False bnames ax' ay'
8285 sc 1
8386 combine bnames hf ha)
8487 (do ha <- un' False bnames ax ay
85− let fx' = normalise ctxt env (substNames ha fx)
86− let fy' = normalise ctxt env (substNames ha fy)
88+ let fx' = hnormalise ha ctxt env (substNames ha fx)
89+ let fy' = hnormalise ha ctxt env (substNames ha fy)
8790 hf <- un' False bnames fx' fy'
8891 sc 1
8992 combine bnames hf ha)
90−
93+ where hnormalise [] _ _ t = t
94+ hnormalise ns ctxt env t = normalise ctxt env t
9195 un' fn bnames x (Bind n (Lam t) (App y (P Bound n' _)))
9296 | n == n' = un' False bnames x y
9397 un' fn bnames (Bind n (Lam t) (App x (P Bound n' _))) y