Skip to content

Commit

Permalink
Add RON.Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
cblp committed Sep 19, 2018
1 parent a554022 commit 1740a30
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
33 changes: 33 additions & 0 deletions ron-storage-fs/RON/Storage.hs
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 ()
12 changes: 12 additions & 0 deletions ron-storage-fs/ron-storage-fs.cabal
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

0 comments on commit 1740a30

Please sign in to comment.