filestore-0.6.3.1: Interface for versioning file stores.

Copyright | Copyright (C) 2009 John MacFarlane
License | BSD 3
Maintainer | John MacFarlane <jgm@berkeley.edu>
Stability | alpha
Portability | GHC 6.10 required
Safe Haskell | Safe
Language | Haskell98

Data.FileStore.Types

Description

Type definitions for Data.FileStore.

Synopsis

- type RevisionId = String
- data Resource
  - = FSFile FilePath
  - | FSDirectory FilePath
- data Author = Author {
  - authorName :: String
  - authorEmail :: String
  }
- data Change
  - = Added FilePath
  - | Deleted FilePath
  - | Modified FilePath
- type Description = String
- data Revision = Revision {
  - revId :: RevisionId
  - revDateTime :: UTCTime
  - revAuthor :: Author
  - revDescription :: Description
  - revChanges :: [Change]
  }
- class Contents a where
- data TimeRange = TimeRange {
  - timeFrom :: Maybe UTCTime
  - timeTo :: Maybe UTCTime
  }
- data MergeInfo = MergeInfo {
  - mergeRevision :: Revision
  - mergeConflicts :: Bool
  - mergeText :: String
  }
- data FileStoreError
  - = RepositoryExists
  - | ResourceExists
  - | NotFound
  - | IllegalResourceName
  - | Unchanged
  - | UnsupportedOperation
  - | NoMaxCount
  - | UnknownError String
- data SearchMatch = SearchMatch {
  - matchResourceName :: FilePath
  - matchLineNumber :: Integer
  - matchLine :: String
  }
- data SearchQuery = SearchQuery {
  - queryPatterns :: [String]
  - queryWholeWords :: Bool
  - queryMatchAll :: Bool
  - queryIgnoreCase :: Bool
  }
- defaultSearchQuery :: SearchQuery
- data UTCTime :: *
- data FileStore = FileStore {
  - initialize :: IO ()
  - save :: forall a. Contents a => FilePath -> Author -> Description -> a -> IO ()
  - retrieve :: forall a. Contents a => FilePath -> Maybe RevisionId -> IO a
  - delete :: FilePath -> Author -> Description -> IO ()
  - rename :: FilePath -> FilePath -> Author -> Description -> IO ()
  - history :: [FilePath] -> TimeRange -> Maybe Int -> IO [Revision]
  - latest :: FilePath -> IO RevisionId
  - revision :: RevisionId -> IO Revision
  - index :: IO [FilePath]
  - directory :: FilePath -> IO [Resource]
  - idsMatch :: RevisionId -> RevisionId -> Bool
  - search :: SearchQuery -> IO [SearchMatch]
  }

# Documentation

type RevisionId = String Source #

data Resource Source #

Constructors

FSFile FilePath |
FSDirectory FilePath |

Instances

Eq Resource Source # |
Methods (==) :: Resource -> Resource -> Bool # (/=) :: Resource -> Resource -> Bool #
Ord Resource Source # |
Methods compare :: Resource -> Resource -> Ordering # (<) :: Resource -> Resource -> Bool # (<=) :: Resource -> Resource -> Bool # (>) :: Resource -> Resource -> Bool # (>=) :: Resource -> Resource -> Bool # max :: Resource -> Resource -> Resource # min :: Resource -> Resource -> Resource #
Read Resource Source # |
Methods readsPrec :: Int -> ReadS Resource # readList :: ReadS [Resource] # readPrec :: ReadPrec Resource # readListPrec :: ReadPrec [Resource] #
Show Resource Source # |
Methods showsPrec :: Int -> Resource -> ShowS # show :: Resource -> String # showList :: [Resource] -> ShowS #

data Author Source #

Constructors

Author |

Fields

- authorName :: String
- authorEmail :: String

Instances

Eq Author Source # |
Methods (==) :: Author -> Author -> Bool # (/=) :: Author -> Author -> Bool #
Read Author Source # |
Methods readsPrec :: Int -> ReadS Author # readList :: ReadS [Author] # readPrec :: ReadPrec Author # readListPrec :: ReadPrec [Author] #
Show Author Source # |
Methods showsPrec :: Int -> Author -> ShowS # show :: Author -> String # showList :: [Author] -> ShowS #

data Change Source #

Constructors

Added FilePath |
Deleted FilePath |
Modified FilePath |

Instances

