Unnecessary style changes
I don't really know why I felt the need to do this, but I am happier now.
This commit is contained in:
parent
b1bca38488
commit
5a1c9ed353
2 changed files with 26 additions and 30 deletions
|
@ -97,26 +97,22 @@ elmi flags filePath = cachePath flags filePath "elmi"
|
|||
buildFile :: Flags -> Int -> Int -> Interfaces -> FilePath -> IO (String, ModuleInterface)
|
||||
buildFile flags moduleNum numModules interfaces filePath = do
|
||||
compiled <- alreadyCompiled
|
||||
if compiled then do
|
||||
if not compiled then compile else do
|
||||
bytes <- IS.loadInterface (elmi flags filePath)
|
||||
case bytes >>= IS.interfaceDecode (elmi flags filePath) >>=
|
||||
IS.validVersion filePath of
|
||||
|
||||
let binary = IS.interfaceDecode (elmi flags filePath) =<< bytes
|
||||
case IS.validVersion filePath =<< binary of
|
||||
Left err -> do
|
||||
hPutStrLn stderr err
|
||||
exitFailure
|
||||
hPutStrLn stderr err
|
||||
exitFailure
|
||||
|
||||
Right (name, interface) -> do
|
||||
when (print_types flags)
|
||||
(printTypes interfaces
|
||||
(iTypes interface)
|
||||
(iAliases interface)
|
||||
(iImports interface))
|
||||
when (print_types flags) $
|
||||
printTypes interfaces
|
||||
(iTypes interface)
|
||||
(iAliases interface)
|
||||
(iImports interface)
|
||||
|
||||
return (name, interface)
|
||||
|
||||
else
|
||||
compile
|
||||
return (name, interface)
|
||||
|
||||
where
|
||||
alreadyCompiled :: IO Bool
|
||||
|
@ -212,9 +208,8 @@ build flags rootFile = do
|
|||
where
|
||||
appendToOutput :: BS.ByteString -> FilePath -> IO BS.ByteString
|
||||
appendToOutput js filePath =
|
||||
do
|
||||
src <- BS.readFile (elmo flags filePath)
|
||||
return (BS.append src js)
|
||||
do src <- BS.readFile (elmo flags filePath)
|
||||
return (BS.append src js)
|
||||
|
||||
sources js = map Link (scripts flags) ++ [ Source js ]
|
||||
|
||||
|
|
|
@ -23,26 +23,27 @@ loadInterface filePath = do
|
|||
return $ Right byteString
|
||||
|
||||
else
|
||||
return $ Left $ "Unable to find file " ++ filePath ++
|
||||
" for deserialization!"
|
||||
return $ Left $ "Unable to find file " ++ filePath ++
|
||||
" for deserialization!"
|
||||
|
||||
interfaceDecode :: Binary.Binary a => FilePath -> L.ByteString ->
|
||||
Either String a
|
||||
interfaceDecode :: Binary.Binary a =>
|
||||
FilePath -> L.ByteString -> Either String a
|
||||
interfaceDecode filePath bytes = do
|
||||
case Binary.decodeOrFail bytes of
|
||||
Left (_, offset, err) -> do
|
||||
Left $ "Got an error, '" ++ err ++ "' at offset " ++
|
||||
show offset ++ " of " ++ filePath ++ ".\n\n" ++
|
||||
"This error may be due to an outdated or corrupt " ++
|
||||
"artifact from a previous build. Please rebuild " ++
|
||||
filePath ++ " and try again."
|
||||
|
||||
Right (_, _, binaryInfo) -> Right binaryInfo
|
||||
|
||||
Left (_, offset, err) ->
|
||||
Left $ concat [ "Got an error, '" ++ err ++ "' at offset "
|
||||
, show offset ++ " of " ++ filePath ++ ".\n\n"
|
||||
, "This error may be due to an outdated or corrupt "
|
||||
, "artifact from a previous build. Please rebuild "
|
||||
, filePath ++ " and try again."
|
||||
]
|
||||
|
||||
validVersion :: FilePath -> (String, ModuleInterface) ->
|
||||
Either String (String, ModuleInterface)
|
||||
validVersion filePath (name, interface) =
|
||||
if (iVersion interface) == showVersion version then
|
||||
if iVersion interface == showVersion version then
|
||||
Right (name, interface)
|
||||
else
|
||||
Left $ "Found build artifacts created by a different " ++
|
||||
|
|
Loading…
Reference in a new issue