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 [ "Got an error, '" ++ err ++ "' at offset "
37 , show offset ++ " of " ++ filePath ++ ".\n\n"
38 , "This error may be due to an outdated or corrupt "
39 , "artifact from a previous build. Please rebuild "
40 , filePath ++ " and try again."
43validVersion :: FilePath -> (String, ModuleInterface) ->
44 Either String (String, ModuleInterface)
45validVersion filePath (name, interface) =
46 if iVersion interface == showVersion version then
47 Right (name, interface)
49 Left $ "Found build artifacts created by a different " ++
50 "Elm compiler version. Please rebuild " ++
51 filePath ++ " and try again."
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