2module InterfaceSerialization ( loadInterface
7import qualified Data.ByteString.Lazy as L
8import qualified Data.Binary as Binary
10import qualified Elm.Internal.Version as Version
11import System.Directory (doesFileExist)
13import SourceSyntax.Module
15loadInterface :: FilePath -> IO (Either String L.ByteString)
16loadInterface filePath = do
17 exists <- doesFileExist filePath
20 byteString <- L.readFile filePath
21 return $ Right byteString
24 return $ Left $ "Unable to find file " ++ filePath ++
25 " for deserialization!"
27interfaceDecode :: Binary.Binary a =>
28 FilePath -> L.ByteString -> Either String a
29interfaceDecode filePath bytes = do
30 case Binary.decodeOrFail bytes of
31 Right (_, _, binaryInfo) -> Right binaryInfo
33 Left (_, offset, err) ->
34 Left $ concat [ "Error reading build artifact: ", filePath, "\n"
35 , " The exact error was '", err, "' at offset ", show offset, ".\n"
36 , " The file was generated by a previous build and may be outdated or corrupt.\n"
37 , " Please remove the file and try again."
40validVersion :: FilePath -> (String, ModuleInterface) ->
41 Either String (String, ModuleInterface)
42validVersion filePath (name, interface) =
43 if iVersion interface == Version.elmVersion then
44 Right (name, interface)
47 [ "Error reading build artifact: ", filePath, "\n"
48 , " It was generated by a different version of the compiler: "
49 , show (iVersion interface), "\n"
50 , " 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