@@ -28,11 +28,9 @@ import Idris.Core.WHNF
2828
2929import Util.Pretty hiding (fill)
3030
31−import Control.Applicative hiding (empty)
3231import Control.Arrow ((***))
3332import Control.Monad.State.Strict
3433import Data.List
35−import Debug.Trace
3634
3735data ProofState = PS { thname :: Name,
3836 holes :: [Name], -- ^ holes still to be solved
@@ -181,7 +179,6 @@ match_unify' :: Context -> Env ->
181179match_unify' ctxt env (topx, xfrom) (topy, yfrom) =
182180 do ps <- get
183181 let while = while_elaborating ps
184− let dont = dontunify ps
185182 let inj = injective ps
186183 traceWhen (unifylog ps)
187184 ("Matching " ++ show (topx, topy) ++
@@ -494,15 +491,6 @@ deferType n fty_in args ctxt env (Bind x (Hole t) (P nt x' ty)) | x == x' =
494491 Nothing -> error ("deferType can't find " ++ show n)
495492deferType _ _ _ _ _ _ = fail "Can't defer a non-hole focus."
496493
497−regret :: RunTactic
498−regret ctxt env (Bind x (Hole t) sc) | noOccurrence x sc =
499− do action (\ps -> let hs = holes ps in
500− ps { holes = hs \\ [x] })
501− return sc
502−regret ctxt env (Bind x (Hole t) _)
503− = fail $ show x ++ " : " ++ show t ++ " is not solved..."
504−regret _ _ _ = fail "The current focus is not a hole."
505−
506494unifyGoal :: Raw -> RunTactic
507495unifyGoal tm ctxt env h@(Bind x b sc) =
508496 do (tmv, _) <- lift $ check ctxt env tm
@@ -529,14 +517,8 @@ exact _ _ _ _ = fail "Can't fill here."
529517fill :: Raw -> RunTactic
530518fill guess ctxt env (Bind x (Hole ty) sc) =
531519 do (val, valty) <- lift $ check ctxt env guess
532−-- let valtyn = normalise ctxt env valty
533−-- let tyn = normalise ctxt env ty
534− ns <- unify' ctxt env (valty, Just $ SourceTerm val)
535− (ty, Just (chkPurpose val ty))
536− ps <- get
537− let (uh, uns) = unified ps
538−-- put (ps { unified = (uh, uns ++ ns) })
539−-- addLog (show (uh, uns ++ ns))
520+ unify' ctxt env (valty, Just $ SourceTerm val)
521+ (ty, Just (chkPurpose val ty))
540522 return $ Bind x (Guess ty val) sc
541523 where
542524 -- some expected types show up commonly in errors and indicate a
@@ -552,14 +534,8 @@ fill _ _ _ _ = fail "Can't fill here."
552534match_fill :: Raw -> RunTactic
553535match_fill guess ctxt env (Bind x (Hole ty) sc) =
554536 do (val, valty) <- lift $ check ctxt env guess
555−-- let valtyn = normalise ctxt env valty
556−-- let tyn = normalise ctxt env ty
557− ns <- match_unify' ctxt env (valty, Just $ SourceTerm val)
558− (ty, Just ExpectedType)
559− ps <- get
560− let (uh, uns) = unified ps
561−-- put (ps { unified = (uh, uns ++ ns) })
562−-- addLog (show (uh, uns ++ ns))
537+ match_unify' ctxt env (valty, Just $ SourceTerm val)
538+ (ty, Just ExpectedType)
563539 return $ Bind x (Guess ty val) sc
564540match_fill _ _ _ _ = fail "Can't fill here."
565541
@@ -573,11 +549,8 @@ complete_fill :: RunTactic
573549complete_fill ctxt env (Bind x (Guess ty val) sc) =
574550 do let guess = forget val
575551 (val', valty) <- lift $ check ctxt env guess
576− ns <- unify' ctxt env (valty, Just $ SourceTerm val')
577− (ty, Just ExpectedType)
578− ps <- get
579− let (uh, uns) = unified ps
580−-- put (ps { unified = (uh, uns ++ ns) })
552+ unify' ctxt env (valty, Just $ SourceTerm val')
553+ (ty, Just ExpectedType)
581554 return $ Bind x (Guess ty val) sc
582555complete_fill ctxt env t = fail $ "Can't complete fill at " ++ show t
583556
@@ -588,7 +561,6 @@ complete_fill ctxt env t = fail $ "Can't complete fill at " ++ show t
588561solve :: RunTactic
589562solve ctxt env (Bind x (Guess ty val) sc)
590563 = do ps <- get
591− let (uh, uns) = unified ps
592564 dropdots <-
593565 case lookup x (notunified ps) of
594566 Just tm -> -- trace ("NEED MATCH: " ++ show (x, tm, val) ++ "\nIN " ++ show (pterm ps)) $
@@ -605,7 +577,7 @@ solve ctxt env (Bind x (Guess ty val) sc)
605577 recents = x : recents ps,
606578 implementations = implementations ps \\ [x],
607579 dotted = dropUnified dropdots (dotted ps) })
608− let (locked, did) = tryLock (holes ps \\ [x]) (updsubst x val sc) in
580+ let (locked, _) = tryLock (holes ps \\ [x]) (updsubst x val sc) in
609581 return locked
610582 where dropUnified ddots [] = []
611583 dropUnified ddots ((x, es) : ds)
@@ -630,7 +602,6 @@ solve ctxt env (Bind x (Guess ty val) sc)
630602 (Bind n (Let ty' val') sc', tyl && vall && scl)
631603 tryLock hs t@(Bind n b sc)
632604 = let (bt', btl) = tryLock hs (binderTy b)
633− (val', vall) = tryLock hs val
634605 (sc', scl) = tryLock hs sc in
635606 (Bind n (b { binderTy = bt' }) sc', btl && scl)
636607 tryLock hs t = (t, True)
@@ -656,13 +627,9 @@ introTy ty mn ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
656627 x@(Bind y (Pi _ _ s _) _) -> x
657628 _ -> normalise ctxt env t
658629 (tyv, tyt) <- lift $ check ctxt env ty
659−-- ns <- lift $ unify ctxt env tyv t'
660630 case t' of
661631 Bind y (Pi rig _ s _) t -> let t' = updsubst y (P Bound n s) t in
662− do ns <- unify' ctxt env (s, Nothing) (tyv, Nothing)
663− ps <- get
664− let (uh, uns) = unified ps
665−-- put (ps { unified = (uh, uns ++ ns) })
632+ do unify' ctxt env (s, Nothing) (tyv, Nothing)
666633 return $ Bind n (Lam rig tyv) (Bind x (Hole t') (P Bound x t'))
667634 _ -> lift $ tfail $ CantIntroduce t'
668635introTy ty n ctxt env _ = fail "Can't introduce here."
@@ -760,7 +727,7 @@ casetac :: Raw -> Bool -> RunTactic
760727casetac tm induction ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
761728 (tmv, tmt) <- lift $ check ctxt env tm
762729 let tmt' = normalise ctxt env tmt
763− let (tacn, tacstr, tactt) = if induction
730+ let (tacn, tacstr, _) = if induction
764731 then (ElimN, "eliminator", "Induction")
765732 else (CaseN (FC' emptyFC), "case analysis", "Case analysis")
766733 case unApply tmt' of
@@ -773,13 +740,9 @@ casetac tm induction ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
773740 _ -> return []
774741 let (params, indicies) = splitTyArgs param_pos tyargs
775742 let args = getArgTys elimTy
776− let pmargs = take (length params) args
777743 let args' = drop (length params) args
778− let propTy = head args'
779744 let restargs = init $ tail args'
780745 let consargs = take (length restargs - length indicies) restargs
781− let indxargs = drop (length restargs - length indicies) restargs
782− let scr = last $ tail args'
783746 let indxnames = makeIndexNames indicies
784747 currentNames <- query $ allTTNames . getProofTerm . pterm
785748 let tmnm = case tm of
@@ -801,8 +764,7 @@ casetac tm induction ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' = do
801764 xs -> lift $ tfail $ Msg $ "Multiple definitions found when searching for " ++ tacstr ++ "of " ++ show tnm
802765 _ -> lift $ tfail $ NoEliminator (if induction then "induction" else "case analysis")
803766 tmt'
804− where scname = sMN 0 "scarg"
805− makeConsArg (nm, ty) = P Bound nm ty
767+ where makeConsArg (nm, ty) = P Bound nm ty
806768 bindConsArgs ((nm, ty):args) v = Bind nm (Hole ty) $ bindConsArgs args v
807769 bindConsArgs [] v = v
808770 addConsHole (nm, ty) =
@@ -881,8 +843,6 @@ start_unify :: Name -> RunTactic
881843start_unify n ctxt env tm = do -- action (\ps -> ps { unified = (n, []) })
882844 return tm
883845
884−tmap f (a, b, c) = (f a, b, c)
885−
886846solve_unified :: RunTactic
887847solve_unified ctxt env tm =
888848 do ps <- get
@@ -931,14 +891,6 @@ updateError ns (CantUnify b (l,lp) (r,rp) e xs sc)
931891 (updateSolvedTerm ns r, fmap (updateProv ns) rp) (updateError ns e) xs sc
932892updateError ns e = e
933893
934−updateRes ns [] = []
935−updateRes ns ((x, t) : ts) = (x, updateSolvedTerm ns t) : updateRes ns ts
936−
937−solveInProblems x val [] = []
938−solveInProblems x val ((l, r, env, err) : ps)
939− = ((psubst x val l, psubst x val r,
940− updateEnv [(x, val)] env, err) : solveInProblems x val ps)
941−
942894mergeNotunified :: Env -> [Name] -> [(Name, Term)] -> ([(Name, Term)], Fails)
943895mergeNotunified env holes ns = mnu ns [] [] where
944896 mnu [] ns_acc ps_acc = (reverse ns_acc, reverse ps_acc)