on master help sign in
Unnecessary style changes

I don't really know why I felt the need to do this, but I am happier now.

commit5a1c9ed3537156298413d6189c8c3189a02fe6c1 authorEvan Czaplicki <info@elm-lang.org> dateMon 4 Nov 2013, 13:28 (13 years ago) parentb1bca38
2 files changed+26−30
compiler/Compiler.hs+13−18 compiler/InterfaceSerialization.hs+13−12
compiler/Compiler.hs+13−18
@@ -97,26 +97,22 @@ elmi flags filePath = cachePath flags filePath "elmi"
9797buildFile :: Flags -> Int -> Int -> Interfaces -> FilePath -> IO (String, ModuleInterface)
9898buildFile flags moduleNum numModules interfaces filePath = do
9999 compiled <- alreadyCompiled
100− if compiled then do
100+ if not compiled then compile else do
101101 bytes <- IS.loadInterface (elmi flags filePath)
102− case bytes >>= IS.interfaceDecode (elmi flags filePath) >>=
103− IS.validVersion filePath of
104−
102+ let binary = IS.interfaceDecode (elmi flags filePath) =<< bytes
103+ case IS.validVersion filePath =<< binary of
105104 Left err -> do
106− hPutStrLn stderr err
107− exitFailure
105+ hPutStrLn stderr err
106+ exitFailure
108107
109108 Right (name, interface) -> do
110− when (print_types flags)
111− (printTypes interfaces
112− (iTypes interface)
113− (iAliases interface)
114− (iImports interface))
115−
116− return (name, interface)
109+ when (print_types flags) $
110+ printTypes interfaces
111+ (iTypes interface)
112+ (iAliases interface)
113+ (iImports interface)
117114
118− else
119− compile
115+ return (name, interface)
120116
121117 where
122118 alreadyCompiled :: IO Bool
@@ -212,9 +208,8 @@ build flags rootFile = do
212208 where
213209 appendToOutput :: BS.ByteString -> FilePath -> IO BS.ByteString
214210 appendToOutput js filePath =
215− do
216− src <- BS.readFile (elmo flags filePath)
217− return (BS.append src js)
211+ do src <- BS.readFile (elmo flags filePath)
212+ return (BS.append src js)
218213
219214 sources js = map Link (scripts flags) ++ [ Source js ]
220215
compiler/InterfaceSerialization.hs+13−12
@@ -23,26 +23,27 @@ loadInterface filePath = do
2323 return $ Right byteString
2424
2525 else
26− return $ Left $ "Unable to find file " ++ filePath ++
27− " for deserialization!"
26+ return $ Left $ "Unable to find file " ++ filePath ++
27+ " for deserialization!"
2828
29−interfaceDecode :: Binary.Binary a => FilePath -> L.ByteString ->
30− Either String a
29+interfaceDecode :: Binary.Binary a =>
30+ FilePath -> L.ByteString -> Either String a
3131interfaceDecode filePath bytes = do
3232 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−
4033 Right (_, _, binaryInfo) -> Right binaryInfo
4134
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+
4243validVersion :: FilePath -> (String, ModuleInterface) ->
4344 Either String (String, ModuleInterface)
4445validVersion filePath (name, interface) =
45− if (iVersion interface) == showVersion version then
46+ if iVersion interface == showVersion version then
4647 Right (name, interface)
4748 else
4849 Left $ "Found build artifacts created by a different " ++