Eq Change Source # |
Methods (==) :: Change -> Change -> Bool # (/=) :: Change -> Change -> Bool #
Read Change Source # |
Methods readsPrec :: Int -> ReadS Change # readList :: ReadS [Change] # readPrec :: ReadPrec Change # readListPrec :: ReadPrec [Change] #
Show Change Source # |
Methods showsPrec :: Int -> Change -> ShowS # show :: Change -> String # showList :: [Change] -> ShowS #

type Description = String Source #

data Revision Source #

Constructors

Revision |

Fields

- revId :: RevisionId
- revDateTime :: UTCTime
- revAuthor :: Author
- revDescription :: Description
- revChanges :: [Change]

Instances

Eq Revision Source # |
Methods (==) :: Revision -> Revision -> Bool # (/=) :: Revision -> Revision -> Bool #
Read Revision Source # |
Methods readsPrec :: Int -> ReadS Revision # readList :: ReadS [Revision] # readPrec :: ReadPrec Revision # readListPrec :: ReadPrec [Revision] #
Show Revision Source # |
Methods showsPrec :: Int -> Revision -> ShowS # show :: Revision -> String # showList :: [Revision] -> ShowS #

class Contents a where Source #

Minimal complete definition

fromByteString, toByteString

Methods

fromByteString :: ByteString -> a Source #

toByteString :: a -> ByteString Source #

Instances

Contents String Source # |
Methods fromByteString :: ByteString -> String Source # toByteString :: String -> ByteString Source #
Contents ByteString Source # |
Methods fromByteString :: ByteString -> ByteString Source # toByteString :: ByteString -> ByteString Source #

data TimeRange Source #

Constructors

TimeRange |

Fields

- timeFrom :: Maybe UTCTime

  `Nothing` means no lower bound

- timeTo :: Maybe UTCTime

  `Nothing` means no upper bound

Instances

Eq TimeRange Source # |
Methods (==) :: TimeRange -> TimeRange -> Bool # (/=) :: TimeRange -> TimeRange -> Bool #
Read TimeRange Source # |
Methods readsPrec :: Int -> ReadS TimeRange # readList :: ReadS [TimeRange] # readPrec :: ReadPrec TimeRange # readListPrec :: ReadPrec [TimeRange] #
Show TimeRange Source # |
Methods showsPrec :: Int -> TimeRange -> ShowS # show :: TimeRange -> String # showList :: [TimeRange] -> ShowS #

data MergeInfo Source #

Constructors

MergeInfo |

Fields

- mergeRevision :: Revision

  The revision w/ which changes were merged

- mergeConflicts :: Bool

  `True` if there were merge conflicts

- mergeText :: String

  The merged text, w/ conflict markers

Instances

Eq MergeInfo Source # |
Methods (==) :: MergeInfo -> MergeInfo -> Bool # (/=) :: MergeInfo -> MergeInfo -> Bool #
Read MergeInfo Source # |
Methods readsPrec :: Int -> ReadS MergeInfo # readList :: ReadS [MergeInfo] # readPrec :: ReadPrec MergeInfo # readListPrec :: ReadPrec [MergeInfo] #
Show MergeInfo Source # |
Methods showsPrec :: Int -> MergeInfo -> ShowS # show :: MergeInfo -> String # showList :: [MergeInfo] -> ShowS #

data FileStoreError Source #

Constructors

RepositoryExists | Tried to initialize a repo that exists
ResourceExists | Tried to create a resource that exists
NotFound | Requested resource was not found
IllegalResourceName | The specified resource name is illegal
Unchanged | The resource was not modified, because the contents were unchanged
UnsupportedOperation |
NoMaxCount | The darcs version used does not support --max-count
UnknownError String |

Instances

Eq FileStoreError Source # |
Methods (==) :: FileStoreError -> FileStoreError -> Bool # (/=) :: FileStoreError -> FileStoreError -> Bool #
Read FileStoreError Source # |
Methods readsPrec :: Int -> ReadS FileStoreError # readList :: ReadS [FileStoreError] # readPrec :: ReadPrec FileStoreError # readListPrec :: ReadPrec [FileStoreError] #
Show FileStoreError Source # |
Methods showsPrec :: Int -> FileStoreError -> ShowS # show :: FileStoreError -> String # showList :: [FileStoreError] -> ShowS #
Exception FileStoreError Source # |
Methods toException :: FileStoreError -> SomeException # fromException :: SomeException -> Maybe FileStoreError # displayException :: FileStoreError -> String #

data SearchMatch Source #

Constructors

SearchMatch |

Fields

- matchResourceName :: FilePath
- matchLineNumber :: Integer
- matchLine :: String

Instances

