@@ -56,6 +56,7 @@ import System.Process
56import System.Directory
56import System.Directory
57import System.IO
57import System.IO
58import Control.Monad
58import Control.Monad
59+import Control.Monad.Trans.Error (ErrorT(..))
59import Control.Monad.Trans.State.Strict ( StateT, execStateT, get, put )
60import Control.Monad.Trans.State.Strict ( StateT, execStateT, get, put )
60import Control.Monad.Trans ( liftIO, lift )
61import Control.Monad.Trans ( liftIO, lift )
61import Data.Maybe
62import Data.Maybe
@@ -121,15 +122,15 @@ ideslave orig mods
122 c <- colourise
123 c <- colourise
123 case parseCmd i "(input)" cmd of
124 case parseCmd i "(input)" cmd of
124− Failure err -> iFail $ show (fixColour c err)
125+ Failure err -> iPrintError $ show (fixColour c err)
125− Success (Prove n') -> do iResult ""
126+ Success (Prove n') -> do iPrintResult ""
126 idrisCatch
127 idrisCatch
127 (do process fn (Prove n'))
128 (do process fn (Prove n'))
128− (\e -> do iFail $ show e)
129+ (\e -> do iPrintError $ show e)
129 isetPrompt (mkPrompt mods)
130 isetPrompt (mkPrompt mods)
130 Success cmd -> idrisCatch
131 Success cmd -> idrisCatch
131 (do ideslaveProcess fn cmd)
132 (do ideslaveProcess fn cmd)
132− (\e -> do iFail $ show e)
133+ (\e -> do iPrintError $ show e)
133 Just (REPLCompletions str) ->
134 Just (REPLCompletions str) ->
134 do (unused, compls) <- replCompletion (reverse str, "")
135 do (unused, compls) <- replCompletion (reverse str, "")
135 let good = SexpList [SymbolAtom "ok", toSExp (map replacement compls, reverse unused)]
136 let good = SexpList [SymbolAtom "ok", toSExp (map replacement compls, reverse unused)]
@@ -145,17 +146,17 @@ ideslave orig mods
145 -- Report either success or failure
146 -- Report either success or failure
146 i <- getIState
147 i <- getIState
147 case (errLine i) of
148 case (errLine i) of
148− Nothing -> iResult $ "loaded " ++ filename
149+ Nothing -> iPrintResult $ "loaded " ++ filename
149− Just x -> iFail $ "didn't load " ++ filename
150+ Just x -> iPrintError $ "didn't load " ++ filename
150 ideslave orig [filename]
151 ideslave orig [filename]
151− Nothing -> do iFail "did not understand")
152+ Nothing -> do iPrintError "did not understand")
152− (\e -> do iFail $ show e)
153+ (\e -> do iPrintError $ show e)
153 ideslave orig mods
154 ideslave orig mods
155ideslaveProcess :: FilePath -> Command -> Idris ()
156ideslaveProcess :: FilePath -> Command -> Idris ()
156ideslaveProcess fn Help = process fn Help
157ideslaveProcess fn Help = process fn Help
157ideslaveProcess fn (ChangeDirectory f) = do process fn (ChangeDirectory f)
158ideslaveProcess fn (ChangeDirectory f) = do process fn (ChangeDirectory f)
158− iResult "changed directory to"
159+ iPrintResult "changed directory to"
159ideslaveProcess fn (Eval t) = process fn (Eval t)
160ideslaveProcess fn (Eval t) = process fn (Eval t)
160ideslaveProcess fn (ExecVal t) = process fn (ExecVal t)
161ideslaveProcess fn (ExecVal t) = process fn (ExecVal t)
161ideslaveProcess fn (Check (PRef x n)) = process fn (Check (PRef x n))
162ideslaveProcess fn (Check (PRef x n)) = process fn (Check (PRef x n))
@@ -163,10 +164,10 @@ ideslaveProcess fn (Check t) = process fn (Check t)
163ideslaveProcess fn (DocStr n) = process fn (DocStr n)
164ideslaveProcess fn (DocStr n) = process fn (DocStr n)
164ideslaveProcess fn Universes = process fn Universes
165ideslaveProcess fn Universes = process fn Universes
165ideslaveProcess fn (Defn n) = do process fn (Defn n)
166ideslaveProcess fn (Defn n) = do process fn (Defn n)
166− iResult ""
167+ iPrintResult ""
167ideslaveProcess fn (TotCheck n) = process fn (TotCheck n)
168ideslaveProcess fn (TotCheck n) = process fn (TotCheck n)
168ideslaveProcess fn (DebugInfo n) = do process fn (DebugInfo n)
169ideslaveProcess fn (DebugInfo n) = do process fn (DebugInfo n)
169− iResult ""
170+ iPrintResult ""
170ideslaveProcess fn (Info n) = process fn (Info n)
171ideslaveProcess fn (Info n) = process fn (Info n)
171ideslaveProcess fn (Search t) = process fn (Search t)
172ideslaveProcess fn (Search t) = process fn (Search t)
172ideslaveProcess fn (Spec t) = process fn (Spec t)
173ideslaveProcess fn (Spec t) = process fn (Spec t)
@@ -178,29 +179,29 @@ ideslaveProcess fn (HNF t) = process fn (HNF t)
178--that most likely does not work, since we need to wrap
179--that most likely does not work, since we need to wrap
179--input/output of the executed binary...
180--input/output of the executed binary...
180ideslaveProcess fn Execute = do process fn Execute
181ideslaveProcess fn Execute = do process fn Execute
181− iResult ""
182+ iPrintResult ""
182ideslaveProcess fn (Compile codegen f) = do process fn (Compile codegen f)
183ideslaveProcess fn (Compile codegen f) = do process fn (Compile codegen f)
183− iResult ""
184+ iPrintResult ""
184ideslaveProcess fn (LogLvl i) = do process fn (LogLvl i)
185ideslaveProcess fn (LogLvl i) = do process fn (LogLvl i)
185− iResult ""
186+ iPrintResult ""
186ideslaveProcess fn (Pattelab t) = process fn (Pattelab t)
187ideslaveProcess fn (Pattelab t) = process fn (Pattelab t)
187ideslaveProcess fn (Missing n) = process fn (Missing n)
188ideslaveProcess fn (Missing n) = process fn (Missing n)
188ideslaveProcess fn (DynamicLink l) = do process fn (DynamicLink l)
189ideslaveProcess fn (DynamicLink l) = do process fn (DynamicLink l)
189− iResult ""
190+ iPrintResult ""
190ideslaveProcess fn ListDynamic = do process fn ListDynamic
191ideslaveProcess fn ListDynamic = do process fn ListDynamic
191− iResult ""
192+ iPrintResult ""
192ideslaveProcess fn Metavars = process fn Metavars
193ideslaveProcess fn Metavars = process fn Metavars
193ideslaveProcess fn (SetOpt ErrContext) = do process fn (SetOpt ErrContext)
194ideslaveProcess fn (SetOpt ErrContext) = do process fn (SetOpt ErrContext)
194− iResult ""
195+ iPrintResult ""
195ideslaveProcess fn (UnsetOpt ErrContext) = do process fn (UnsetOpt ErrContext)
196ideslaveProcess fn (UnsetOpt ErrContext) = do process fn (UnsetOpt ErrContext)
196− iResult ""
197+ iPrintResult ""
197ideslaveProcess fn (SetOpt ShowImpl) = do process fn (SetOpt ShowImpl)
198ideslaveProcess fn (SetOpt ShowImpl) = do process fn (SetOpt ShowImpl)
198− iResult ""
199+ iPrintResult ""
199ideslaveProcess fn (UnsetOpt ShowImpl) = do process fn (UnsetOpt ShowImpl)
200ideslaveProcess fn (UnsetOpt ShowImpl) = do process fn (UnsetOpt ShowImpl)
200− iResult ""
201+ iPrintResult ""
201ideslaveProcess fn (SetOpt x) = process fn (SetOpt x)
202ideslaveProcess fn (SetOpt x) = process fn (SetOpt x)
202ideslaveProcess fn (UnsetOpt x) = process fn (UnsetOpt x)
203ideslaveProcess fn (UnsetOpt x) = process fn (UnsetOpt x)
203−ideslaveProcess fn _ = iFail "command not recognized or not supported"
204+ideslaveProcess fn _ = iPrintError "command not recognized or not supported"
206-- | The prompt consists of the currently loaded modules, or "Idris" if there are none
207-- | The prompt consists of the currently loaded modules, or "Idris" if there are none
@@ -250,7 +251,7 @@ processInput cmd orig inputs
250 Success Quit -> do when (not quiet) (iputStrLn "Bye bye")
251 Success Quit -> do when (not quiet) (iputStrLn "Bye bye")
251 return Nothing
252 return Nothing
252 Success cmd -> do idrisCatch (process fn cmd)
253 Success cmd -> do idrisCatch (process fn cmd)
253− (\e -> iputStrLn (show e))
254+ (\e -> do msg <- showErr e ; iputStrLn msg)
254 return (Just inputs)
255 return (Just inputs)
256resolveProof :: Name -> Idris Name
257resolveProof :: Name -> Idris Name
@@ -260,7 +261,7 @@ resolveProof n'
260 n <- case lookupNames n' ctxt of
261 n <- case lookupNames n' ctxt of
261 [x] -> return x
262 [x] -> return x
262 [] -> return n'
263 [] -> return n'
263− ns -> fail $ pshow i (CantResolveAlts (map show ns))
264+ ns -> ierror (CantResolveAlts (map show ns))
266removeProof :: Name -> Idris ()
267removeProof :: Name -> Idris ()
@@ -308,7 +309,7 @@ insertScript prf (p@"---------- Proofs ----------" : "" : xs)
308insertScript prf (x : xs) = x : insertScript prf xs
309insertScript prf (x : xs) = x : insertScript prf xs
310process :: FilePath -> Command -> Idris ()
311process :: FilePath -> Command -> Idris ()
311−process fn Help = iResult displayHelp
312+process fn Help = iPrintResult displayHelp
312process fn (ChangeDirectory f)
313process fn (ChangeDirectory f)
313 = do liftIO $ setCurrentDirectory f
314 = do liftIO $ setCurrentDirectory f
314 return ()
315 return ()
@@ -324,7 +325,7 @@ process fn (Eval t)
324 logLvl 10 $ "Debug: " ++ showEnvDbg [] tm'
325 logLvl 10 $ "Debug: " ++ showEnvDbg [] tm'
325 imp <- impShow
326 imp <- impShow
326 c <- colourise
327 c <- colourise
327− iResult (showImp (Just ist) imp c (delab ist tm') ++ " : " ++
328+ iPrintResult (showImp (Just ist) imp c (delab ist tm') ++ " : " ++
328 showImp (Just ist) imp c (delab ist ty'))
329 showImp (Just ist) imp c (delab ist ty'))
329process fn (ExecVal t)
330process fn (ExecVal t)
330 = do ctxt <- getContext
331 = do ctxt <- getContext
@@ -335,7 +336,7 @@ process fn (ExecVal t)
335 res <- execute tm
336 res <- execute tm
336 imp <- impShow
337 imp <- impShow
337 c <- colourise
338 c <- colourise
338− iResult (showImp (Just ist) imp c (delab ist res) ++ " : " ++
339+ iPrintResult (showImp (Just ist) imp c (delab ist res) ++ " : " ++
339 showImp (Just ist) imp c (delab ist ty'))
340 showImp (Just ist) imp c (delab ist ty'))
340process fn (Check (PRef _ n))
341process fn (Check (PRef _ n))
341 = do ctxt <- getContext
342 = do ctxt <- getContext
@@ -345,8 +346,8 @@ process fn (Check (PRef _ n))
345 case lookupNames n ctxt of
346 case lookupNames n ctxt of
346 ts@(_:_) -> do mapM_ (\n -> iputStrLn $ showName (Just ist) [] False c n ++ " : " ++
347 ts@(_:_) -> do mapM_ (\n -> iputStrLn $ showName (Just ist) [] False c n ++ " : " ++
347 showImp (Just ist) imp c (delabTy ist n)) ts
348 showImp (Just ist) imp c (delabTy ist n)) ts
348− iResult ""
349+ iPrintResult ""
349− [] -> iFail $ "No such variable " ++ show n
350+ [] -> iPrintError $ "No such variable " ++ show n
350process fn (Check t)
351process fn (Check t)
351 = do (tm, ty) <- elabVal toplevel False t
352 = do (tm, ty) <- elabVal toplevel False t
352 ctxt <- getContext
353 ctxt <- getContext
@@ -355,15 +356,15 @@ process fn (Check t)
355 c <- colourise
356 c <- colourise
356 let ty' = normaliseC ctxt [] ty
357 let ty' = normaliseC ctxt [] ty
357 case tm of
358 case tm of
358− TType _ -> iResult ("Type : Type 1")
359+ TType _ -> iPrintResult ("Type : Type 1")
359− _ -> iResult (showImp (Just ist) imp c (delab ist tm) ++ " : " ++
360+ _ -> iPrintResult (showImp (Just ist) imp c (delab ist tm) ++ " : " ++
360− showImp (Just ist) imp c (delab ist ty))
361+ showImp (Just ist) imp c (delab ist ty))
362process fn (DocStr n) = do i <- getIState
363process fn (DocStr n) = do i <- getIState
363 case lookupCtxtName n (idris_docstrings i) of
364 case lookupCtxtName n (idris_docstrings i) of
364− [] -> iFail $ "No documentation for " ++ show n
365+ [] -> iPrintError $ "No documentation for " ++ show n
365 ns -> do mapM_ showDoc ns
366 ns -> do mapM_ showDoc ns
366− iResult ""
367+ iPrintResult ""
367 where showDoc (n, d)
368 where showDoc (n, d)
368 = do doc <- getDocs n
369 = do doc <- getDocs n
369 iputStrLn $ show doc
370 iputStrLn $ show doc
@@ -374,8 +375,8 @@ process fn Universes = do i <- getIState
374 let n = length cs
375 let n = length cs
375 iputStrLn $ "(" ++ show n ++ " constraints)"
376 iputStrLn $ "(" ++ show n ++ " constraints)"
376 case ucheck cs of
377 case ucheck cs of
377− Error e -> iFail $ pshow i e
378+ Error e -> iPrintError $ pshow i e
378− OK _ -> iResult "Universes OK"
379+ OK _ -> iPrintResult "Universes OK"
379process fn (Defn n) = do i <- getIState
380process fn (Defn n) = do i <- getIState
380 iputStrLn "Compiled patterns:\n"
381 iputStrLn "Compiled patterns:\n"
381 iputStrLn $ show (lookupDef n (tt_ctxt i))
382 iputStrLn $ show (lookupDef n (tt_ctxt i))
@@ -392,8 +393,8 @@ process fn (Defn n) = do i <- getIState
392 showImp (Just i) True c (delab i rhs))
393 showImp (Just i) True c (delab i rhs))
393process fn (TotCheck n) = do i <- getIState
394process fn (TotCheck n) = do i <- getIState
394 case lookupTotal n (tt_ctxt i) of
395 case lookupTotal n (tt_ctxt i) of
395− [t] -> iResult (showTotal t i)
396+ [t] -> iPrintResult (showTotal t i)
396− _ -> do iFail ""
397+ _ -> do iPrintError ""
397 return ()
398 return ()
398process fn (DebugInfo n)
399process fn (DebugInfo n)
399 = do i <- getIState
400 = do i <- getIState
@@ -416,13 +417,13 @@ process fn (DebugInfo n)
416process fn (Info n) = do i <- getIState
417process fn (Info n) = do i <- getIState
417 case lookupCtxt n (idris_classes i) of
418 case lookupCtxt n (idris_classes i) of
418 [c] -> classInfo c
419 [c] -> classInfo c
419− _ -> iFail "Not a class"
420+ _ -> iPrintError "Not a class"
420−process fn (Search t) = iFail "Not implemented"
421+process fn (Search t) = iPrintError "Not implemented"
421process fn (Spec t) = do (tm, ty) <- elabVal toplevel False t
422process fn (Spec t) = do (tm, ty) <- elabVal toplevel False t
422 ctxt <- getContext
423 ctxt <- getContext
423 ist <- getIState
424 ist <- getIState
424 let tm' = simplify ctxt [] {- (idris_statics ist) -} tm
425 let tm' = simplify ctxt [] {- (idris_statics ist) -} tm
425− iResult (show (delab ist tm'))
426+ iPrintResult (show (delab ist tm'))
427process fn (RmProof n')
428process fn (RmProof n')
428 = do i <- getIState
429 = do i <- getIState
@@ -449,7 +450,7 @@ process fn' (AddProof prf)
449 then return fn'
450 then return fn'
450 else if exExt
451 else if exExt
451 then return fnExt
452 then return fnExt
452− else fail $ "Neither \""++fn'++"\" nor \""++fnExt++"\" exist"
453+ else ifail $ "Neither \""++fn'++"\" nor \""++fnExt++"\" exist"
453 let fb = fn ++ "~"
454 let fb = fn ++ "~"
454 liftIO $ copyFile fn fb -- make a backup in case something goes wrong!
455 liftIO $ copyFile fn fb -- make a backup in case something goes wrong!
455 prog <- liftIO $ readFile fb
456 prog <- liftIO $ readFile fb
@@ -457,7 +458,7 @@ process fn' (AddProof prf)
457 let proofs = proof_list i
458 let proofs = proof_list i
458 n' <- case prf of
459 n' <- case prf of
459 Nothing -> case proofs of
460 Nothing -> case proofs of
460− [] -> fail "No proof to add"
461+ [] -> ifail "No proof to add"
461 ((x, p) : _) -> return x
462 ((x, p) : _) -> return x
462 Just nm -> return nm
463 Just nm -> return nm
463 n <- resolveProof n'
464 n <- resolveProof n'
@@ -474,8 +475,8 @@ process fn (ShowProof n')
474 n <- resolveProof n'
475 n <- resolveProof n'
475 let proofs = proof_list i
476 let proofs = proof_list i
476 case lookup n proofs of
477 case lookup n proofs of
477− Nothing -> iFail "No proof to show"
478+ Nothing -> iPrintError "No proof to show"
478− Just p -> iResult $ showProof False n p
479+ Just p -> iPrintResult $ showProof False n p
480process fn (Prove n')
481process fn (Prove n')
481 = do ctxt <- getContext
482 = do ctxt <- getContext
@@ -483,7 +484,7 @@ process fn (Prove n')
483 n <- case lookupNames n' ctxt of
484 n <- case lookupNames n' ctxt of
484 [x] -> return x
485 [x] -> return x
485 [] -> return n'
486 [] -> return n'
486− ns -> fail $ pshow ist (CantResolveAlts (map show ns))
487+ ns -> ierror (CantResolveAlts (map show ns))
487 prover (lit fn) n
488 prover (lit fn) n
488 -- recheck totality
489 -- recheck totality
489 i <- getIState
490 i <- getIState
@@ -495,14 +496,14 @@ process fn (HNF t) = do (tm, ty) <- elabVal toplevel False t
495 ctxt <- getContext
496 ctxt <- getContext
496 ist <- getIState
497 ist <- getIState
497 let tm' = hnf ctxt [] tm
498 let tm' = hnf ctxt [] tm
498− iResult (show (delab ist tm'))
499+ iPrintResult (show (delab ist tm'))
499process fn (TestInline t) = do (tm, ty) <- elabVal toplevel False t
500process fn (TestInline t) = do (tm, ty) <- elabVal toplevel False t
500 ctxt <- getContext
501 ctxt <- getContext
501 ist <- getIState
502 ist <- getIState
502 let tm' = inlineTerm ist tm
503 let tm' = inlineTerm ist tm
503 imp <- impShow
504 imp <- impShow
504 c <- colourise
505 c <- colourise
505− iResult (showImp (Just ist) imp c (delab ist tm'))
506+ iPrintResult (showImp (Just ist) imp c (delab ist tm'))
506process fn TTShell = do ist <- getIState
507process fn TTShell = do ist <- getIState
507 let shst = initState (tt_ctxt ist)
508 let shst = initState (tt_ctxt ist)
508 runShell shst
509 runShell shst
@@ -529,7 +530,7 @@ process fn (LogLvl i) = setLogLevel i
529-- Elaborate as if LHS of a pattern (debug command)
530-- Elaborate as if LHS of a pattern (debug command)
530process fn (Pattelab t)
531process fn (Pattelab t)
531 = do (tm, ty) <- elabVal toplevel True t
532 = do (tm, ty) <- elabVal toplevel True t
532− iResult $ show tm ++ "\n\n : " ++ show ty
533+ iPrintResult $ show tm ++ "\n\n : " ++ show ty
534process fn (Missing n)
535process fn (Missing n)
535 = do i <- getIState
536 = do i <- getIState
@@ -537,13 +538,13 @@ process fn (Missing n)
537 case lookupCtxt n (idris_patdefs i) of
538 case lookupCtxt n (idris_patdefs i) of
538 [] -> return ()
539 [] -> return ()
539 [(_, tms)] ->
540 [(_, tms)] ->
540− iResult (showSep "\n" (map (showImp (Just i) True c) tms))
541+ iPrintResult (showSep "\n" (map (showImp (Just i) True c) tms))
541− _ -> iFail $ "Ambiguous name"
542+ _ -> iPrintError $ "Ambiguous name"
542process fn (DynamicLink l) = do i <- getIState
543process fn (DynamicLink l) = do i <- getIState
543 let lib = trim l
544 let lib = trim l
544− handle <- lift $ tryLoadLib lib
545+ handle <- lift . lift $ tryLoadLib lib
545 case handle of
546 case handle of
546− Nothing -> iFail $ "Could not load dynamic lib \"" ++ l ++ "\""
547+ Nothing -> iPrintError $ "Could not load dynamic lib \"" ++ l ++ "\""
547 Just x -> do let libs = idris_dynamic_libs i
548 Just x -> do let libs = idris_dynamic_libs i
548 if x `elem` libs
549 if x `elem` libs
549 then do iLOG ("Tried to load duplicate library " ++ lib_name x)
550 then do iLOG ("Tried to load duplicate library " ++ lib_name x)
@@ -559,8 +560,8 @@ process fn Metavars
559 = do ist <- getIState
560 = do ist <- getIState
560 let mvs = idris_metavars ist \\ primDefs
561 let mvs = idris_metavars ist \\ primDefs
561 case mvs of
562 case mvs of
562− [] -> iFail "No global metavariables to solve"
563+ [] -> iPrintError "No global metavariables to solve"
563− _ -> iResult $ "Global metavariables:\n\t" ++ show mvs
564+ _ -> iPrintResult $ "Global metavariables:\n\t" ++ show mvs
564process fn NOP = return ()
565process fn NOP = return ()
566process fn (SetOpt ErrContext) = setErrContext True
567process fn (SetOpt ErrContext) = setErrContext True
@@ -568,8 +569,8 @@ process fn (UnsetOpt ErrContext) = setErrContext False
568process fn (SetOpt ShowImpl) = setImpShow True
569process fn (SetOpt ShowImpl) = setImpShow True
569process fn (UnsetOpt ShowImpl) = setImpShow False
570process fn (UnsetOpt ShowImpl) = setImpShow False
571−process fn (SetOpt _) = iFail "Not a valid option"
572+process fn (SetOpt _) = iPrintError "Not a valid option"
572−process fn (UnsetOpt _) = iFail "Not a valid option"
573+process fn (UnsetOpt _) = iPrintError "Not a valid option"
573process fn (SetColour ty c) = setColour ty c
574process fn (SetColour ty c) = setColour ty c
574process fn ColourOn = do ist <- getIState
575process fn ColourOn = do ist <- getIState
575 putIState $ ist { idris_colourRepl = True }
576 putIState $ ist { idris_colourRepl = True }
@@ -583,7 +584,7 @@ classInfo ci = do iputStrLn "Methods:\n"
583 iputStrLn ""
584 iputStrLn ""
584 iputStrLn "Instances:\n"
585 iputStrLn "Instances:\n"
585 mapM_ dumpInstance (class_instances ci)
586 mapM_ dumpInstance (class_instances ci)
586− iResult ""
587+ iPrintResult ""
588dumpMethod :: (Name, (FnOpts, PTerm)) -> Idris ()
589dumpMethod :: (Name, (FnOpts, PTerm)) -> Idris ()
589dumpMethod (n, (_, t)) = iputStrLn $ show n ++ " : " ++ show t
590dumpMethod (n, (_, t)) = iputStrLn $ show n ++ " : " ++ show t
@@ -686,8 +687,12 @@ replSettings hFile = setComplete replCompletion $ defaultSettings {
688-- invoke as if from command line
689-- invoke as if from command line
689−idris :: [Opt] -> IO IState
690+idris :: [Opt] -> IO ()
690−idris opts = execStateT (idrisMain opts) idrisInit
691+idris opts = do res <- runErrorT $ execStateT (idrisMain opts) idrisInit
693+ Left err -> putStrLn $ pshow idrisInit err
694+ Right ist -> return ()
692loadInputs :: [FilePath] -> Idris ()
697loadInputs :: [FilePath] -> Idris ()
693loadInputs inputs
698loadInputs inputs
@@ -886,9 +891,9 @@ initScript = do script <- getInitScript
886 h <- liftIO $ openFile script ReadMode
891 h <- liftIO $ openFile script ReadMode
887 runInit h
892 runInit h
888 liftIO $ hClose h)
893 liftIO $ hClose h)
889− (\e -> iFail $ "Error reading init file: " ++ show e)
894+ (\e -> iPrintError $ "Error reading init file: " ++ show e)
890 where runInit :: Handle -> Idris ()
895 where runInit :: Handle -> Idris ()
891− runInit h = do eof <- lift (hIsEOF h)
896+ runInit h = do eof <- lift . lift $ hIsEOF h
892 ist <- getIState
897 ist <- getIState
893 unless eof $ do
898 unless eof $ do
894 line <- liftIO $ hGetLine h
899 line <- liftIO $ hGetLine h
@@ -899,12 +904,12 @@ initScript = do script <- getInitScript
899 processLine i cmd input clr =
904 processLine i cmd input clr =
900 case parseCmd i input cmd of
905 case parseCmd i input cmd of
901 Failure err -> liftIO $ print (fixColour clr err)
906 Failure err -> liftIO $ print (fixColour clr err)
902− Success Reload -> iFail "Init scripts cannot reload the file"
907+ Success Reload -> iPrintError "Init scripts cannot reload the file"
903− Success (Load f) -> iFail "Init scripts cannot load files"
908+ Success (Load f) -> iPrintError "Init scripts cannot load files"
904− Success (ModImport f) -> iFail "Init scripts cannot import modules"
909+ Success (ModImport f) -> iPrintError "Init scripts cannot import modules"
905− Success Edit -> iFail "Init scripts cannot invoke the editor"
910+ Success Edit -> iPrintError "Init scripts cannot invoke the editor"
906 Success Proofs -> proofs i
911 Success Proofs -> proofs i
907− Success Quit -> iFail "Init scripts cannot quit Idris"
912+ Success Quit -> iPrintError "Init scripts cannot quit Idris"
908 Success cmd -> process [] cmd
913 Success cmd -> process [] cmd
910getFile :: Opt -> Maybe String
915getFile :: Opt -> Maybe String