@@ -42,7 +42,7 @@ data ElabMode = ETyDecl | ETransLHS | ELHS | ERHS
43data ElabResult =
43data ElabResult =
44 ElabResult { resultTerm :: Term -- ^ The term resulting from elaboration
44 ElabResult { resultTerm :: Term -- ^ The term resulting from elaboration
45− , resultMetavars :: [(Name, (Int, Maybe Name, Type))]
45+ , resultMetavars :: [(Name, (Int, Maybe Name, Type, [Name]))]
46 -- ^ Information about new metavariables
46 -- ^ Information about new metavariables
47 , resultCaseDecls :: [PDecl]
47 , resultCaseDecls :: [PDecl]
48 -- ^ Deferred declarations as the meaning of case blocks
48 -- ^ Deferred declarations as the meaning of case blocks
@@ -628,6 +628,7 @@ elab ist info emode opts fn tm
628 lift $ tfail (Msg $ "Can't use type constructor " ++ show n ++ " here")
628 lift $ tfail (Msg $ "Can't use type constructor " ++ show n ++ " here")
629 checkPiGoal n
629 checkPiGoal n
630 attack; intro (Just n);
630 attack; intro (Just n);
631+ addPSname n -- okay for proof search
631 -- trace ("------ intro " ++ show n ++ " ---- \n" ++ show ptm)
632 -- trace ("------ intro " ++ show n ++ " ---- \n" ++ show ptm)
632 elabE (ina { e_inarg = True } ) (Just fc) sc; solve
633 elabE (ina { e_inarg = True } ) (Just fc) sc; solve
633 highlightSource nfc (AnnBoundName n False)
634 highlightSource nfc (AnnBoundName n False)
@@ -644,6 +645,7 @@ elab ist info emode opts fn tm
644 ptm <- get_term
645 ptm <- get_term
645 hs <- get_holes
646 hs <- get_holes
646 introTy (Var tyn) (Just n)
647 introTy (Var tyn) (Just n)
648+ addPSname n -- okay for proof search
647 focus tyn
649 focus tyn
649 elabE (ec { e_inarg = True, e_intype = True }) (Just fc) ty
651 elabE (ec { e_inarg = True, e_intype = True }) (Just fc) ty
@@ -652,6 +654,7 @@ elab ist info emode opts fn tm
652 highlightSource nfc (AnnBoundName n False)
654 highlightSource nfc (AnnBoundName n False)
653 elab' ina fc (PPi p n nfc Placeholder sc)
655 elab' ina fc (PPi p n nfc Placeholder sc)
654 = do attack; arg n (is_scoped p) (sMN 0 "ty")
656 = do attack; arg n (is_scoped p) (sMN 0 "ty")
657+ addPSname n -- okay for proof search
655 elabE (ina { e_inarg = True, e_intype = True }) fc sc
658 elabE (ina { e_inarg = True, e_intype = True }) fc sc
657 highlightSource nfc (AnnBoundName n False)
660 highlightSource nfc (AnnBoundName n False)
@@ -662,6 +665,7 @@ elab ist info emode opts fn tm
662 MN _ _ -> unique_hole n
665 MN _ _ -> unique_hole n
663 _ -> return n
666 _ -> return n
664 forall n' (is_scoped p) (Var tyn)
667 forall n' (is_scoped p) (Var tyn)
668+ addPSname n' -- okay for proof search
665 focus tyn
669 focus tyn
666 let ec' = ina { e_inarg = True, e_intype = True }
670 let ec' = ina { e_inarg = True, e_intype = True }
667 elabE ec' fc ty
671 elabE ec' fc ty
@@ -677,6 +681,7 @@ elab ist info emode opts fn tm
677 claim valn (Var tyn)
681 claim valn (Var tyn)
678 explicit valn
682 explicit valn
679 letbind n (Var tyn) (Var valn)
683 letbind n (Var tyn) (Var valn)
680 case ty of
685 case ty of
681 Placeholder -> return ()
686 Placeholder -> return ()
682 _ -> do focus tyn
687 _ -> do focus tyn
@@ -902,7 +907,7 @@ elab ist info emode opts fn tm
902 case lookup n env of
907 case lookup n env of
903 Nothing -> return ()
908 Nothing -> return ()
904 Just b ->
909 Just b ->
905− case unApply (binderTy b) of
910+ case unApply (normalise (tt_ctxt ist) env (binderTy b)) of
906 (P _ c _, args) ->
911 (P _ c _, args) ->
907 case lookupCtxtExact c (idris_classes ist) of
912 case lookupCtxtExact c (idris_classes ist) of
908 Nothing -> return ()
913 Nothing -> return ()
@@ -962,6 +967,7 @@ elab ist info emode opts fn tm
962 let unique_used = getUniqueUsed (tt_ctxt ist) ptm
967 let unique_used = getUniqueUsed (tt_ctxt ist) ptm
963 let n' = metavarName (namespace info) n
968 let n' = metavarName (namespace info) n
965 defer unique_used n'
971 defer unique_used n'
967 highlightSource nfc (AnnName n' (Just MetavarOutput) Nothing Nothing)
973 highlightSource nfc (AnnName n' (Just MetavarOutput) Nothing Nothing)
@@ -1621,7 +1627,7 @@ solveAuto ist fn ambigok n
1621 g <- goal
1627 g <- goal
1622 isg <- is_guess -- if it's a guess, we're working on it recursively, so stop
1628 isg <- is_guess -- if it's a guess, we're working on it recursively, so stop
1623 when (not isg) $
1629 when (not isg) $
1624− proofSearch' ist True ambigok 100 True Nothing fn []
1630+ proofSearch' ist True ambigok 100 True Nothing fn [] []
1626solveAutos :: IState -> Name -> Bool -> ElabD ()
1632solveAutos :: IState -> Name -> Bool -> ElabD ()
1627solveAutos ist fn ambigok
1633solveAutos ist fn ambigok
@@ -1630,12 +1636,12 @@ solveAutos ist fn ambigok
1631trivial' ist
1637trivial' ist
1632 = trivial (elab ist toplevel ERHS [] (sMN 0 "tac")) ist
1638 = trivial (elab ist toplevel ERHS [] (sMN 0 "tac")) ist
1633−trivialHoles' h ist
1639+trivialHoles' psn h ist
1634− = trivialHoles h (elab ist toplevel ERHS [] (sMN 0 "tac")) ist
1640+ = trivialHoles psn h (elab ist toplevel ERHS [] (sMN 0 "tac")) ist
1635−proofSearch' ist rec ambigok depth prv top n hints
1641+proofSearch' ist rec ambigok depth prv top n psns hints
1636 = do unifyProblems
1642 = do unifyProblems
1637 proofSearch rec prv ambigok (not prv) depth
1643 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
1640-- | Resolve type classes. This will only pick up 'normal' instances, never
1646-- | Resolve type classes. This will only pick up 'normal' instances, never
1641-- named instances (which is enforced by 'findInstances').
1647-- named instances (which is enforced by 'findInstances').
@@ -1675,7 +1681,7 @@ resTC' tcs defaultOn topholes depth topg fn ist
1677 traceWhen ulog ("Resolving class " ++ show g ++ "\nin" ++ show env ++ "\n" ++ show okholes) $
1683 traceWhen ulog ("Resolving class " ++ show g ++ "\nin" ++ show env ++ "\n" ++ show okholes) $
1678− try' (trivialHoles' okholes ist)
1684+ try' (trivialHoles' [] okholes ist)
1679 (do addDefault t tc ttypes
1685 (do addDefault t tc ttypes
1680 let stk = map fst (filter snd $ elab_stack ist)
1686 let stk = map fst (filter snd $ elab_stack ist)
1681 let insts = findInstances ist t
1687 let insts = findInstances ist t
@@ -1800,11 +1806,11 @@ resTC' tcs defaultOn topholes depth topg fn ist
1800 isImp arg = (False, priority arg)
1806 isImp arg = (False, priority arg)
1802collectDeferred :: Maybe Name -> [Name] -> Context ->
1808collectDeferred :: Maybe Name -> [Name] -> Context ->
1803− Term -> State [(Name, (Int, Maybe Name, Type))] Term
1809+ Term -> State [(Name, (Int, Maybe Name, Type, [Name]))] Term
1804−collectDeferred top casenames ctxt (Bind n (GHole i t) app) =
1810+collectDeferred top casenames ctxt (Bind n (GHole i psns t) app) =
1805 do ds <- get
1811 do ds <- get
1806 t' <- collectDeferred top casenames ctxt t
1812 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))])
1808 collectDeferred top casenames ctxt app
1814 collectDeferred top casenames ctxt app
1810 -- Evaluate the top level functions in arguments, if possible, and if it's
1816 -- 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) =
1814 tidyArg env (Bind n b@(Pi im t k) sc)
1820 tidyArg env (Bind n b@(Pi im t k) sc)
1815 = Bind n (Pi im (tidy ctxt env t) k)
1821 = Bind n (Pi im (tidy ctxt env t) k)
1816 (tidyArg ((n, b) : env) sc)
1822 (tidyArg ((n, b) : env) sc)
1817− tidyArg env t = t
1823+ tidyArg env t = tidy ctxt env t
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)
1825+ tidy ctxt env t = normalise ctxt env t
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
1830 getFn (Bind n (Lam _) t) = getFn t
1827 getFn (Bind n (Lam _) t) = getFn t
1831 getFn t | (f, a) <- unApply t = f
1828 getFn t | (f, a) <- unApply t = f
@@ -2138,7 +2135,7 @@ runElabAction ist fc env tm ns = do tm' <- eval tm
2138 do actualHints <- mapM reifyTTName hs
2135 do actualHints <- mapM reifyTTName hs
2139 unifyProblems
2136 unifyProblems
2140 let psElab = elab ist toplevel ERHS [] (sMN 0 "tac")
2137 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
2142 returnUnit
2139 returnUnit
2143 (Constant (I _), Nothing ) ->
2140 (Constant (I _), Nothing ) ->
2144 lift . tfail . InternalMsg $ "Not a list: " ++ show hints'
2141 lift . tfail . InternalMsg $ "Not a list: " ++ show hints'
@@ -2310,8 +2307,8 @@ runTac autoSolve ist perhapsFC fn tac
2310 runT Compute = compute
2307 runT Compute = compute
2311 runT Trivial = do trivial' ist; when autoSolve solveAll
2308 runT Trivial = do trivial' ist; when autoSolve solveAll
2312 runT TCInstance = runT (Exact (PResolveTC emptyFC))
2309 runT TCInstance = runT (Exact (PResolveTC emptyFC))
2313− runT (ProofSearch rec prover depth top hints)
2310+ runT (ProofSearch rec prover depth top psns hints)
2314− = do proofSearch' ist rec False depth prover top fn hints
2311+ = do proofSearch' ist rec False depth prover top fn psns hints
2315 when autoSolve solveAll
2312 when autoSolve solveAll
2316 runT (Focus n) = focus n
2313 runT (Focus n) = focus n
2317 runT Unfocus = do hs <- get_holes
2314 runT Unfocus = do hs <- get_holes
@@ -2519,7 +2516,7 @@ processTacticDecls info steps =
2519 updateIState $ \i -> i { idris_implicits =
2516 updateIState $ \i -> i { idris_implicits =
2520 addDef n impls (idris_implicits i) }
2517 addDef n impls (idris_implicits i) }
2521 addIBC (IBCImp n)
2518 addIBC (IBCImp n)
2522− ds <- checkDef fc (\_ e -> e) [(n, (-1, Nothing, ty))]
2519+ ds <- checkDef fc (\_ e -> e) [(n, (-1, Nothing, ty, []))]
2523 addIBC (IBCDef n)
2520 addIBC (IBCDef n)
2524 ctxt <- getContext
2521 ctxt <- getContext
2525 case lookupDef n ctxt of
2522 case lookupDef n ctxt of
@@ -2528,7 +2525,7 @@ processTacticDecls info steps =
2528 -- then it must be added as a metavariable. This needs guarding
2525 -- then it must be added as a metavariable. This needs guarding
2529 -- to prevent overwriting case defs with a metavar, if the case
2526 -- to prevent overwriting case defs with a metavar, if the case
2530 -- defs come after the type decl in the same script!
2527 -- 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
2532 in addDeferred ds'
2529 in addDeferred ds'
2533 _ -> return ()
2530 _ -> return ()
2534 RAddInstance className instName ->
2531 RAddInstance className instName ->