on master help sign in
Lifted a FIXME from Core/ProofState
127db00Jan de Muijnck-Hughes
src/Idris/Core/ProofState.hs+16−14
@@ -151,10 +151,10 @@ match_unify' ctxt env topx topy =
151 let dont = dontunify ps
151 let dont = dontunify ps
152 let inj = injective ps
152 let inj = injective ps
153 traceWhen (unifylog ps)
153 traceWhen (unifylog ps)
154− ("Matching " ++ show (topx, topy) ++
154+ ("Matching " ++ show (topx, topy) ++
155 " in " ++ show env ++
155 " in " ++ show env ++
156 "\nHoles: " ++ show (holes ps)
156 "\nHoles: " ++ show (holes ps)
157− ++ "\n"
157+ ++ "\n"
158 ++ "\n" ++ show (getProofTerm (pterm ps)) ++ "\n\n"
158 ++ "\n" ++ show (getProofTerm (pterm ps)) ++ "\n\n"
159 ) $
159 ) $
160 case match_unify ctxt env topx topy inj (holes ps) while of
160 case match_unify ctxt env topx topy inj (holes ps) while of
@@ -170,7 +170,7 @@ match_unify' ctxt env topx topy =
170 return []
170 return []
171-- traceWhen (unifylog ps)
171-- traceWhen (unifylog ps)
172-- ("Matched " ++ show (topx, topy) ++ " without " ++ show dont ++
172-- ("Matched " ++ show (topx, topy) ++ " without " ++ show dont ++
173−-- "\nSolved: " ++ show u
173+-- "\nSolved: " ++ show u
174-- ++ "\nCurrent problems:\n" ++ qshow (problems ps)
174-- ++ "\nCurrent problems:\n" ++ qshow (problems ps)
175-- -- ++ show (pterm ps)
175-- -- ++ show (pterm ps)
176-- ++ "\n----------") $
176-- ++ "\n----------") $
@@ -203,7 +203,7 @@ unify' ctxt env topx topy =
203 "\nHoles: " ++ show (holes ps)
203 "\nHoles: " ++ show (holes ps)
204 ++ "\nInjective: " ++ show (injective ps)
204 ++ "\nInjective: " ++ show (injective ps)
205 ++ "\n") $
205 ++ "\n") $
206− lift $ unify ctxt env topx topy inj (holes ps)
206+ lift $ unify ctxt env topx topy inj (holes ps)
207 (map fst (notunified ps)) while
207 (map fst (notunified ps)) while
208 let notu = filter (\ (n, t) -> case t of
208 let notu = filter (\ (n, t) -> case t of
209 P _ _ _ -> False
209 P _ _ _ -> False
@@ -416,7 +416,7 @@ deferType n fty_in args ctxt env (Bind x (Hole t) (P nt x' ty)) | x == x' =
416 Nothing -> error ("deferType can't find " ++ show n)
416 Nothing -> error ("deferType can't find " ++ show n)
417
417
418regret :: RunTactic
418regret :: RunTactic
419−regret ctxt env (Bind x (Hole t) sc) | noOccurrence x sc =
419+regret ctxt env (Bind x (Hole t) sc) | noOccurrence x sc =
420 do action (\ps -> let hs = holes ps in
420 do action (\ps -> let hs = holes ps in
421 ps { holes = hs \\ [x] })
421 ps { holes = hs \\ [x] })
422 return sc
422 return sc
@@ -495,7 +495,7 @@ solve ctxt env (Bind x (Guess ty val) sc)
495 notunified = updateNotunified [(x,val)]
495 notunified = updateNotunified [(x,val)]
496 (notunified ps),
496 (notunified ps),
497 instances = instances ps \\ [x] })
497 instances = instances ps \\ [x] })
498− let tm' = subst x val sc in
498+ let tm' = subst x val sc in
499 return tm'
499 return tm'
500solve _ _ h@(Bind x t sc)
500solve _ _ h@(Bind x t sc)
501 = do ps <- get
501 = do ps <- get
@@ -504,7 +504,7 @@ solve _ _ h@(Bind x t sc)
504 _ -> lift $ tfail (IncompleteTerm h)
504 _ -> lift $ tfail (IncompleteTerm h)
505 where findType x (Bind n (Let t v) sc)
505 where findType x (Bind n (Let t v) sc)
506 = findType x v `mplus` findType x sc
506 = findType x v `mplus` findType x sc
507− findType x (Bind n t sc)
507+ findType x (Bind n t sc)
508 | P _ x' _ <- binderTy t, x == x' = Just n
508 | P _ x' _ <- binderTy t, x == x' = Just n
509 | otherwise = findType x sc
509 | otherwise = findType x sc
510 findType x _ = Nothing
510 findType x _ = Nothing
@@ -553,7 +553,7 @@ forall n ty ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
553forall n ty ctxt env _ = fail "Can't pi bind here"
553forall n ty ctxt env _ = fail "Can't pi bind here"
554
554
555patvar :: Name -> RunTactic
555patvar :: Name -> RunTactic
556−patvar n ctxt env (Bind x (Hole t) sc) =
556+patvar n ctxt env (Bind x (Hole t) sc) =
557 do action (\ps -> ps { holes = traceWhen (unifylog ps) ("Dropping pattern hole " ++ show x) $
557 do action (\ps -> ps { holes = traceWhen (unifylog ps) ("Dropping pattern hole " ++ show x) $
558 holes ps \\ [x],
558 holes ps \\ [x],
559 solved = Just (x, P Bound n t),
559 solved = Just (x, P Bound n t),
@@ -590,7 +590,7 @@ rewrite tm ctxt env (Bind x (Hole t) xp@(P _ x' _)) | x == x' =
590 [lt, l, r, p, tmv, xp]))
590 [lt, l, r, p, tmv, xp]))
591 (scv, sct) <- lift $ check ctxt env sc
591 (scv, sct) <- lift $ check ctxt env sc
592 return scv
592 return scv
593− _ -> lift $ tfail (NotEquality tmv tmt')
593+ _ -> lift $ tfail (NotEquality tmv tmt')
594 where rname = sMN 0 "replaced"
594 where rname = sMN 0 "replaced"
595rewrite _ _ _ _ = fail "Can't rewrite here"
595rewrite _ _ _ _ = fail "Can't rewrite here"
596
596
@@ -769,7 +769,7 @@ updateEnv ns ((n, b) : env) = (n, fmap (updateSolvedTerm ns) b) : updateEnv ns e
769updateError [] err = err
769updateError [] err = err
770updateError ns (At f e) = At f (updateError ns e)
770updateError ns (At f e) = At f (updateError ns e)
771updateError ns (Elaborating s n e) = Elaborating s n (updateError ns e)
771updateError ns (Elaborating s n e) = Elaborating s n (updateError ns e)
772−updateError ns (ElaboratingArg f a env e)
772+updateError ns (ElaboratingArg f a env e)
773 = ElaboratingArg f a env (updateError ns e)
773 = ElaboratingArg f a env (updateError ns e)
774updateError ns (CantUnify b l r e xs sc)
774updateError ns (CantUnify b l r e xs sc)
775 = CantUnify b (updateSolvedTerm ns l) (updateSolvedTerm ns r) (updateError ns e) xs sc
775 = CantUnify b (updateSolvedTerm ns l) (updateSolvedTerm ns r) (updateError ns e) xs sc
@@ -777,7 +777,7 @@ updateError ns e = e
777
777
778solveInProblems x val [] = []
778solveInProblems x val [] = []
779solveInProblems x val ((l, r, env, err) : ps)
779solveInProblems x val ((l, r, env, err) : ps)
780− = ((psubst x val l, psubst x val r,
780+ = ((psubst x val l, psubst x val r,
781 updateEnv [(x, val)] env, err) : solveInProblems x val ps)
781 updateEnv [(x, val)] env, err) : solveInProblems x val ps)
782
782
783mergeNotunified :: Env -> [(Name, Term)] -> ([(Name, Term)], Fails)
783mergeNotunified :: Env -> [(Name, Term)] -> ([(Name, Term)], Fails)
@@ -785,7 +785,7 @@ mergeNotunified env ns = mnu ns [] [] where
785 mnu [] ns_acc ps_acc = (reverse ns_acc, reverse ps_acc)
785 mnu [] ns_acc ps_acc = (reverse ns_acc, reverse ps_acc)
786 mnu ((n, t):ns) ns_acc ps_acc
786 mnu ((n, t):ns) ns_acc ps_acc
787 | Just t' <- lookup n ns, t /= t'
787 | Just t' <- lookup n ns, t /= t'
788− = mnu ns ((n,t') : ns_acc)
788+ = mnu ns ((n,t') : ns_acc)
789 ((t,t',env,CantUnify True t t' (Msg "") [] 0, [],Match) : ps_acc)
789 ((t,t',env,CantUnify True t t' (Msg "") [] 0, [],Match) : ps_acc)
790 | otherwise = mnu ns ((n,t) : ns_acc) ps_acc
790 | otherwise = mnu ns ((n,t) : ns_acc) ps_acc
791
791
@@ -796,6 +796,8 @@ updateNotunified ns nu = up nu where
796 ((n, t') : up nus)
796 ((n, t') : up nus)
797
797
798-- FIXME: Why not just pass the whole proof state?
798-- FIXME: Why not just pass the whole proof state?
799+-- Issue #1716 on the issue tracker.
800+-- https://github.com/idris-lang/Idris-dev/issues/1716
799updateProblems :: Context -> [(Name, TT Name)] -> Fails -> [Name] -> [Name] -> [Name]
801updateProblems :: Context -> [(Name, TT Name)] -> Fails -> [Name] -> [Name] -> [Name]
800 -> ([(Name, TT Name)], Fails)
802 -> ([(Name, TT Name)], Fails)
801-- updateProblems ctxt [] ps inj holes = ([], ps)
803-- updateProblems ctxt [] ps inj holes = ([], ps)
@@ -806,7 +808,7 @@ updateProblems ctxt ns ps inj holes usupp = up ns ps where
806 y' = updateSolvedTerm ns y
808 y' = updateSolvedTerm ns y
807 err' = updateError ns err
809 err' = updateError ns err
808 env' = updateEnv ns env in
810 env' = updateEnv ns env in
809−-- trace ("Updating " ++ show (x',y')) $
811+-- trace ("Updating " ++ show (x',y')) $
810 case unify ctxt env' x' y' inj holes usupp while of
812 case unify ctxt env' x' y' inj holes usupp while of
811 OK (v, []) -> -- trace ("Added " ++ show v ++ " from " ++ show (x', y')) $
813 OK (v, []) -> -- trace ("Added " ++ show v ++ " from " ++ show (x', y')) $
812 up (ns ++ v) ps
814 up (ns ++ v) ps
@@ -867,7 +869,7 @@ processTactic (Reorder n) ps
867 return (ps' { previous = Just ps, plog = "" }, plog ps')
869 return (ps' { previous = Just ps, plog = "" }, plog ps')
868processTactic (ComputeLet n) ps
870processTactic (ComputeLet n) ps
869 = return (ps { pterm = mkProofTerm $
871 = return (ps { pterm = mkProofTerm $
870− computeLet (context ps) n
872+ computeLet (context ps) n
871 (getProofTerm (pterm ps)) }, "")
873 (getProofTerm (pterm ps)) }, "")
872processTactic UnifyProblems ps
874processTactic UnifyProblems ps
873 = let (ns', probs') = updateProblems (context ps) []
875 = let (ns', probs') = updateProblems (context ps) []