@@ -36,7 +36,7 @@ toplevel = EInfo [] emptyContext id Nothing
3636-- Also find deferred names in the term and their types
3737
3838build :: IState -> ElabInfo -> Bool -> Name -> PTerm ->
39− ElabD (Term, [(Name, (Int, Type))], [PDecl])
39+ ElabD (Term, [(Name, (Int, Maybe Name, Type))], [PDecl])
4040build ist info pattern fn tm
4141 = do elab ist info pattern False fn tm
4242 ivs <- get_instances
@@ -64,7 +64,7 @@ build ist info pattern fn tm
6464 ((_,_,_,e):es) -> lift (Error e)
6565 is <- getAux
6666 tt <- get_term
67− let (tm, ds) = runState (collectDeferred tt) []
67+ let (tm, ds) = runState (collectDeferred (Just fn) tt) []
6868 log <- getLog
6969 if (log /= "") then trace log $ return (tm, ds, is)
7070 else return (tm, ds, is)
@@ -74,7 +74,7 @@ build ist info pattern fn tm
7474-- know about yet on the LHS of a pattern def)
7575
7676buildTC :: IState -> ElabInfo -> Bool -> Bool -> Name -> PTerm ->
77− ElabD (Term, [(Name, (Int, Type))], [PDecl])
77+ ElabD (Term, [(Name, (Int, Maybe Name, Type))], [PDecl])
7878buildTC ist info pattern tcgen fn tm
7979 = do elab ist info pattern tcgen fn tm
8080 probs <- get_probs
@@ -84,7 +84,7 @@ buildTC ist info pattern tcgen fn tm
8484 ((_,_,_,e):es) -> lift (Error e)
8585 is <- getAux
8686 tt <- get_term
87− let (tm, ds) = runState (collectDeferred tt) []
87+ let (tm, ds) = runState (collectDeferred (Just fn) tt) []
8888 log <- getLog
8989 if (log /= "") then trace log $ return (tm, ds, is)
9090 else return (tm, ds, is)
@@ -646,8 +646,8 @@ findInstances ist t
646646
647647trivial' ist
648648 = trivial (elab ist toplevel False False (MN 0 "tac")) ist
649−proofSearch' ist n
650− = proofSearch (elab ist toplevel False False (MN 0 "tac")) n ist
649+proofSearch' ist top n
650+ = proofSearch (elab ist toplevel False False (MN 0 "tac")) top n ist
651651
652652
653653resolveTC :: Int -> Name -> IState -> ElabD ()
@@ -736,21 +736,22 @@ resolveTC depth fn ist
736736 where isImp (PImp p _ _ _ _ _) = (True, p)
737737 isImp arg = (False, priority arg)
738738
739−collectDeferred :: Term -> State [(Name, (Int, Type))] Term
740−collectDeferred (Bind n (GHole i t) app) =
739+collectDeferred :: Maybe Name ->
740+ Term -> State [(Name, (Int, Maybe Name, Type))] Term
741+collectDeferred top (Bind n (GHole i t) app) =
741742 do ds <- get
742− when (not (n `elem` map fst ds)) $ put ((n, (i, t)) : ds)
743− collectDeferred app
744−collectDeferred (Bind n b t) = do b' <- cdb b
745− t' <- collectDeferred t
746− return (Bind n b' t')
743+ when (not (n `elem` map fst ds)) $ put ((n, (i, top, t)) : ds)
744+ collectDeferred top app
745+collectDeferred top (Bind n b t) = do b' <- cdb b
746+ t' <- collectDeferred top t
747+ return (Bind n b' t')
747748 where
748− cdb (Let t v) = liftM2 Let (collectDeferred t) (collectDeferred v)
749− cdb (Guess t v) = liftM2 Guess (collectDeferred t) (collectDeferred v)
750− cdb b = do ty' <- collectDeferred (binderTy b)
749+ cdb (Let t v) = liftM2 Let (collectDeferred top t) (collectDeferred top v)
750+ cdb (Guess t v) = liftM2 Guess (collectDeferred top t) (collectDeferred top v)
751+ cdb b = do ty' <- collectDeferred top (binderTy b)
751752 return (b { binderTy = ty' })
752−collectDeferred (App f a) = liftM2 App (collectDeferred f) (collectDeferred a)
753−collectDeferred t = return t
753+collectDeferred top (App f a) = liftM2 App (collectDeferred top f) (collectDeferred top a)
754+collectDeferred top t = return t
754755
755756-- Running tactics directly
756757-- if a tactic adds unification problems, return an error
@@ -862,7 +863,7 @@ runTac autoSolve ist tac
862863 when autoSolve solveAll
863864 runT Compute = compute
864865 runT Trivial = do trivial' ist; when autoSolve solveAll
865− runT (ProofSearch n) = do proofSearch' ist n; when autoSolve solveAll
866+ runT (ProofSearch top n) = do proofSearch' ist top n; when autoSolve solveAll
866867 runT (Focus n) = focus n
867868 runT Solve = solve
868869 runT (Try l r) = do try' (runT l) (runT r) True