@@ -86,14 +86,24 @@ match_unify ctxt env topx topy inj holes from =
8686 return (map (renameBinders env) v')
8787 _ -> tfail e
8888 where
89− -- This rule is highly dubious... it certainly produces a valid answer
90− -- but it scares me. However, matching is never guaranteed to give a unique
91− -- answer, merely a valid one, so perhaps we're okay.
92− -- In other words: it may vanish without warning some day :)
9389 un :: [((Name, Name), TT Name)] -> TT Name -> TT Name ->
9490 StateT UInfo
9591 TC [(Name, TT Name)]
9692
93+ -- This rule is highly dubious... it certainly produces a valid answer
94+ -- but it scares me. However, matching is never guaranteed to give a unique
95+ -- answer, merely a valid one, so perhaps we're okay.
96+ -- In other words: it may vanish without warning some day :)
97+ un names x tm@(App (P _ f (Bind fn (Pi _ t _) sc)) a)
98+ | (P (TCon _ _) _ _, _) <- unApply x,
99+ holeIn env f || f `elem` holes
100+ = let n' = uniqueName (sMN 0 "mv") (map fst env) in
101+ checkCycle names (f, Bind n' (Lam t) x)
102+ un names tm@(App (P _ f (Bind fn (Pi _ t _) sc)) a) x
103+ | (P (TCon _ _) _ _, _) <- unApply x,
104+ holeIn env f || f `elem` holes
105+ = let n' = uniqueName fn (map fst env) in
106+ checkCycle names (f, Bind n' (Lam t) x)
97107 un names x tm@(App (P _ f (Bind fn (Pi _ t _) sc)) a)
98108 | (P (DCon _ _ _) _ _, _) <- unApply x,
99109 holeIn env f || f `elem` holes