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.Internal.Version as Version
9import System.Directory (doesFileExist)
10import AST.Module as Module
12load :: Binary.Binary a => FilePath -> IO a
14 do exists <- doesFileExist filePath
16 False -> Print.failure $ "Unable to find file " ++ filePath ++ " for deserialization!"
18 bytes <- L.readFile filePath
19 case Binary.decodeOrFail bytes of
20 Right (_, _, binaryInfo) -> return binaryInfo
21 Left (_, offset, err) -> Print.failure $ msg offset err
24 msg offset err = concat
25 [ "Error reading build artifact: ", filePath, "\n"
26 , " '", err, "' at offset ", show offset, "\n"
27 , " The file was generated by a previous build and may be outdated or corrupt.\n"
28 , " Please remove the file and try again."
31isValid :: FilePath -> (String, Module.Interface) -> Either String (String, Module.Interface)
32isValid filePath (name, interface) =
33 let version = iVersion interface in
34 if version == Version.elmVersion
35 then Right (name, interface)
37 [ "Error reading build artifact: ", filePath, "\n"
38 , " It was generated by version ", show version, " of the compiler,\n"
39 , " but you are using version ", show Version.elmVersion, "\n"
40 , " 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