git-annex/Types.hs

41 lines
944 B
Haskell
Raw Normal View History

2010-10-12 19:52:18 +00:00
{- git-annex core data types -}
module Types (
2010-10-12 20:06:10 +00:00
State(..),
Key(..),
Backend(..)
2010-10-12 19:52:18 +00:00
) where
2010-10-13 00:04:36 +00:00
import Data.String.Utils
2010-10-12 19:52:18 +00:00
import GitRepo
-- git-annex's runtime state
data State = State {
repo :: GitRepo,
backends :: [Backend]
2010-10-12 20:06:10 +00:00
} deriving (Show)
-- annexed filenames are mapped into keys
data Key = Key String deriving (Eq)
-- show a key to convert it to a string
instance Show Key where
show (Key v) = v
2010-10-12 20:06:10 +00:00
-- this structure represents a key/value backend
data Backend = Backend {
-- name of this backend
name :: String,
-- converts a filename to a key
getKey :: State -> FilePath -> IO (Maybe Key),
-- stores a file's contents to a key
storeFileKey :: State -> FilePath -> Key -> IO Bool,
-- retrieves a key's contents to a file
2010-10-12 20:10:15 +00:00
retrieveKeyFile :: State -> Key -> FilePath -> IO Bool,
2010-10-12 20:06:10 +00:00
-- removes a key
2010-10-12 20:10:15 +00:00
removeKey :: State -> Key -> IO Bool
2010-10-12 19:52:18 +00:00
}
2010-10-12 20:06:10 +00:00
instance Show Backend where
show backend = "Backend { name =\"" ++ (name backend) ++ "\" }"