@@ -10,7 +10,7 @@ import Idris.AbsSyntax
1010import Idris.Delaborate
1111import Idris.ElabDecls
1212import Idris.ElabTerm
13−import Idris.Parser
13+import Idris.Parser hiding (params)
1414import Idris.Error
1515import Idris.DataOpts
1616import Idris.Completion
@@ -21,6 +21,7 @@ import Text.Trifecta.Result(Result(..))
2121import System.Console.Haskeline
2222import System.Console.Haskeline.History
2323import Control.Monad.State.Strict
24+import Control.DeepSeq
2425
2526import Util.Pretty
2627import Debug.Trace
@@ -200,6 +201,64 @@ ploop d prompt prf e h
200201 when (not (null hs)) $ ifail "Incomplete proof"
201202 iPrintResult "Proof completed!"
202203 return (False, e, True, prf)
204+ Success (TCheck (PRef _ n)) ->
205+ do ctxt <- getContext
206+ ist <- getIState
207+ imp <- impShow
208+ idrisCatch (do
209+ let h = idris_outh ist
210+ OK env = envAtFocus (proof e)
211+ ctxt' = envCtxt env ctxt
212+ bnd = map (\x -> (fst x, False)) env
213+ ist' = ist { tt_ctxt = ctxt' }
214+ putIState ist'
215+ -- Unlike the REPL, metavars have no special treatment, to
216+ -- make it easier to see how to prove with them.
217+ case lookupNames n ctxt' of
218+ [] -> ihPrintError h $ "No such variable " ++ show n
219+ ts -> ihPrintFunTypes h bnd n (map (\n -> (n, delabTy ist' n)) ts)
220+ putIState ist
221+ return (False, e, False, prf))
222+ (\err -> do putIState ist ; ierror err)
223+ Success (TCheck t) ->
224+ do ist <- getIState
225+ ctxt <- getContext
226+ idrisCatch (do
227+ let OK env = envAtFocus (proof e)
228+ ctxt' = envCtxt env ctxt
229+ putIState ist { tt_ctxt = ctxt' }
230+ (tm, ty) <- elabVal toplevel False t
231+ let imp = opt_showimp (idris_options ist)
232+ ty' = normaliseC ctxt [] ty
233+ h = idris_outh ist
234+ case tm of
235+ TType _ ->
236+ ihPrintTermWithType h (prettyImp imp PType) type1Doc
237+ _ -> let bnd = map (\x -> (fst x, False)) env in
238+ ihPrintTermWithType h (pprintPTerm imp bnd (delab ist tm))
239+ (pprintPTerm imp bnd (delab ist ty))
240+ putIState ist
241+ return (False, e, False, prf))
242+ (\err -> do putIState ist { tt_ctxt = ctxt } ; ierror err)
243+ Success (TEval t) -> withErrorReflection $
244+ do ctxt <- getContext
245+ ist <- getIState
246+ idrisCatch (do
247+ let OK env = envAtFocus (proof e)
248+ ctxt' = envCtxt env ctxt
249+ ist' = ist { tt_ctxt = ctxt' }
250+ bnd = map (\x -> (fst x, False)) env
251+ putIState ist'
252+ (tm, ty) <- elabVal toplevel False t
253+ let tm' = force (normaliseAll ctxt' env tm)
254+ ty' = force (normaliseAll ctxt' env ty)
255+ imp = opt_showimp (idris_options ist')
256+ tmDoc = pprintPTerm imp bnd (delab ist' tm')
257+ tyDoc = pprintPTerm imp bnd (delab ist' ty')
258+ ihPrintTermWithType (idris_outh ist') tmDoc tyDoc
259+ putIState ist
260+ return (False, e, False, prf))
261+ (\err -> do putIState ist ; ierror err)
203262 Success tac -> do (_, e) <- elabStep e saveState
204263 (_, st) <- elabStep e (runTac True i tac)
205264-- trace (show (problems (proof st))) $
@@ -211,4 +270,4 @@ ploop d prompt prf e h
211270 if done then do (tm, _) <- elabStep st get_term
212271 return (tm, prf')
213272 else ploop d prompt prf' st h'
214−
273+ where envCtxt env ctxt = foldl (\c (n, b) -> addTyDecl n Bound (binderTy b) c) ctxt env