2{-# LANGUAGE FlexibleContexts #-}
3module Build.Artifact (read) where
5import Prelude hiding (read)
6import Control.Monad.Error (MonadError, throwError, MonadIO, liftIO)
7import qualified Data.ByteString.Lazy as LBS
8import qualified Data.Binary as Binary
9import System.Directory (doesFileExist)
12read :: (MonadIO m, MonadError String m, Binary.Binary a) => FilePath -> m a
14 do exists <- liftIO (doesFileExist filePath)
15 if exists then decode else throwError notFound
18 do bytes <- liftIO (LBS.readFile filePath)
19 case Binary.decodeOrFail bytes of
20 Right (_, _, binaryInfo) -> return binaryInfo
21 Left (_, _, _) -> throwError corrupted
25 [ "Error reading build artifact ", filePath, "\n"
26 , " The file was generated by a previous build and may be outdated or corrupt.\n"
27 , " Please remove the file and try again."
31 "Unable to find file " ++ filePath ++ " for deserialization!"
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