@@ -1,3 +1,4 @@
1{-# LANGUAGE PatternGuards #-}
2{-# LANGUAGE PatternGuards #-}
2module Idris.Prover (prover, showProof, showRunElab) where
3module Idris.Prover (prover, showProof, showRunElab) where
@@ -5,7 +6,7 @@ module Idris.Prover (prover, showProof, showRunElab) where
5-- This exludes (<$>) as fmap, because wl-pprint uses it for newline
6-- This exludes (<$>) as fmap, because wl-pprint uses it for newline
6import Prelude (Eq(..), Show(..),
7import Prelude (Eq(..), Show(..),
7 Bool(..), Either(..), Maybe(..), String,
8 Bool(..), Either(..), Maybe(..), String,
8− (.), ($), (++), (||),
9+ (.), ($), (++), (||), (&&),
9 concatMap, id, elem, error, fst, flip, foldl, foldr, init,
10 concatMap, id, elem, error, fst, flip, foldl, foldr, init,
10 length, lines, map, not, null, repeat, reverse, tail, zip)
11 length, lines, map, not, null, repeat, reverse, tail, zip)
@@ -89,7 +90,10 @@ prove mode opt ctxt lit n ty
89 (tm, prf) <-
90 (tm, prf) <-
91 then elabloop n True ("-" ++ show n) [] (ES (ps, initEState) "" Nothing) [] Nothing []
92 then elabloop n True ("-" ++ show n) [] (ES (ps, initEState) "" Nothing) [] Nothing []
93+ else do iputStrLn $ "Warning: this interactive prover is deprecated and will be removed " ++
94+ "in a future release. Please see :elab for a similar feature that "++
92− else ploop n True ("-" ++ show n) [] (ES (ps, initEState) "" Nothing) Nothing
96+ ploop n True ("-" ++ show n) [] (ES (ps, initEState) "" Nothing) Nothing
93 logLvl 1 $ "Adding " ++ show tm
97 logLvl 1 $ "Adding " ++ show tm
94 i <- getIState
98 i <- getIState
95 let shower = if mode
99 let shower = if mode
@@ -145,16 +149,16 @@ elabStep st e =
145 return (res, ctxt)
149 return (res, ctxt)
146 ((_,_,_,_,e,_,_):_) -> lift $ Error e
150 ((_,_,_,_,e,_,_):_) -> lift $ Error e
148−dumpState :: IState -> [(Name, Type, Term)] -> ProofState -> Idris ()
152+dumpState :: IState -> Bool -> [(Name, Type, Term)] -> ProofState -> Idris ()
149−dumpState ist menv ps | [] <- holes ps =
153+dumpState ist inElab menv ps | [] <- holes ps =
150 do let nm = thname ps
154 do let nm = thname ps
151 rendered <- iRender $ prettyName True False [] nm <> colon <+> text "No more goals."
155 rendered <- iRender $ prettyName True False [] nm <> colon <+> text "No more goals."
152 iputGoal rendered
156 iputGoal rendered
153−dumpState ist menv ps | (h : hs) <- holes ps = do
157+dumpState ist inElab menv ps | (h : hs) <- holes ps = do
154 let OK ty = goalAtFocus ps
158 let OK ty = goalAtFocus ps
155 let OK env = envAtFocus ps
159 let OK env = envAtFocus ps
156 let state = prettyOtherGoals hs <> line <>
160 let state = prettyOtherGoals hs <> line <>
157− prettyAssumptions ty env <> line <>
161+ prettyAssumptions inElab ty env <> line <>
158 prettyMetaValues (reverse menv) <>
162 prettyMetaValues (reverse menv) <>
159 prettyGoal (zip (assumptionNames env) (repeat False)) ty
163 prettyGoal (zip (assumptionNames env) (repeat False)) ty
160 rendered <- iRender state
164 rendered <- iRender state
@@ -172,18 +176,18 @@ dumpState ist menv ps | (h : hs) <- holes ps = do
172 assumptionNames :: Env -> [Name]
176 assumptionNames :: Env -> [Name]
173 assumptionNames = map fst
177 assumptionNames = map fst
175− prettyPs :: Binder Type -> [(Name, Bool)] -> Env -> Doc OutputAnnotation
179+ prettyPs :: Bool -> Binder Type -> [(Name, Bool)] -> Env -> Doc OutputAnnotation
176− prettyPs g bnd [] = empty
180+ prettyPs all g bnd [] = empty
177− prettyPs g bnd ((n@(MN _ r), _) : bs)
181+ prettyPs all g bnd ((n@(MN _ r), _) : bs)
178− | r == txt "rewrite_rule" = prettyPs g ((n, False):bnd) bs
182+ | not all && r == txt "rewrite_rule" = prettyPs all g ((n, False):bnd) bs
179− prettyPs g bnd ((n@(MN _ _), _) : bs)
183+ prettyPs all g bnd ((n@(MN _ _), _) : bs)
180− | not (n `elem` freeEnvNames bs || n `elem` goalNames g) = prettyPs g bnd bs
184+ | not (all || n `elem` freeEnvNames bs || n `elem` goalNames g) = prettyPs all g bnd bs
181− prettyPs g bnd ((n, Let t v) : bs) =
185+ prettyPs all g bnd ((n, Let t v) : bs) =
182 line <> bindingOf n False <+> text "=" <+> tPretty bnd v <+> colon <+>
186 line <> bindingOf n False <+> text "=" <+> tPretty bnd v <+> colon <+>
183− align (tPretty bnd t) <> prettyPs g ((n, False):bnd) bs
187+ align (tPretty bnd t) <> prettyPs all g ((n, False):bnd) bs
184− prettyPs g bnd ((n, b) : bs) =
188+ prettyPs all g bnd ((n, b) : bs) =
185 line <> bindingOf n False <+> colon <+>
189 line <> bindingOf n False <+> colon <+>
186− align (tPretty bnd (binderTy b)) <> prettyPs g ((n, False):bnd) bs
190+ align (tPretty bnd (binderTy b)) <> prettyPs all g ((n, False):bnd) bs
188 prettyMetaValues [] = empty
192 prettyMetaValues [] = empty
189 prettyMetaValues mvs =
193 prettyMetaValues mvs =
@@ -210,12 +214,12 @@ dumpState ist menv ps | (h : hs) <- holes ps = do
210 text "---------- Goal: ----------" <$$>
214 text "---------- Goal: ----------" <$$>
211 bindingOf h False <+> colon <+> align (prettyG bnd ty)
215 bindingOf h False <+> colon <+> align (prettyG bnd ty)
213− prettyAssumptions g env =
217+ prettyAssumptions inElab g env =
214 if length env == 0 then
218 if length env == 0 then
217 text "---------- Assumptions: ----------" <>
221 text "---------- Assumptions: ----------" <>
218− nest nestingSize (prettyPs g [] $ reverse env)
222+ nest nestingSize (prettyPs inElab g [] $ reverse env)
220 prettyOtherGoals hs =
224 prettyOtherGoals hs =
221 if length hs == 0 then
225 if length hs == 0 then
@@ -273,7 +277,7 @@ undoElab prf env st (h:hs) = do (prf', env', st') <- undoStep prf env st h
273elabloop :: Name -> Bool -> String -> [String] -> ElabState EState -> [ElabShellHistory] -> Maybe History -> [(Name, Type, Term)] -> Idris (Term, [String])
277elabloop :: Name -> Bool -> String -> [String] -> ElabState EState -> [ElabShellHistory] -> Maybe History -> [(Name, Type, Term)] -> Idris (Term, [String])
274elabloop fn d prompt prf e prev h env
278elabloop fn d prompt prf e prev h env
275 = do ist <- getIState
279 = do ist <- getIState
276− when d $ dumpState ist env (proof e)
280+ when d $ dumpState ist True env (proof e)
277 (x, h') <-
281 (x, h') <-
278 case idris_outputmode ist of
282 case idris_outputmode ist of
279 RawOutput _ ->
283 RawOutput _ ->
@@ -390,7 +394,7 @@ ploop :: Name -> Bool -> String -> [String] -> ElabState EState -> Maybe History
390ploop fn d prompt prf e h
394ploop fn d prompt prf e h
391 = do i <- getIState
395 = do i <- getIState
392 let autoSolve = opt_autoSolve (idris_options i)
396 let autoSolve = opt_autoSolve (idris_options i)
393− when d $ dumpState i [] (proof e)
397+ when d $ dumpState i False [] (proof e)
394 (x, h') <-
398 (x, h') <-
395 case idris_outputmode i of
399 case idris_outputmode i of
396 RawOutput _ ->
400 RawOutput _ ->