on master help sign in
Unnecessary style changes
5a1c9edEvan Czaplicki
compiler/Compiler.hs+13−18
@@ -97,26 +97,22 @@ elmi flags filePath = cachePath flags filePath "elmi"
97buildFile :: Flags -> Int -> Int -> Interfaces -> FilePath -> IO (String, ModuleInterface)
97buildFile :: Flags -> Int -> Int -> Interfaces -> FilePath -> IO (String, ModuleInterface)
98buildFile flags moduleNum numModules interfaces filePath = do
98buildFile flags moduleNum numModules interfaces filePath = do
99 compiled <- alreadyCompiled
99 compiled <- alreadyCompiled
100− if compiled then do
100+ if not compiled then compile else do
101 bytes <- IS.loadInterface (elmi flags filePath)
101 bytes <- IS.loadInterface (elmi flags filePath)
102− case bytes >>= IS.interfaceDecode (elmi flags filePath) >>=
102+ let binary = IS.interfaceDecode (elmi flags filePath) =<< bytes
103− IS.validVersion filePath of
103+ case IS.validVersion filePath =<< binary of
104−
105 Left err -> do
104 Left err -> do
106− hPutStrLn stderr err
105+ hPutStrLn stderr err
107− exitFailure
106+ exitFailure
108
107
109 Right (name, interface) -> do
108 Right (name, interface) -> do
110− when (print_types flags)
109+ when (print_types flags) $
111− (printTypes interfaces
110+ printTypes interfaces
112− (iTypes interface)
111+ (iTypes interface)
113− (iAliases interface)
112+ (iAliases interface)
114− (iImports interface))
113+ (iImports interface)
115−
116− return (name, interface)
117
114
118− else
115+ return (name, interface)
119− compile
120
116
121 where
117 where
122 alreadyCompiled :: IO Bool
118 alreadyCompiled :: IO Bool
@@ -212,9 +208,8 @@ build flags rootFile = do
212 where
208 where
213 appendToOutput :: BS.ByteString -> FilePath -> IO BS.ByteString
209 appendToOutput :: BS.ByteString -> FilePath -> IO BS.ByteString
214 appendToOutput js filePath =
210 appendToOutput js filePath =
215− do
216− src <- BS.readFile (elmo flags filePath)
211+ do src <- BS.readFile (elmo flags filePath)
217− return (BS.append src js)
212+ return (BS.append src js)
218
213
219 sources js = map Link (scripts flags) ++ [ Source js ]
214 sources js = map Link (scripts flags) ++ [ Source js ]
220
215
compiler/InterfaceSerialization.hs+13−12
@@ -23,26 +23,27 @@ loadInterface filePath = do
23 return $ Right byteString
23 return $ Right byteString
24
24
25 else
25 else
26− return $ Left $ "Unable to find file " ++ filePath ++
26+ return $ Left $ "Unable to find file " ++ filePath ++
27− " for deserialization!"
27+ " for deserialization!"
28
28
29−interfaceDecode :: Binary.Binary a => FilePath -> L.ByteString ->
29+interfaceDecode :: Binary.Binary a =>
30− Either String a
30+ FilePath -> L.ByteString -> Either String a
31interfaceDecode filePath bytes = do
31interfaceDecode filePath bytes = do
32 case Binary.decodeOrFail bytes of
32 case Binary.decodeOrFail bytes of
33− Left (_, offset, err) -> do
34− Left $ "Got an error, '" ++ err ++ "' at offset " ++
35− show offset ++ " of " ++ filePath ++ ".\n\n" ++
36− "This error may be due to an outdated or corrupt " ++
37− "artifact from a previous build. Please rebuild " ++
38− filePath ++ " and try again."
39−
40 Right (_, _, binaryInfo) -> Right binaryInfo
33 Right (_, _, binaryInfo) -> Right binaryInfo
41
34
35+ Left (_, offset, err) ->
36+ Left $ concat [ "Got an error, '" ++ err ++ "' at offset "
37+ , show offset ++ " of " ++ filePath ++ ".\n\n"
38+ , "This error may be due to an outdated or corrupt "
39+ , "artifact from a previous build. Please rebuild "
40+ , filePath ++ " and try again."
41+ ]
42+
42validVersion :: FilePath -> (String, ModuleInterface) ->
43validVersion :: FilePath -> (String, ModuleInterface) ->
43 Either String (String, ModuleInterface)
44 Either String (String, ModuleInterface)
44validVersion filePath (name, interface) =
45validVersion filePath (name, interface) =
45− if (iVersion interface) == showVersion version then
46+ if iVersion interface == showVersion version then
46 Right (name, interface)
47 Right (name, interface)
47 else
48 else
48 Left $ "Found build artifacts created by a different " ++
49 Left $ "Found build artifacts created by a different " ++