@@ -5,6 +5,7 @@ module Idris.ElabTerm where
55import Idris.AbsSyntax
66import Idris.DSL
77import Idris.Delaborate
8+import Idris.ProofSearch
89
910import Core.Elaborate hiding (Tactic(..))
1011import Core.TT
@@ -26,8 +27,6 @@ data ElabInfo = EInfo { params :: [(Name, PTerm)],
2627
2728toplevel = EInfo [] emptyContext id Nothing
2829
29−type ElabD a = Elab' [PDecl] a
30−
3130-- Using the elaborator, convert a term in raw syntax to a fully
3231-- elaborated, typechecked term.
3332--
@@ -637,26 +636,6 @@ pruneByType (P _ n _) c as
637636
638637pruneByType t _ as = as
639638
640−trivial :: IState -> ElabD ()
641−trivial ist = try' (do elab ist toplevel False False (MN 0 "tac")
642− (PRefl (fileFC "prf") Placeholder)
643− return ())
644− (do env <- get_env
645− g <- goal
646− tryAll env
647− return ()) True
648− where
649− tryAll [] = fail "No trivial solution"
650− tryAll ((x, b):xs)
651− = do -- if type of x has any holes in it, move on
652− hs <- get_holes
653− g <- goal
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))
657− (tryAll xs) True
658− else tryAll xs
659−
660639findInstances :: IState -> Term -> [Name]
661640findInstances ist t
662641 | (P _ n _, _) <- unApply t
@@ -665,16 +644,20 @@ findInstances ist t
665644 _ -> []
666645 | otherwise = []
667646
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
649+
650+
668651resolveTC :: Int -> Name -> IState -> ElabD ()
669652resolveTC 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
671654resolveTC depth fn ist
672655 = do hnf_compute
673656 g <- goal
674657 ptm <- get_term
675658 hs <- get_holes
676659 if True -- all (\n -> not (n `elem` hs)) (freeNames g)
677− then try' (trivial ist)
660+ then try' (trivial' ist)
678661 (do t <- goal
679662 let (tc, ttypes) = unApply t
680663 scopeOnly <- needsDefault t tc ttypes
@@ -687,7 +670,7 @@ resolveTC depth fn ist
687670-- if scopeOnly then fail "Can't resolve" else
688671 let depth' = if scopeOnly then 2 else depth
689672 blunderbuss t depth' insts) True
690− else do try' (trivial ist)
673+ else do try' (trivial' ist)
691674 (do g <- goal
692675 fail $ "Can't resolve " ++ show g) True
693676-- tm <- get_term
@@ -876,7 +859,8 @@ runTac autoSolve ist tac
876859 elab ist toplevel False False (MN 0 "tac") tm
877860 when autoSolve solveAll
878861 runT Compute = compute
879− runT Trivial = do trivial ist; when autoSolve solveAll
862+ runT Trivial = do trivial' ist; when autoSolve solveAll
863+ runT ProofSearch = do proofSearch' ist; when autoSolve solveAll
880864 runT (Focus n) = focus n
881865 runT Solve = solve
882866 runT (Try l r) = do try' (runT l) (runT r) True