Eq SearchMatch Source # |
Methods (==) :: SearchMatch -> SearchMatch -> Bool # (/=) :: SearchMatch -> SearchMatch -> Bool #
Read SearchMatch Source # |
Methods readsPrec :: Int -> ReadS SearchMatch # readList :: ReadS [SearchMatch] # readPrec :: ReadPrec SearchMatch # readListPrec :: ReadPrec [SearchMatch] #
Show SearchMatch Source # |
Methods showsPrec :: Int -> SearchMatch -> ShowS # show :: SearchMatch -> String # showList :: [SearchMatch] -> ShowS #

data SearchQuery Source #

Constructors

SearchQuery |

Fields

- queryPatterns :: [String]

  Patterns to match

- queryWholeWords :: Bool

  Match patterns only with whole words?

- queryMatchAll :: Bool

  Return matches only from files in which all patterns match?

- queryIgnoreCase :: Bool

  Make matches case-insensitive?

Instances

Eq SearchQuery Source # |
Methods (==) :: SearchQuery -> SearchQuery -> Bool # (/=) :: SearchQuery -> SearchQuery -> Bool #
Read SearchQuery Source # |
Methods readsPrec :: Int -> ReadS SearchQuery # readList :: ReadS [SearchQuery] # readPrec :: ReadPrec SearchQuery # readListPrec :: ReadPrec [SearchQuery] #
Show SearchQuery Source # |
Methods showsPrec :: Int -> SearchQuery -> ShowS # show :: SearchQuery -> String # showList :: [SearchQuery] -> ShowS #

defaultSearchQuery :: SearchQuery Source #

data UTCTime :: * #

This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.

Instances

Eq UTCTime |
Methods (==) :: UTCTime -> UTCTime -> Bool # (/=) :: UTCTime -> UTCTime -> Bool #
Data UTCTime |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UTCTime -> c UTCTime #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UTCTime #

toConstr :: UTCTime -> Constr #

dataTypeOf :: UTCTime -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c UTCTime) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UTCTime) #

gmapT :: (forall b. Data b => b -> b) -> UTCTime -> UTCTime #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r #

gmapQ :: (forall d. Data d => d -> u) -> UTCTime -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> UTCTime -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime #

Ord UTCTime |
Methods compare :: UTCTime -> UTCTime -> Ordering # (<) :: UTCTime -> UTCTime -> Bool # (<=) :: UTCTime -> UTCTime -> Bool # (>) :: UTCTime -> UTCTime -> Bool # (>=) :: UTCTime -> UTCTime -> Bool # max :: UTCTime -> UTCTime -> UTCTime # min :: UTCTime -> UTCTime -> UTCTime #
NFData UTCTime |
Methods rnf :: UTCTime -> () #
FormatTime UTCTime |
Methods formatCharacter :: Char -> Maybe (TimeLocale -> Maybe NumericPadOption -> UTCTime -> String) #
ParseTime UTCTime |
Methods buildTime :: TimeLocale -> [(Char, String)] -> Maybe UTCTime #

data FileStore Source #

A versioning filestore, which can be implemented using the file system, a database, or revision-control software.

Constructors

FileStore |

Fields

- initialize :: IO ()

  Initialize a new filestore.

- save :: forall a. Contents a => FilePath -> Author -> Description -> a -> IO ()

  Save contents in the filestore.

- retrieve :: forall a. Contents a => FilePath -> Maybe RevisionId -> IO a

  Retrieve the contents of the named resource.

- delete :: FilePath -> Author -> Description -> IO ()

  Delete a named resource, providing author and log message.

- rename :: FilePath -> FilePath -> Author -> Description -> IO ()

  Rename a resource, providing author and log message.

- history :: [FilePath] -> TimeRange -> Maybe Int -> IO [Revision]

  Get history for a list of named resources in a (possibly openended) time range. If the list is empty, history for all resources will be returned. If the TimeRange is 2 Nothings, history for all dates will be returned.

- latest :: FilePath -> IO RevisionId

  Return the revision ID of the latest change for a resource. Raises `NotFound` if the resource is not found.

- revision :: RevisionId -> IO Revision

  Return information about a revision, given the ID. Raises `NotFound` if there is no such revision.

- index :: IO [FilePath]

  Return a list of resources in the filestore.

- directory :: FilePath -> IO [Resource]

  Return a list of resources in a directory of the filestore.

- idsMatch :: RevisionId -> RevisionId -> Bool

  `True` if the revision IDs match, in the sense that the can be treated as specifying the same revision.

- search :: SearchQuery -> IO [SearchMatch]

  Search the filestore for patterns.