@@ -1029,11 +1029,12 @@ replSettings hFile = setComplete replCompletion $ defaultSettings {
1031-- invoke as if from command line
1031-- invoke as if from command line
1032−idris :: [Opt] -> IO ()
1032+idris :: [Opt] -> IO (Maybe IState)
1033idris opts = do res <- runErrorT $ execStateT (idrisMain opts) idrisInit
1033idris opts = do res <- runErrorT $ execStateT (idrisMain opts) idrisInit
1034 case res of
1034 case res of
1035− Left err -> putStrLn $ pshow idrisInit err
1035+ Left err -> do putStrLn $ pshow idrisInit err
1036− Right ist -> return ()
1037+ Right ist -> return (Just ist)
1039loadInputs :: Handle -> [FilePath] -> Idris ()
1040loadInputs :: Handle -> [FilePath] -> Idris ()
@@ -1054,7 +1055,7 @@ loadInputs h inputs
1054 -- so that they don't interfere with each other when checking
1055 -- so that they don't interfere with each other when checking
1056 let ninputs = zip [1..] inputs
1057 let ninputs = zip [1..] inputs
1057− ifiles <- mapM (\(num, input) ->
1058+ ifiles <- mapWhileOK (\(num, input) ->
1058 do putIState ist
1059 do putIState ist
1059 v <- verbose
1060 v <- verbose
1060 -- when v $ iputStrLn $ "(" ++ show num ++ "/" ++
1061 -- when v $ iputStrLn $ "(" ++ show num ++ "/" ++
@@ -1080,7 +1081,7 @@ loadInputs h inputs
1080 when (not loadCode) $ tryLoad $ nub (concat ifiles)
1081 when (not loadCode) $ tryLoad $ nub (concat ifiles)
1081 _ -> return ()
1082 _ -> return ()
1082 putIState inew)
1083 putIState inew)
1083− (\e -> case e of
1084+ (\e -> do case e of
1084 At f _ -> do setErrLine (fc_line f)
1085 At f _ -> do setErrLine (fc_line f)
1085 iputStrLn (show e)
1086 iputStrLn (show e)
1086 ProgramLineComment -> return () -- fail elsewhere
1087 ProgramLineComment -> return () -- fail elsewhere
@@ -1090,14 +1091,20 @@ loadInputs h inputs
1090 tryLoad :: [IFileType] -> Idris ()
1091 tryLoad :: [IFileType] -> Idris ()
1091 tryLoad [] = return ()
1092 tryLoad [] = return ()
1092 tryLoad (f : fs) = do loadFromIFile h f
1093 tryLoad (f : fs) = do loadFromIFile h f
1093− inew <- getIState
1094+ ok <- noErrors
1094− case errLine inew of
1095− Nothing -> tryLoad fs
1095+ when ok $ tryLoad fs
1096− _ -> return () -- error, stop
1098 ibc (IBC _ _) = True
1097 ibc (IBC _ _) = True
1099 ibc _ = False
1098 ibc _ = False
1100+ -- Like mapM, but give up when there's an error
1101+ mapWhileOK f [] = return []
1102+ mapWhileOK f (x : xs) = do x' <- f x
1104+ if ok then do xs' <- mapWhileOK f xs
1101idrisMain :: [Opt] -> Idris ()
1108idrisMain :: [Opt] -> Idris ()
1102idrisMain opts =
1109idrisMain opts =
1103 do let inputs = opt getFile opts
1110 do let inputs = opt getFile opts