filestore-0.6.0.1: Interface for versioning file stores.

Portability | GHC 6.10 required
Stability | alpha
Maintainer | John MacFarlane <jgm@berkeley.edu>
Safe Haskell | None

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 :: Contents a => FilePath -> Author -> Description -> a -> IO ()
  - retrieve :: 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 |
Ord Resource |
Read Resource |
Show Resource |
Typeable Resource |

data Author Source

Constructors

Author |

Fields

authorName :: String
authorEmail :: String

Instances

Eq Author |
Read Author |
Show Author |
Typeable Author |

data Change Source

Constructors

Added FilePath |
Deleted FilePath |
Modified FilePath |

Instances

Eq Change |
Read Change |
Show Change |
Typeable Change |

type Description = String Source

data Revision Source

Constructors

Revision |

Fields

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

Instances

Eq Revision |
Read Revision |
Show Revision |
Typeable Revision |

class Contents a where Source

Methods

fromByteString :: ByteString -> aSource

toByteString :: a -> ByteString Source

Instances

Contents String |
Contents ByteString |

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 |
Read TimeRange |
Show TimeRange |
Typeable TimeRange |

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 |
Read MergeInfo |
Show MergeInfo |
Typeable MergeInfo |

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 |
Read FileStoreError |
Show FileStoreError |
Typeable FileStoreError |
Exception FileStoreError |

data SearchMatch Source

Constructors

SearchMatch |

Fields

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

Instances

Eq SearchMatch |
Read SearchMatch |
Show SearchMatch |
Typeable SearchMatch |

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 |
Read SearchQuery |
Show SearchQuery |
Typeable SearchQuery |

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 |
Data UTCTime |
Ord UTCTime |
Read UTCTime |
Show UTCTime |
Typeable UTCTime |
NFData UTCTime |
FormatTime UTCTime |
ParseTime 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 :: Contents a => FilePath -> Author -> Description -> a -> IO ()

  Save contents in the filestore.

retrieve :: 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.