@@ -1029,11 +1029,12 @@ replSettings hFile = setComplete replCompletion $ defaultSettings {
10291029 }
10301030
10311031-- invoke as if from command line
1032−idris :: [Opt] -> IO ()
1032+idris :: [Opt] -> IO (Maybe IState)
10331033idris opts = do res <- runErrorT $ execStateT (idrisMain opts) idrisInit
10341034 case res of
1035− Left err -> putStrLn $ pshow idrisInit err
1036− Right ist -> return ()
1035+ Left err -> do putStrLn $ pshow idrisInit err
1036+ return Nothing
1037+ Right ist -> return (Just ist)
10371038
10381039
10391040loadInputs :: Handle -> [FilePath] -> Idris ()
@@ -1054,7 +1055,7 @@ loadInputs h inputs
10541055 -- so that they don't interfere with each other when checking
10551056
10561057 let ninputs = zip [1..] inputs
1057− ifiles <- mapM (\(num, input) ->
1058+ ifiles <- mapWhileOK (\(num, input) ->
10581059 do putIState ist
10591060 v <- verbose
10601061 -- when v $ iputStrLn $ "(" ++ show num ++ "/" ++
@@ -1080,7 +1081,7 @@ loadInputs h inputs
10801081 when (not loadCode) $ tryLoad $ nub (concat ifiles)
10811082 _ -> return ()
10821083 putIState inew)
1083− (\e -> case e of
1084+ (\e -> do case e of
10841085 At f _ -> do setErrLine (fc_line f)
10851086 iputStrLn (show e)
10861087 ProgramLineComment -> return () -- fail elsewhere
@@ -1090,14 +1091,20 @@ loadInputs h inputs
10901091 tryLoad :: [IFileType] -> Idris ()
10911092 tryLoad [] = return ()
10921093 tryLoad (f : fs) = do loadFromIFile h f
1093− inew <- getIState
1094− case errLine inew of
1095− Nothing -> tryLoad fs
1096− _ -> return () -- error, stop
1094+ ok <- noErrors
1095+ when ok $ tryLoad fs
10971096
10981097 ibc (IBC _ _) = True
10991098 ibc _ = False
11001099
1100+ -- Like mapM, but give up when there's an error
1101+ mapWhileOK f [] = return []
1102+ mapWhileOK f (x : xs) = do x' <- f x
1103+ ok <- noErrors
1104+ if ok then do xs' <- mapWhileOK f xs
1105+ return (x' : xs')
1106+ else return [x']
1107+
11011108idrisMain :: [Opt] -> Idris ()
11021109idrisMain opts =
11031110 do let inputs = opt getFile opts