@@ -122,15 +122,15 @@ ideslave orig mods
122122 _ -> ""
123123 c <- colourise
124124 case parseCmd i "(input)" cmd of
125− Failure err -> iFail $ show (fixColour c err)
126− Success (Prove n') -> do iResult ""
125+ Failure err -> iPrintError $ show (fixColour c err)
126+ Success (Prove n') -> do iPrintResult ""
127127 idrisCatch
128128 (do process fn (Prove n'))
129− (\e -> do iFail $ show e)
129+ (\e -> do iPrintError $ show e)
130130 isetPrompt (mkPrompt mods)
131131 Success cmd -> idrisCatch
132132 (do ideslaveProcess fn cmd)
133− (\e -> do iFail $ show e)
133+ (\e -> do iPrintError $ show e)
134134 Just (REPLCompletions str) ->
135135 do (unused, compls) <- replCompletion (reverse str, "")
136136 let good = SexpList [SymbolAtom "ok", toSExp (map replacement compls, reverse unused)]
@@ -146,17 +146,17 @@ ideslave orig mods
146146 -- Report either success or failure
147147 i <- getIState
148148 case (errLine i) of
149− Nothing -> iResult $ "loaded " ++ filename
150− Just x -> iFail $ "didn't load " ++ filename
149+ Nothing -> iPrintResult $ "loaded " ++ filename
150+ Just x -> iPrintError $ "didn't load " ++ filename
151151 ideslave orig [filename]
152− Nothing -> do iFail "did not understand")
153− (\e -> do iFail $ show e)
152+ Nothing -> do iPrintError "did not understand")
153+ (\e -> do iPrintError $ show e)
154154 ideslave orig mods
155155
156156ideslaveProcess :: FilePath -> Command -> Idris ()
157157ideslaveProcess fn Help = process fn Help
158158ideslaveProcess fn (ChangeDirectory f) = do process fn (ChangeDirectory f)
159− iResult "changed directory to"
159+ iPrintResult "changed directory to"
160160ideslaveProcess fn (Eval t) = process fn (Eval t)
161161ideslaveProcess fn (ExecVal t) = process fn (ExecVal t)
162162ideslaveProcess fn (Check (PRef x n)) = process fn (Check (PRef x n))
@@ -164,10 +164,10 @@ ideslaveProcess fn (Check t) = process fn (Check t)
164164ideslaveProcess fn (DocStr n) = process fn (DocStr n)
165165ideslaveProcess fn Universes = process fn Universes
166166ideslaveProcess fn (Defn n) = do process fn (Defn n)
167− iResult ""
167+ iPrintResult ""
168168ideslaveProcess fn (TotCheck n) = process fn (TotCheck n)
169169ideslaveProcess fn (DebugInfo n) = do process fn (DebugInfo n)
170− iResult ""
170+ iPrintResult ""
171171ideslaveProcess fn (Info n) = process fn (Info n)
172172ideslaveProcess fn (Search t) = process fn (Search t)
173173ideslaveProcess fn (Spec t) = process fn (Spec t)
@@ -179,29 +179,29 @@ ideslaveProcess fn (HNF t) = process fn (HNF t)
179179--that most likely does not work, since we need to wrap
180180--input/output of the executed binary...
181181ideslaveProcess fn Execute = do process fn Execute
182− iResult ""
182+ iPrintResult ""
183183ideslaveProcess fn (Compile codegen f) = do process fn (Compile codegen f)
184− iResult ""
184+ iPrintResult ""
185185ideslaveProcess fn (LogLvl i) = do process fn (LogLvl i)
186− iResult ""
186+ iPrintResult ""
187187ideslaveProcess fn (Pattelab t) = process fn (Pattelab t)
188188ideslaveProcess fn (Missing n) = process fn (Missing n)
189189ideslaveProcess fn (DynamicLink l) = do process fn (DynamicLink l)
190− iResult ""
190+ iPrintResult ""
191191ideslaveProcess fn ListDynamic = do process fn ListDynamic
192− iResult ""
192+ iPrintResult ""
193193ideslaveProcess fn Metavars = process fn Metavars
194194ideslaveProcess fn (SetOpt ErrContext) = do process fn (SetOpt ErrContext)
195− iResult ""
195+ iPrintResult ""
196196ideslaveProcess fn (UnsetOpt ErrContext) = do process fn (UnsetOpt ErrContext)
197− iResult ""
197+ iPrintResult ""
198198ideslaveProcess fn (SetOpt ShowImpl) = do process fn (SetOpt ShowImpl)
199− iResult ""
199+ iPrintResult ""
200200ideslaveProcess fn (UnsetOpt ShowImpl) = do process fn (UnsetOpt ShowImpl)
201− iResult ""
201+ iPrintResult ""
202202ideslaveProcess fn (SetOpt x) = process fn (SetOpt x)
203203ideslaveProcess fn (UnsetOpt x) = process fn (UnsetOpt x)
204−ideslaveProcess fn _ = iFail "command not recognized or not supported"
204+ideslaveProcess fn _ = iPrintError "command not recognized or not supported"
205205
206206
207207-- | The prompt consists of the currently loaded modules, or "Idris" if there are none
@@ -261,7 +261,7 @@ resolveProof n'
261261 n <- case lookupNames n' ctxt of
262262 [x] -> return x
263263 [] -> return n'
264− ns -> fail $ pshow i (CantResolveAlts (map show ns))
264+ ns -> ierror (CantResolveAlts (map show ns))
265265 return n
266266
267267removeProof :: Name -> Idris ()
@@ -309,7 +309,7 @@ insertScript prf (p@"---------- Proofs ----------" : "" : xs)
309309insertScript prf (x : xs) = x : insertScript prf xs
310310
311311process :: FilePath -> Command -> Idris ()
312−process fn Help = iResult displayHelp
312+process fn Help = iPrintResult displayHelp
313313process fn (ChangeDirectory f)
314314 = do liftIO $ setCurrentDirectory f
315315 return ()
@@ -325,7 +325,7 @@ process fn (Eval t)
325325 logLvl 10 $ "Debug: " ++ showEnvDbg [] tm'
326326 imp <- impShow
327327 c <- colourise
328− iResult (showImp (Just ist) imp c (delab ist tm') ++ " : " ++
328+ iPrintResult (showImp (Just ist) imp c (delab ist tm') ++ " : " ++
329329 showImp (Just ist) imp c (delab ist ty'))
330330process fn (ExecVal t)
331331 = do ctxt <- getContext
@@ -336,7 +336,7 @@ process fn (ExecVal t)
336336 res <- execute tm
337337 imp <- impShow
338338 c <- colourise
339− iResult (showImp (Just ist) imp c (delab ist res) ++ " : " ++
339+ iPrintResult (showImp (Just ist) imp c (delab ist res) ++ " : " ++
340340 showImp (Just ist) imp c (delab ist ty'))
341341process fn (Check (PRef _ n))
342342 = do ctxt <- getContext
@@ -346,8 +346,8 @@ process fn (Check (PRef _ n))
346346 case lookupNames n ctxt of
347347 ts@(_:_) -> do mapM_ (\n -> iputStrLn $ showName (Just ist) [] False c n ++ " : " ++
348348 showImp (Just ist) imp c (delabTy ist n)) ts
349− iResult ""
350− [] -> iFail $ "No such variable " ++ show n
349+ iPrintResult ""
350+ [] -> iPrintError $ "No such variable " ++ show n
351351process fn (Check t)
352352 = do (tm, ty) <- elabVal toplevel False t
353353 ctxt <- getContext
@@ -356,15 +356,15 @@ process fn (Check t)
356356 c <- colourise
357357 let ty' = normaliseC ctxt [] ty
358358 case tm of
359− TType _ -> iResult ("Type : Type 1")
360− _ -> iResult (showImp (Just ist) imp c (delab ist tm) ++ " : " ++
361− showImp (Just ist) imp c (delab ist ty))
359+ TType _ -> iPrintResult ("Type : Type 1")
360+ _ -> iPrintResult (showImp (Just ist) imp c (delab ist tm) ++ " : " ++
361+ showImp (Just ist) imp c (delab ist ty))
362362
363363process fn (DocStr n) = do i <- getIState
364364 case lookupCtxtName n (idris_docstrings i) of
365− [] -> iFail $ "No documentation for " ++ show n
365+ [] -> iPrintError $ "No documentation for " ++ show n
366366 ns -> do mapM_ showDoc ns
367− iResult ""
367+ iPrintResult ""
368368 where showDoc (n, d)
369369 = do doc <- getDocs n
370370 iputStrLn $ show doc
@@ -375,8 +375,8 @@ process fn Universes = do i <- getIState
375375 let n = length cs
376376 iputStrLn $ "(" ++ show n ++ " constraints)"
377377 case ucheck cs of
378− Error e -> iFail $ pshow i e
379− OK _ -> iResult "Universes OK"
378+ Error e -> iPrintError $ pshow i e
379+ OK _ -> iPrintResult "Universes OK"
380380process fn (Defn n) = do i <- getIState
381381 iputStrLn "Compiled patterns:\n"
382382 iputStrLn $ show (lookupDef n (tt_ctxt i))
@@ -393,8 +393,8 @@ process fn (Defn n) = do i <- getIState
393393 showImp (Just i) True c (delab i rhs))
394394process fn (TotCheck n) = do i <- getIState
395395 case lookupTotal n (tt_ctxt i) of
396− [t] -> iResult (showTotal t i)
397− _ -> do iFail ""
396+ [t] -> iPrintResult (showTotal t i)
397+ _ -> do iPrintError ""
398398 return ()
399399process fn (DebugInfo n)
400400 = do i <- getIState
@@ -417,13 +417,13 @@ process fn (DebugInfo n)
417417process fn (Info n) = do i <- getIState
418418 case lookupCtxt n (idris_classes i) of
419419 [c] -> classInfo c
420− _ -> iFail "Not a class"
421−process fn (Search t) = iFail "Not implemented"
420+ _ -> iPrintError "Not a class"
421+process fn (Search t) = iPrintError "Not implemented"
422422process fn (Spec t) = do (tm, ty) <- elabVal toplevel False t
423423 ctxt <- getContext
424424 ist <- getIState
425425 let tm' = simplify ctxt [] {- (idris_statics ist) -} tm
426− iResult (show (delab ist tm'))
426+ iPrintResult (show (delab ist tm'))
427427
428428process fn (RmProof n')
429429 = do i <- getIState
@@ -450,7 +450,7 @@ process fn' (AddProof prf)
450450 then return fn'
451451 else if exExt
452452 then return fnExt
453− else fail $ "Neither \""++fn'++"\" nor \""++fnExt++"\" exist"
453+ else ifail $ "Neither \""++fn'++"\" nor \""++fnExt++"\" exist"
454454 let fb = fn ++ "~"
455455 liftIO $ copyFile fn fb -- make a backup in case something goes wrong!
456456 prog <- liftIO $ readFile fb
@@ -458,7 +458,7 @@ process fn' (AddProof prf)
458458 let proofs = proof_list i
459459 n' <- case prf of
460460 Nothing -> case proofs of
461− [] -> fail "No proof to add"
461+ [] -> ifail "No proof to add"
462462 ((x, p) : _) -> return x
463463 Just nm -> return nm
464464 n <- resolveProof n'
@@ -475,8 +475,8 @@ process fn (ShowProof n')
475475 n <- resolveProof n'
476476 let proofs = proof_list i
477477 case lookup n proofs of
478− Nothing -> iFail "No proof to show"
479− Just p -> iResult $ showProof False n p
478+ Nothing -> iPrintError "No proof to show"
479+ Just p -> iPrintResult $ showProof False n p
480480
481481process fn (Prove n')
482482 = do ctxt <- getContext
@@ -484,7 +484,7 @@ process fn (Prove n')
484484 n <- case lookupNames n' ctxt of
485485 [x] -> return x
486486 [] -> return n'
487− ns -> fail $ pshow ist (CantResolveAlts (map show ns))
487+ ns -> ierror (CantResolveAlts (map show ns))
488488 prover (lit fn) n
489489 -- recheck totality
490490 i <- getIState
@@ -496,14 +496,14 @@ process fn (HNF t) = do (tm, ty) <- elabVal toplevel False t
496496 ctxt <- getContext
497497 ist <- getIState
498498 let tm' = hnf ctxt [] tm
499− iResult (show (delab ist tm'))
499+ iPrintResult (show (delab ist tm'))
500500process fn (TestInline t) = do (tm, ty) <- elabVal toplevel False t
501501 ctxt <- getContext
502502 ist <- getIState
503503 let tm' = inlineTerm ist tm
504504 imp <- impShow
505505 c <- colourise
506− iResult (showImp (Just ist) imp c (delab ist tm'))
506+ iPrintResult (showImp (Just ist) imp c (delab ist tm'))
507507process fn TTShell = do ist <- getIState
508508 let shst = initState (tt_ctxt ist)
509509 runShell shst
@@ -530,7 +530,7 @@ process fn (LogLvl i) = setLogLevel i
530530-- Elaborate as if LHS of a pattern (debug command)
531531process fn (Pattelab t)
532532 = do (tm, ty) <- elabVal toplevel True t
533− iResult $ show tm ++ "\n\n : " ++ show ty
533+ iPrintResult $ show tm ++ "\n\n : " ++ show ty
534534
535535process fn (Missing n)
536536 = do i <- getIState
@@ -538,13 +538,13 @@ process fn (Missing n)
538538 case lookupCtxt n (idris_patdefs i) of
539539 [] -> return ()
540540 [(_, tms)] ->
541− iResult (showSep "\n" (map (showImp (Just i) True c) tms))
542− _ -> iFail $ "Ambiguous name"
541+ iPrintResult (showSep "\n" (map (showImp (Just i) True c) tms))
542+ _ -> iPrintError $ "Ambiguous name"
543543process fn (DynamicLink l) = do i <- getIState
544544 let lib = trim l
545545 handle <- lift . lift $ tryLoadLib lib
546546 case handle of
547− Nothing -> iFail $ "Could not load dynamic lib \"" ++ l ++ "\""
547+ Nothing -> iPrintError $ "Could not load dynamic lib \"" ++ l ++ "\""
548548 Just x -> do let libs = idris_dynamic_libs i
549549 if x `elem` libs
550550 then do iLOG ("Tried to load duplicate library " ++ lib_name x)
@@ -560,8 +560,8 @@ process fn Metavars
560560 = do ist <- getIState
561561 let mvs = idris_metavars ist \\ primDefs
562562 case mvs of
563− [] -> iFail "No global metavariables to solve"
564− _ -> iResult $ "Global metavariables:\n\t" ++ show mvs
563+ [] -> iPrintError "No global metavariables to solve"
564+ _ -> iPrintResult $ "Global metavariables:\n\t" ++ show mvs
565565process fn NOP = return ()
566566
567567process fn (SetOpt ErrContext) = setErrContext True
@@ -569,8 +569,8 @@ process fn (UnsetOpt ErrContext) = setErrContext False
569569process fn (SetOpt ShowImpl) = setImpShow True
570570process fn (UnsetOpt ShowImpl) = setImpShow False
571571
572−process fn (SetOpt _) = iFail "Not a valid option"
573−process fn (UnsetOpt _) = iFail "Not a valid option"
572+process fn (SetOpt _) = iPrintError "Not a valid option"
573+process fn (UnsetOpt _) = iPrintError "Not a valid option"
574574process fn (SetColour ty c) = setColour ty c
575575process fn ColourOn = do ist <- getIState
576576 putIState $ ist { idris_colourRepl = True }
@@ -584,7 +584,7 @@ classInfo ci = do iputStrLn "Methods:\n"
584584 iputStrLn ""
585585 iputStrLn "Instances:\n"
586586 mapM_ dumpInstance (class_instances ci)
587− iResult ""
587+ iPrintResult ""
588588
589589dumpMethod :: (Name, (FnOpts, PTerm)) -> Idris ()
590590dumpMethod (n, (_, t)) = iputStrLn $ show n ++ " : " ++ show t
@@ -891,7 +891,7 @@ initScript = do script <- getInitScript
891891 h <- liftIO $ openFile script ReadMode
892892 runInit h
893893 liftIO $ hClose h)
894− (\e -> iFail $ "Error reading init file: " ++ show e)
894+ (\e -> iPrintError $ "Error reading init file: " ++ show e)
895895 where runInit :: Handle -> Idris ()
896896 runInit h = do eof <- lift . lift $ hIsEOF h
897897 ist <- getIState
@@ -904,12 +904,12 @@ initScript = do script <- getInitScript
904904 processLine i cmd input clr =
905905 case parseCmd i input cmd of
906906 Failure err -> liftIO $ print (fixColour clr err)
907− Success Reload -> iFail "Init scripts cannot reload the file"
908− Success (Load f) -> iFail "Init scripts cannot load files"
909− Success (ModImport f) -> iFail "Init scripts cannot import modules"
910− Success Edit -> iFail "Init scripts cannot invoke the editor"
907+ Success Reload -> iPrintError "Init scripts cannot reload the file"
908+ Success (Load f) -> iPrintError "Init scripts cannot load files"
909+ Success (ModImport f) -> iPrintError "Init scripts cannot import modules"
910+ Success Edit -> iPrintError "Init scripts cannot invoke the editor"
911911 Success Proofs -> proofs i
912− Success Quit -> iFail "Init scripts cannot quit Idris"
912+ Success Quit -> iPrintError "Init scripts cannot quit Idris"
913913 Success cmd -> process [] cmd
914914
915915getFile :: Opt -> Maybe String