@@ -28,14 +28,14 @@ unify ctxt env topx topy
28 = -- case runStateT (un' False [] topx topy) (UI 0 [] []) of
28 = -- case runStateT (un' False [] topx topy) (UI 0 [] []) of
29 -- OK (v, UI _ inj []) -> return (filter notTrivial v, inj, [])
29 -- OK (v, UI _ inj []) -> return (filter notTrivial v, inj, [])
31−-- trace ("Unifying " ++ show (topx, topy)) $
31+-- trace ("Unifying " ++ show (topx, topy)) $
32 let topxn = normalise ctxt env topx
32 let topxn = normalise ctxt env topx
33 topyn = normalise ctxt env topy in
33 topyn = normalise ctxt env topy in
34-- trace ("Unifying " ++ show (topxn, topyn)) $
34-- trace ("Unifying " ++ show (topxn, topyn)) $
35 case runStateT (un' False [] topxn topyn)
35 case runStateT (un' False [] topxn topyn)
36 (UI 0 [] []) of
36 (UI 0 [] []) of
37+ OK (v, UI _ inj fails) ->
37− OK (v, UI _ inj fails) -> return (filter notTrivial v, inj, reverse fails)
38+ return (filter notTrivial v, inj, reverse fails)
38−-- OK (_, UI s _ ((_,_,f):fs)) -> tfail $ CantUnify topx topy f s
39 Error e -> tfail e
39 Error e -> tfail e
41 notTrivial (x, P _ x' _) = x /= x'
41 notTrivial (x, P _ x' _) = x /= x'
@@ -75,12 +75,18 @@ unify ctxt env topx topy
75 | (x,y) `elem` bnames = do sc 1; return []
75 | (x,y) `elem` bnames = do sc 1; return []
76 un' fn bnames (P Bound x _) tm
76 un' fn bnames (P Bound x _) tm
77 | holeIn env x = do UI s i f <- get
77 | holeIn env x = do UI s i f <- get
79+ when (notP tm && fn) $
80+-- trace (show (x, tm, normalise ctxt env tm)) $
78− when (notP tm && fn) $ put (UI s ((tm, topx, topy) : i) f)
81+ put (UI s ((tm, topx, topy) : i) f)
80 checkCycle (x, tm)
83 checkCycle (x, tm)
81 un' fn bnames tm (P Bound y _)
84 un' fn bnames tm (P Bound y _)
82 | holeIn env y = do UI s i f <- get
85 | holeIn env y = do UI s i f <- get
87+ when (notP tm && fn) $
88+-- trace (show (y, tm, normalise ctxt env tm)) $
83− when (notP tm && fn) $ put (UI s ((tm, topx, topy) : i) f)
89+ put (UI s ((tm, topx, topy) : i) f)
85 checkCycle (y, tm)
91 checkCycle (y, tm)
86 un' fn bnames (V i) (P Bound x _)
92 un' fn bnames (V i) (P Bound x _)