on master help sign in
Merge 'not unified' variables

That is, explicitly given variables which could otherwise be unified. If they appear several times in the notunified list, make sure they all match. Fixes #1077

commitf2bf55d6f81683f87200cc99057e85e832be8e67 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateThu 24 Apr 2014, 09:56 (13 years ago) parent51394aa
2 files changed+14−5
src/Idris/Core/ProofState.hs+12−4 src/Idris/ElabTerm.hs+2−1
src/Idris/Core/ProofState.hs+12−4
@@ -212,10 +212,11 @@ unify' ctxt env topx topy =
212212 (fails ++ problems ps)
213213 (injective ps)
214214 (holes ps)
215− put (ps { problems = probs',
215+ let (notu', probs_notu) = mergeNotunified env (notu ++ notunified ps)
216+ put (ps { problems = probs' ++ probs_notu,
216217 unified = (h, ns'),
217218 injective = updateInj u (injective ps),
218− notunified = notu ++ notunified ps })
219+ notunified = notu' })
219220 return u
220221 where updateInj ((n, a) : us) inj
221222 | (P _ n' _, _) <- unApply a,
@@ -812,6 +813,14 @@ solveInProblems x val ((l, r, env, err) : ps)
812813 = ((psubst x val l, psubst x val r,
813814 updateEnv [(x, val)] env, err) : solveInProblems x val ps)
814815
816+mergeNotunified :: Env -> [(Name, Term)] -> ([(Name, Term)], Fails)
817+mergeNotunified env ns = mnu ns [] [] where
818+ mnu [] ns_acc ps_acc = (reverse ns_acc, reverse ps_acc)
819+ mnu ((n, t):ns) ns_acc ps_acc
820+ | Just t' <- lookup n ns = mnu ns ((n,t) : ns_acc)
821+ ((t,t',env,Msg "", [],Match) : ps_acc)
822+ | otherwise = mnu ns ((n,t) : ns_acc) ps_acc
823+
815824updateNotunified [] nu = nu
816825updateNotunified ns nu = up nu where
817826 up [] = []
@@ -877,8 +886,7 @@ processTactic EndUnify ps
877886 notunified = updateNotunified ns'' (notunified ps),
878887 holes = holes ps \\ map fst ns'' }, "")
879888processTactic UnifyAll ps
880− = trace (show (notunified ps)) $
881− let tm' = updateSolved (notunified ps) (pterm ps) in
889+ = let tm' = updateSolved (notunified ps) (pterm ps) in
882890 return (ps { pterm = tm',
883891 notunified = [],
884892 holes = holes ps \\ map fst (notunified ps) }, "")
src/Idris/ElabTerm.hs+2−1
@@ -69,7 +69,7 @@ build ist info pattern opts fn tm
6969
7070 when (not pattern) $
7171 traceWhen u ("Remaining problems:\n" ++ show probs) $
72− do matchProblems True; unifyProblems
72+ do unify_all; matchProblems True; unifyProblems
7373 probs <- get_probs
7474 case probs of
7575 [] -> return ()
@@ -123,6 +123,7 @@ elab ist info pattern opts fn tm
123123 end_unify
124124 when pattern -- convert remaining holes to pattern vars
125125 (do update_term orderPats
126+ unify_all
126127 matchProblems False -- only the ones we matched earlier
127128 unifyProblems
128129 mkPat)