@@ -5,6 +5,7 @@ module Idris.ElabTerm where
5import Idris.AbsSyntax
5import Idris.AbsSyntax
6import Idris.DSL
6import Idris.DSL
7import Idris.Delaborate
7import Idris.Delaborate
8+import Idris.ProofSearch
9import Core.Elaborate hiding (Tactic(..))
10import Core.Elaborate hiding (Tactic(..))
10import Core.TT
11import Core.TT
@@ -26,8 +27,6 @@ data ElabInfo = EInfo { params :: [(Name, PTerm)],
27toplevel = EInfo [] emptyContext id Nothing
28toplevel = EInfo [] emptyContext id Nothing
29−type ElabD a = Elab' [PDecl] a
31-- Using the elaborator, convert a term in raw syntax to a fully
30-- Using the elaborator, convert a term in raw syntax to a fully
32-- elaborated, typechecked term.
31-- elaborated, typechecked term.
@@ -637,26 +636,6 @@ pruneByType (P _ n _) c as
638pruneByType t _ as = as
637pruneByType t _ as = as
640−trivial :: IState -> ElabD ()
641−trivial ist = try' (do elab ist toplevel False False (MN 0 "tac")
642− (PRefl (fileFC "prf") Placeholder)
649− tryAll [] = fail "No trivial solution"
651− = do -- if type of x has any holes in it, move on
654− if all (\n -> not (n `elem` hs)) (freeNames (binderTy b))
655− then try' (elab ist toplevel False False
656− (MN 0 "tac") (PRef (fileFC "prf") x))
660findInstances :: IState -> Term -> [Name]
639findInstances :: IState -> Term -> [Name]
661findInstances ist t
640findInstances ist t
662 | (P _ n _, _) <- unApply t
641 | (P _ n _, _) <- unApply t
@@ -665,16 +644,20 @@ findInstances ist t
666 | otherwise = []
645 | otherwise = []
647+trivial' ist = trivial (elab ist toplevel False False (MN 0 "tac")) ist
648+proofSearch' ist = trivial (elab ist toplevel False False (MN 0 "tac")) ist
668resolveTC :: Int -> Name -> IState -> ElabD ()
651resolveTC :: Int -> Name -> IState -> ElabD ()
669resolveTC 0 fn ist = fail $ "Can't resolve type class"
652resolveTC 0 fn ist = fail $ "Can't resolve type class"
670−resolveTC 1 fn ist = try' (trivial ist) (resolveTC 0 fn ist) True
653+resolveTC 1 fn ist = try' (trivial' ist) (resolveTC 0 fn ist) True
671resolveTC depth fn ist
654resolveTC depth fn ist
672 = do hnf_compute
655 = do hnf_compute
673 g <- goal
656 g <- goal
674 ptm <- get_term
657 ptm <- get_term
675 hs <- get_holes
658 hs <- get_holes
676 if True -- all (\n -> not (n `elem` hs)) (freeNames g)
659 if True -- all (\n -> not (n `elem` hs)) (freeNames g)
677− then try' (trivial ist)
660+ then try' (trivial' ist)
678 (do t <- goal
661 (do t <- goal
679 let (tc, ttypes) = unApply t
662 let (tc, ttypes) = unApply t
680 scopeOnly <- needsDefault t tc ttypes
663 scopeOnly <- needsDefault t tc ttypes
@@ -687,7 +670,7 @@ resolveTC depth fn ist
687-- if scopeOnly then fail "Can't resolve" else
670-- if scopeOnly then fail "Can't resolve" else
688 let depth' = if scopeOnly then 2 else depth
671 let depth' = if scopeOnly then 2 else depth
689 blunderbuss t depth' insts) True
672 blunderbuss t depth' insts) True
690− else do try' (trivial ist)
673+ else do try' (trivial' ist)
691 (do g <- goal
674 (do g <- goal
692 fail $ "Can't resolve " ++ show g) True
675 fail $ "Can't resolve " ++ show g) True
693-- tm <- get_term
676-- tm <- get_term
@@ -876,7 +859,8 @@ runTac autoSolve ist tac
876 elab ist toplevel False False (MN 0 "tac") tm
859 elab ist toplevel False False (MN 0 "tac") tm
877 when autoSolve solveAll
860 when autoSolve solveAll
878 runT Compute = compute
861 runT Compute = compute
862+ runT Trivial = do trivial' ist; when autoSolve solveAll
879− runT Trivial = do trivial ist; when autoSolve solveAll
863+ runT ProofSearch = do proofSearch' ist; when autoSolve solveAll
880 runT (Focus n) = focus n
864 runT (Focus n) = focus n
881 runT Solve = solve
865 runT Solve = solve
882 runT (Try l r) = do try' (runT l) (runT r) True
866 runT (Try l r) = do try' (runT l) (runT r) True