1module InterfaceSerialization ( loadInterface
6import qualified Data.ByteString.Lazy as L
7import qualified Data.Binary as Binary
9import Paths_Elm (version)
10import Data.Version (showVersion)
11import System.Directory (doesFileExist)
12import System.IO (hPutStrLn, stderr)
13import System.Exit (exitFailure)
15import SourceSyntax.Module
17loadInterface :: FilePath -> IO (Either String L.ByteString)
18loadInterface filePath = do
19 exists <- doesFileExist filePath
22 byteString <- L.readFile filePath
23 return $ Right byteString
26 return $ Left $ "Unable to find file " ++ filePath ++
27 " for deserialization!"
29interfaceDecode :: Binary.Binary a =>
30 FilePath -> L.ByteString -> Either String a
31interfaceDecode filePath bytes = do
32 case Binary.decodeOrFail bytes of
33 Right (_, _, binaryInfo) -> Right binaryInfo
35 Left (_, offset, err) ->
36 Left $ concat [ "Error reading build artifact: ", filePath, "\n"
37 , " The exact error was '", err, "' at offset ", show offset, ".\n"
38 , " The file was generated by a previous build and may be outdated or corrupt.\n"
39 , " Please remove the file and try again."
42validVersion :: FilePath -> (String, ModuleInterface) ->
43 Either String (String, ModuleInterface)
44validVersion filePath (name, interface) =
45 if iVersion interface == showVersion version then
46 Right (name, interface)
49 [ "Error reading build artifact: ", filePath, "\n"
50 , " It was generated by a different version of the compiler: ", iVersion interface, "\n"
51 , " 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