filestore-0.6.5: 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-Inferred
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
  - fromByteString :: ByteString -> a
  - toByteString :: a -> ByteString
- 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

Instances details

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

data Author Source #

Constructors

Author |

Fields

- authorName :: String
- authorEmail :: String

#### Instances

Instances details

Read Author Source # |
Instance details Defined in Data.FileStore.Types Methods readsPrec :: Int -> ReadS Author Source # readList :: ReadS [Author] Source # readPrec :: ReadPrec Author Source # readListPrec :: ReadPrec [Author] Source #
Show Author Source # |
Instance details Defined in Data.FileStore.Types Methods showsPrec :: Int -> Author -> ShowS Source # show :: Author -> String Source # showList :: [Author] -> ShowS Source #
Eq Author Source # |
Instance details Defined in Data.FileStore.Types Methods (==) :: Author -> Author -> Bool Source # (/=) :: Author -> Author -> Bool Source #

data Change Source #

Constructors

Added FilePath |
Deleted FilePath |
Modified FilePath |

#### Instances

Instances details

Read Change Source # |
Instance details Defined in Data.FileStore.Types Methods readsPrec :: Int -> ReadS Change Source # readList :: ReadS [Change] Source # readPrec :: ReadPrec Change Source # readListPrec :: ReadPrec [Change] Source #
Show Change Source # |
Instance details Defined in Data.FileStore.Types Methods showsPrec :: Int -> Change -> ShowS Source # show :: Change -> String Source # showList :: [Change] -> ShowS Source #
Eq Change Source # |
Instance details Defined in Data.FileStore.Types Methods (==) :: Change -> Change -> Bool Source # (/=) :: Change -> Change -> Bool Source #

type Description = String Source #

data Revision Source #

Constructors

Revision |

Fields

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

#### Instances

Instances details

Read Revision Source # |
Instance details Defined in Data.FileStore.Types Methods readsPrec :: Int -> ReadS Revision Source # readList :: ReadS [Revision] Source # readPrec :: ReadPrec Revision Source # readListPrec :: ReadPrec [Revision] Source #
Show Revision Source # |
Instance details Defined in Data.FileStore.Types Methods showsPrec :: Int -> Revision -> ShowS Source # show :: Revision -> String Source # showList :: [Revision] -> ShowS Source #
Eq Revision Source # |
Instance details Defined in Data.FileStore.Types Methods (==) :: Revision -> Revision -> Bool Source # (/=) :: Revision -> Revision -> Bool Source #

class Contents a where Source #

Methods

fromByteString :: ByteString -> a Source #

toByteString :: a -> ByteString Source #

#### Instances

Instances details

Contents ByteString Source # |
Instance details Defined in Data.FileStore.Types Methods fromByteString :: ByteString -> ByteString Source # toByteString :: ByteString -> ByteString Source #
Contents String Source # |
Instance details Defined in Data.FileStore.Types Methods fromByteString :: ByteString -> String Source # toByteString :: String -> 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

Instances details

Read TimeRange Source # |
Instance details Defined in Data.FileStore.Types Methods readsPrec :: Int -> ReadS TimeRange Source # readList :: ReadS [TimeRange] Source # readPrec :: ReadPrec TimeRange Source # readListPrec :: ReadPrec [TimeRange] Source #
Show TimeRange Source # |
Instance details Defined in Data.FileStore.Types Methods showsPrec :: Int -> TimeRange -> ShowS Source # show :: TimeRange -> String Source # showList :: [TimeRange] -> ShowS Source #
Eq TimeRange Source # |
Instance details Defined in Data.FileStore.Types Methods (==) :: TimeRange -> TimeRange -> Bool Source # (/=) :: TimeRange -> TimeRange -> Bool Source #

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

Instances details

Read MergeInfo Source # |
Instance details Defined in Data.FileStore.Types Methods readsPrec :: Int -> ReadS MergeInfo Source # readList :: ReadS [MergeInfo] Source # readPrec :: ReadPrec MergeInfo Source # readListPrec :: ReadPrec [MergeInfo] Source #
Show MergeInfo Source # |
Instance details Defined in Data.FileStore.Types Methods showsPrec :: Int -> MergeInfo -> ShowS Source # show :: MergeInfo -> String Source # showList :: [MergeInfo] -> ShowS Source #
Eq MergeInfo Source # |
Instance details Defined in Data.FileStore.Types Methods (==) :: MergeInfo -> MergeInfo -> Bool Source # (/=) :: MergeInfo -> MergeInfo -> Bool Source #

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

Instances details

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

data SearchMatch Source #

Constructors

SearchMatch |

Fields

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

#### Instances

Instances details

Read SearchMatch Source # |
Instance details Defined in Data.FileStore.Types Methods readsPrec :: Int -> ReadS SearchMatch Source # readList :: ReadS [SearchMatch] Source # readPrec :: ReadPrec SearchMatch Source # readListPrec :: ReadPrec [SearchMatch] Source #
Show SearchMatch Source # |
Instance details Defined in Data.FileStore.Types Methods showsPrec :: Int -> SearchMatch -> ShowS Source # show :: SearchMatch -> String Source # showList :: [SearchMatch] -> ShowS Source #
Eq SearchMatch Source # |
Instance details Defined in Data.FileStore.Types Methods (==) :: SearchMatch -> SearchMatch -> Bool Source # (/=) :: SearchMatch -> SearchMatch -> Bool Source #

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

Instances details

Read SearchQuery Source # |
Instance details Defined in Data.FileStore.Types Methods readsPrec :: Int -> ReadS SearchQuery Source # readList :: ReadS [SearchQuery] Source # readPrec :: ReadPrec SearchQuery Source # readListPrec :: ReadPrec [SearchQuery] Source #
Show SearchQuery Source # |
Instance details Defined in Data.FileStore.Types Methods showsPrec :: Int -> SearchQuery -> ShowS Source # show :: SearchQuery -> String Source # showList :: [SearchQuery] -> ShowS Source #
Eq SearchQuery Source # |
Instance details Defined in Data.FileStore.Types Methods (==) :: SearchQuery -> SearchQuery -> Bool Source # (/=) :: SearchQuery -> SearchQuery -> Bool Source #

defaultSearchQuery :: SearchQuery Source #

data UTCTime Source #

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

Instances details

Data UTCTime |

Instance details

Defined in Data.Time.Clock.Internal.UTCTime

Methods

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

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

toConstr :: UTCTime -> Constr Source #

dataTypeOf :: UTCTime -> DataType Source #

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

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

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

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

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

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

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

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

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

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

NFData UTCTime |
Instance details Defined in Data.Time.Clock.Internal.UTCTime Methods rnf :: UTCTime -> () Source #
Eq UTCTime |
Instance details Defined in Data.Time.Clock.Internal.UTCTime Methods (==) :: UTCTime -> UTCTime -> Bool Source # (/=) :: UTCTime -> UTCTime -> Bool Source #
Ord UTCTime |
Instance details Defined in Data.Time.Clock.Internal.UTCTime Methods compare :: UTCTime -> UTCTime -> Ordering Source # (<) :: UTCTime -> UTCTime -> Bool Source # (<=) :: UTCTime -> UTCTime -> Bool Source # (>) :: UTCTime -> UTCTime -> Bool Source # (>=) :: UTCTime -> UTCTime -> Bool Source # max :: UTCTime -> UTCTime -> UTCTime Source # min :: UTCTime -> UTCTime -> UTCTime Source #

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.