@@ -206,6 +206,14 @@ mergeSolutions env ns = merge [] ns
206 merge acc ns
206 merge acc ns
207 | otherwise = merge ((n, t): acc) ns
207 | otherwise = merge ((n, t): acc) ns
209+dropSwaps :: [(Name, TT Name)] -> [(Name, TT Name)]
211+dropSwaps (p@(x, P _ y _) : xs) | solvedIn y x xs = dropSwaps xs
212+ where solvedIn _ _ [] = False
213+ solvedIn y x ((y', P _ x' _) : xs) | y == y' && x == x' = True
214+ solvedIn y x (_ : xs) = solvedIn y x xs
215+dropSwaps (p : xs) = p : dropSwaps xs
209unify' :: Context -> Env ->
217unify' :: Context -> Env ->
210 (TT Name, Maybe Provenance) ->
218 (TT Name, Maybe Provenance) ->
211 (TT Name, Maybe Provenance) ->
219 (TT Name, Maybe Provenance) ->
@@ -242,7 +250,8 @@ unify' ctxt env (topx, xfrom) (topy, yfrom) =
242 -- problem for each.
250 -- problem for each.
243 uns <- mergeSolutions env (u' ++ ns)
251 uns <- mergeSolutions env (u' ++ ns)
244 ps <- get
252 ps <- get
245− let (ns', probs') = updateProblems ps uns (fails ++ problems ps)
253+ let (ns_p, probs') = updateProblems ps uns (fails ++ problems ps)
254+ let ns' = dropSwaps ns_p
246 let (notu', probs_notu) = mergeNotunified env (holes ps) (notu ++ notunified ps)
255 let (notu', probs_notu) = mergeNotunified env (holes ps) (notu ++ notunified ps)
247 traceWhen (unifylog ps)
256 traceWhen (unifylog ps)
248 ("Now solved: " ++ show ns' ++
257 ("Now solved: " ++ show ns' ++