-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
|
||
module RON.Storage (Collection (..), DocId (..), MonadStorage (..)) where | ||
|
||
import RON.Data (Replicated) | ||
import RON.Event (Clock) | ||
import RON.Types (UUID) | ||
|
||
type Version = UUID | ||
|
||
newtype DocId doc = DocId UUID | ||
|
||
type CollectionName = FilePath | ||
|
||
class Replicated doc => Collection doc where | ||
collectionName :: CollectionName | ||
|
||
class Clock m => MonadStorage m where | ||
listCollections :: m [CollectionName] | ||
|
||
-- | Must return @[]@ for non-existent collection | ||
listDocuments :: Collection doc => m [DocId doc] | ||
|
||
-- | Must return @[]@ for non-existent document | ||
listVersions :: Collection doc => DocId doc -> m [Version] | ||
|
||
-- | Must create collection and document if not exist | ||
createVersion :: Collection doc => DocId doc -> Version -> doc -> m () | ||
|
||
readVersion | ||
:: Collection doc => DocId doc -> Version -> m (Either String doc) | ||
|
||
deleteVersion :: Collection doc => DocId doc -> Version -> m () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
name: ron-storage-fs | ||
version: 0 | ||
|
||
build-type: Simple | ||
cabal-version: >= 1.2 | ||
|
||
library | ||
build-depends: | ||
-- global | ||
base | ||
-- organization | ||
, ron | ||
exposed-modules: | ||
RON.Storage |