@@ -35,21 +35,21 @@ readInput inputFiles = forM inputFiles $ \inputFile -> do
35 text <- readFile inputFile
35 text <- readFile inputFile
36 return (inputFile, text)
36 return (inputFile, text)
38−loadPrelude :: Either String (String, String, P.Environment)
38+loadPrelude :: Either P.MultipleErrors (String, String, P.Environment)
39loadPrelude =
39loadPrelude =
40 case P.parseModulesFromFiles id [("", P.prelude)] of
40 case P.parseModulesFromFiles id [("", P.prelude)] of
41− Left parseError -> Left (show parseError)
41+ Left parseError -> Left . P.errorMessage . P.ErrorParsingPrelude $ parseError
42 Right ms -> runReaderT (P.compile (map snd ms) []) $ P.defaultCompileOptions { P.optionsAdditional = P.CompileOptions "Tests" [] [] }
42 Right ms -> runReaderT (P.compile (map snd ms) []) $ P.defaultCompileOptions { P.optionsAdditional = P.CompileOptions "Tests" [] [] }
44−compile :: P.Options P.Compile -> [FilePath] -> IO (Either String (String, String, P.Environment))
44+compile :: P.Options P.Compile -> [FilePath] -> IO (Either P.MultipleErrors (String, String, P.Environment))
45compile opts inputFiles = do
45compile opts inputFiles = do
46 modules <- P.parseModulesFromFiles id <$> readInput inputFiles
46 modules <- P.parseModulesFromFiles id <$> readInput inputFiles
47 case modules of
47 case modules of
48 Left parseError ->
48 Left parseError ->
49− return (Left $ show parseError)
49+ return . Left . P.errorMessage . P.ErrorParsingPrelude $ parseError
50 Right ms -> return $ runReaderT (P.compile (map snd ms) []) opts
50 Right ms -> return $ runReaderT (P.compile (map snd ms) []) opts
52−assert :: FilePath -> P.Options P.Compile -> FilePath -> (Either String (String, String, P.Environment) -> IO (Maybe String)) -> IO ()
52+assert :: FilePath -> P.Options P.Compile -> FilePath -> (Either P.MultipleErrors (String, String, P.Environment) -> IO (Maybe String)) -> IO ()
53assert preludeExterns opts inputFile f = do
53assert preludeExterns opts inputFile f = do
54 e <- compile opts [preludeExterns, inputFile]
54 e <- compile opts [preludeExterns, inputFile]
55 maybeErr <- f e
55 maybeErr <- f e
@@ -64,7 +64,7 @@ assertCompiles preludeJs preludeExterns inputFile = do
64 { P.optionsMain = Just "Main"
64 { P.optionsMain = Just "Main"
65 , P.optionsAdditional = P.CompileOptions "Tests" ["Main"] ["Main"]
65 , P.optionsAdditional = P.CompileOptions "Tests" ["Main"] ["Main"]
67− assert preludeExterns options inputFile $ either (return . Just) $ \(js, _, _) -> do
67+ assert preludeExterns options inputFile $ either (return . Just . P.prettyPrintMultipleErrors False) $ \(js, _, _) -> do
68 process <- findNodeProcess
68 process <- findNodeProcess
69 result <- traverse (\node -> readProcessWithExitCode node [] (preludeJs ++ js)) process
69 result <- traverse (\node -> readProcessWithExitCode node [] (preludeJs ++ js)) process
70 case result of
70 case result of
@@ -77,7 +77,7 @@ assertDoesNotCompile preludeExterns inputFile = do
77 putStrLn $ "Assert " ++ inputFile ++ " does not compile"
77 putStrLn $ "Assert " ++ inputFile ++ " does not compile"
78 assert preludeExterns (P.defaultCompileOptions { P.optionsAdditional = P.CompileOptions "Tests" [] [] }) inputFile $ \e ->
78 assert preludeExterns (P.defaultCompileOptions { P.optionsAdditional = P.CompileOptions "Tests" [] [] }) inputFile $ \e ->
80− Left err -> putStrLn err >> return Nothing
80+ Left errs -> putStrLn (P.prettyPrintMultipleErrors False errs) >> return Nothing
81 Right _ -> return $ Just "Should not have compiled"
81 Right _ -> return $ Just "Should not have compiled"
83findNodeProcess :: IO (Maybe String)
83findNodeProcess :: IO (Maybe String)
@@ -88,7 +88,7 @@ main :: IO ()
89 putStrLn "Compiling Prelude"
89 putStrLn "Compiling Prelude"
90 case loadPrelude of
90 case loadPrelude of
91− Left err -> putStrLn err >> exitFailure
91+ Left errs -> putStrLn (P.prettyPrintMultipleErrors False errs) >> exitFailure
92 Right (preludeJs, exts, _) -> do
92 Right (preludeJs, exts, _) -> do
93 tmp <- getTemporaryDirectory
93 tmp <- getTemporaryDirectory
94 let preludeExterns = tmp ++ pathSeparator : "prelude.externs"
94 let preludeExterns = tmp ++ pathSeparator : "prelude.externs"