@@ -42,7 +42,7 @@ data ElabMode = ETyDecl | ETransLHS | ELHS | ERHS
4242
4343data ElabResult =
4444 ElabResult { resultTerm :: Term -- ^ The term resulting from elaboration
45− , resultMetavars :: [(Name, (Int, Maybe Name, Type))]
45+ , resultMetavars :: [(Name, (Int, Maybe Name, Type, [Name]))]
4646 -- ^ Information about new metavariables
4747 , resultCaseDecls :: [PDecl]
4848 -- ^ Deferred declarations as the meaning of case blocks
@@ -628,6 +628,7 @@ elab ist info emode opts fn tm
628628 lift $ tfail (Msg $ "Can't use type constructor " ++ show n ++ " here")
629629 checkPiGoal n
630630 attack; intro (Just n);
631+ addPSname n -- okay for proof search
631632 -- trace ("------ intro " ++ show n ++ " ---- \n" ++ show ptm)
632633 elabE (ina { e_inarg = True } ) (Just fc) sc; solve
633634 highlightSource nfc (AnnBoundName n False)
@@ -644,6 +645,7 @@ elab ist info emode opts fn tm
644645 ptm <- get_term
645646 hs <- get_holes
646647 introTy (Var tyn) (Just n)
648+ addPSname n -- okay for proof search
647649 focus tyn
648650
649651 elabE (ec { e_inarg = True, e_intype = True }) (Just fc) ty
@@ -652,6 +654,7 @@ elab ist info emode opts fn tm
652654 highlightSource nfc (AnnBoundName n False)
653655 elab' ina fc (PPi p n nfc Placeholder sc)
654656 = do attack; arg n (is_scoped p) (sMN 0 "ty")
657+ addPSname n -- okay for proof search
655658 elabE (ina { e_inarg = True, e_intype = True }) fc sc
656659 solve
657660 highlightSource nfc (AnnBoundName n False)
@@ -662,6 +665,7 @@ elab ist info emode opts fn tm
662665 MN _ _ -> unique_hole n
663666 _ -> return n
664667 forall n' (is_scoped p) (Var tyn)
668+ addPSname n' -- okay for proof search
665669 focus tyn
666670 let ec' = ina { e_inarg = True, e_intype = True }
667671 elabE ec' fc ty
@@ -677,6 +681,7 @@ elab ist info emode opts fn tm
677681 claim valn (Var tyn)
678682 explicit valn
679683 letbind n (Var tyn) (Var valn)
684+ addPSname n
680685 case ty of
681686 Placeholder -> return ()
682687 _ -> do focus tyn
@@ -902,7 +907,7 @@ elab ist info emode opts fn tm
902907 case lookup n env of
903908 Nothing -> return ()
904909 Just b ->
905− case unApply (binderTy b) of
910+ case unApply (normalise (tt_ctxt ist) env (binderTy b)) of
906911 (P _ c _, args) ->
907912 case lookupCtxtExact c (idris_classes ist) of
908913 Nothing -> return ()
@@ -962,6 +967,7 @@ elab ist info emode opts fn tm
962967 let unique_used = getUniqueUsed (tt_ctxt ist) ptm
963968 let n' = metavarName (namespace info) n
964969 attack
970+ psns <- getPSnames
965971 defer unique_used n'
966972 solve
967973 highlightSource nfc (AnnName n' (Just MetavarOutput) Nothing Nothing)
@@ -1621,7 +1627,7 @@ solveAuto ist fn ambigok n
16211627 g <- goal
16221628 isg <- is_guess -- if it's a guess, we're working on it recursively, so stop
16231629 when (not isg) $
1624− proofSearch' ist True ambigok 100 True Nothing fn []
1630+ proofSearch' ist True ambigok 100 True Nothing fn [] []
16251631
16261632solveAutos :: IState -> Name -> Bool -> ElabD ()
16271633solveAutos ist fn ambigok
@@ -1630,12 +1636,12 @@ solveAutos ist fn ambigok
16301636
16311637trivial' ist
16321638 = trivial (elab ist toplevel ERHS [] (sMN 0 "tac")) ist
1633−trivialHoles' h ist
1634− = trivialHoles h (elab ist toplevel ERHS [] (sMN 0 "tac")) ist
1635−proofSearch' ist rec ambigok depth prv top n hints
1639+trivialHoles' psn h ist
1640+ = trivialHoles psn h (elab ist toplevel ERHS [] (sMN 0 "tac")) ist
1641+proofSearch' ist rec ambigok depth prv top n psns hints
16361642 = do unifyProblems
16371643 proofSearch rec prv ambigok (not prv) depth
1638− (elab ist toplevel ERHS [] (sMN 0 "tac")) top n hints ist
1644+ (elab ist toplevel ERHS [] (sMN 0 "tac")) top n psns hints ist
16391645
16401646-- | Resolve type classes. This will only pick up 'normal' instances, never
16411647-- named instances (which is enforced by 'findInstances').
@@ -1675,7 +1681,7 @@ resTC' tcs defaultOn topholes depth topg fn ist
16751681 _ -> []
16761682
16771683 traceWhen ulog ("Resolving class " ++ show g ++ "\nin" ++ show env ++ "\n" ++ show okholes) $
1678− try' (trivialHoles' okholes ist)
1684+ try' (trivialHoles' [] okholes ist)
16791685 (do addDefault t tc ttypes
16801686 let stk = map fst (filter snd $ elab_stack ist)
16811687 let insts = findInstances ist t
@@ -1800,11 +1806,11 @@ resTC' tcs defaultOn topholes depth topg fn ist
18001806 isImp arg = (False, priority arg)
18011807
18021808collectDeferred :: Maybe Name -> [Name] -> Context ->
1803− Term -> State [(Name, (Int, Maybe Name, Type))] Term
1804−collectDeferred top casenames ctxt (Bind n (GHole i t) app) =
1809+ Term -> State [(Name, (Int, Maybe Name, Type, [Name]))] Term
1810+collectDeferred top casenames ctxt (Bind n (GHole i psns t) app) =
18051811 do ds <- get
18061812 t' <- collectDeferred top casenames ctxt t
1807− when (not (n `elem` map fst ds)) $ put (ds ++ [(n, (i, top, tidyArg [] t'))])
1813+ when (not (n `elem` map fst ds)) $ put (ds ++ [(n, (i, top, tidyArg [] t', psns))])
18081814 collectDeferred top casenames ctxt app
18091815 where
18101816 -- Evaluate the top level functions in arguments, if possible, and if it's
@@ -1814,18 +1820,9 @@ collectDeferred top casenames ctxt (Bind n (GHole i t) app) =
18141820 tidyArg env (Bind n b@(Pi im t k) sc)
18151821 = Bind n (Pi im (tidy ctxt env t) k)
18161822 (tidyArg ((n, b) : env) sc)
1817− tidyArg env t = t
1818−
1819− tidy ctxt env t | (f, args) <- unApply t,
1820− P _ specn _ <- getFn f,
1821− n `notElem` casenames
1822− = fst $ specialise ctxt env [(specn, 99999)] t
1823− tidy ctxt env t@(Bind n (Let _ _) sct)
1824− | (f, args) <- unApply sct,
1825− P _ specn _ <- getFn f,
1826− n `notElem` casenames
1827− = fst $ specialise ctxt env [(specn, 99999)] t
1828− tidy ctxt env t = t
1823+ tidyArg env t = tidy ctxt env t
1824+
1825+ tidy ctxt env t = normalise ctxt env t
18291826
18301827 getFn (Bind n (Lam _) t) = getFn t
18311828 getFn t | (f, a) <- unApply t = f
@@ -2138,7 +2135,7 @@ runElabAction ist fc env tm ns = do tm' <- eval tm
21382135 do actualHints <- mapM reifyTTName hs
21392136 unifyProblems
21402137 let psElab = elab ist toplevel ERHS [] (sMN 0 "tac")
2141− proofSearch True True False False i psElab Nothing (sMN 0 "search ") actualHints ist
2138+ proofSearch True True False False i psElab Nothing (sMN 0 "search ") [] actualHints ist
21422139 returnUnit
21432140 (Constant (I _), Nothing ) ->
21442141 lift . tfail . InternalMsg $ "Not a list: " ++ show hints'
@@ -2310,8 +2307,8 @@ runTac autoSolve ist perhapsFC fn tac
23102307 runT Compute = compute
23112308 runT Trivial = do trivial' ist; when autoSolve solveAll
23122309 runT TCInstance = runT (Exact (PResolveTC emptyFC))
2313− runT (ProofSearch rec prover depth top hints)
2314− = do proofSearch' ist rec False depth prover top fn hints
2310+ runT (ProofSearch rec prover depth top psns hints)
2311+ = do proofSearch' ist rec False depth prover top fn psns hints
23152312 when autoSolve solveAll
23162313 runT (Focus n) = focus n
23172314 runT Unfocus = do hs <- get_holes
@@ -2519,7 +2516,7 @@ processTacticDecls info steps =
25192516 updateIState $ \i -> i { idris_implicits =
25202517 addDef n impls (idris_implicits i) }
25212518 addIBC (IBCImp n)
2522− ds <- checkDef fc (\_ e -> e) [(n, (-1, Nothing, ty))]
2519+ ds <- checkDef fc (\_ e -> e) [(n, (-1, Nothing, ty, []))]
25232520 addIBC (IBCDef n)
25242521 ctxt <- getContext
25252522 case lookupDef n ctxt of
@@ -2528,7 +2525,7 @@ processTacticDecls info steps =
25282525 -- then it must be added as a metavariable. This needs guarding
25292526 -- to prevent overwriting case defs with a metavar, if the case
25302527 -- defs come after the type decl in the same script!
2531− let ds' = map (\(n, (i, top, t)) -> (n, (i, top, t, True))) ds
2528+ let ds' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, True))) ds
25322529 in addDeferred ds'
25332530 _ -> return ()
25342531 RAddInstance className instName ->