2module Build.Interface (load,isValid) where
4import qualified Data.ByteString.Lazy as L
5import qualified Data.Binary as Binary
7import qualified Build.Print as Print
8import qualified Elm.Compiler.Version as Compiler
9import System.Directory (doesFileExist)
10import AST.Module as Module
13load :: Binary.Binary a => FilePath -> IO a
15 do exists <- doesFileExist filePath
17 False -> Print.failure $ "Unable to find file " ++ filePath ++ " for deserialization!"
19 bytes <- L.readFile filePath
20 case Binary.decodeOrFail bytes of
21 Right (_, _, binaryInfo) -> return binaryInfo
22 Left (_, offset, err) -> Print.failure $ msg offset err
25 msg offset err = concat
26 [ "Error reading build artifact: ", filePath, "\n"
27 , " '", err, "' at offset ", show offset, "\n"
28 , " The file was generated by a previous build and may be outdated or corrupt.\n"
29 , " Please remove the file and try again."
33isValid :: FilePath -> (String, Module.Interface) -> Either String (String, Module.Interface)
34isValid filePath (name, interface) =
35 let version = iVersion interface in
36 if version == Compiler.version
37 then Right (name, interface)
39 [ "Error reading build artifact: ", filePath, "\n"
40 , " It was generated by version ", version, " of the compiler,\n"
41 , " but you are using version ", Compiler.version, "\n"
42 , " Please remove the file and try again.\n"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list