@@ -206,6 +206,14 @@ mergeSolutions env ns = merge [] ns
206206 merge acc ns
207207 | otherwise = merge ((n, t): acc) ns
208208
209+dropSwaps :: [(Name, TT Name)] -> [(Name, TT Name)]
210+dropSwaps [] = []
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
216+
209217unify' :: Context -> Env ->
210218 (TT Name, Maybe Provenance) ->
211219 (TT Name, Maybe Provenance) ->
@@ -242,7 +250,8 @@ unify' ctxt env (topx, xfrom) (topy, yfrom) =
242250 -- problem for each.
243251 uns <- mergeSolutions env (u' ++ ns)
244252 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
246255 let (notu', probs_notu) = mergeNotunified env (holes ps) (notu ++ notunified ps)
247256 traceWhen (unifylog ps)
248257 ("Now solved: " ++ show ns' ++