haskey-mtl-0.2.0.0: A monad transformer supporting Haskey transactions.

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Haskey

Contents

Description

A monad transformer supporting Haskey transactions.

See https://github.com/haskell-haskey/haskey-mtl/blob/master/example/Main.hs for a complete example.

Synopsis

Re-exports

Monad

class Monad m => MonadHaskey root m | m -> root where Source #

A monad supporting database transactions.

The type root is the data type holding the roots of the database trees.

Minimal complete definition

transact, transact_, transactReadOnly

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> m a Source #

transact_ :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> m a Source #

Instances

(Monoid w, MonadHaskey root m) => MonadHaskey root (WriterT w m) Source # 

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> WriterT w m a Source #

transact_ :: (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> WriterT w m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> WriterT w m a Source #

(Monoid w, MonadHaskey root m) => MonadHaskey root (WriterT w m) Source # 

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> WriterT w m a Source #

transact_ :: (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> WriterT w m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> WriterT w m a Source #

MonadHaskey root m => MonadHaskey root (StateT s m) Source # 

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> StateT s m a Source #

transact_ :: (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> StateT s m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> StateT s m a Source #

MonadHaskey root m => MonadHaskey root (StateT s m) Source # 

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> StateT s m a Source #

transact_ :: (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> StateT s m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> StateT s m a Source #

(Root root, Applicative m, MonadMask m, MonadIO m) => MonadHaskey root (HaskeyT root m) Source # 

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> HaskeyT root m a Source #

transact_ :: (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> HaskeyT root m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> HaskeyT root m a Source #

MonadHaskey root m => MonadHaskey root (ReaderT * r m) Source # 

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> ReaderT * r m a Source #

transact_ :: (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> ReaderT * r m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> ReaderT * r m a Source #

(Monoid w, MonadHaskey root m) => MonadHaskey root (RWST r w s m) Source # 

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> RWST r w s m a Source #

transact_ :: (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> RWST r w s m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> RWST r w s m a Source #

(Monoid w, MonadHaskey root m) => MonadHaskey root (RWST r w s m) Source # 

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> RWST r w s m a Source #

transact_ :: (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> RWST r w s m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> RWST r w s m a Source #

data HaskeyT root m a Source #

A monad transformer that is an instance of MonadHaskey.

The root is the data type holding the roots of the database trees.

Instances

MonadRWS r w s m => MonadRWS r w s (HaskeyT root m) Source # 
MonadReader r m => MonadReader r (HaskeyT root m) Source # 

Methods

ask :: HaskeyT root m r #

local :: (r -> r) -> HaskeyT root m a -> HaskeyT root m a #

reader :: (r -> a) -> HaskeyT root m a #

MonadState s m => MonadState s (HaskeyT root m) Source # 

Methods

get :: HaskeyT root m s #

put :: s -> HaskeyT root m () #

state :: (s -> (a, s)) -> HaskeyT root m a #

MonadWriter w m => MonadWriter w (HaskeyT root m) Source # 

Methods

writer :: (a, w) -> HaskeyT root m a #

tell :: w -> HaskeyT root m () #

listen :: HaskeyT root m a -> HaskeyT root m (a, w) #

pass :: HaskeyT root m (a, w -> w) -> HaskeyT root m a #

(Root root, Applicative m, MonadMask m, MonadIO m) => MonadHaskey root (HaskeyT root m) Source # 

Methods

transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> HaskeyT root m a Source #

transact_ :: (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> HaskeyT root m () Source #

transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> HaskeyT root m a Source #

MonadTrans (HaskeyT root) Source # 

Methods

lift :: Monad m => m a -> HaskeyT root m a #

Monad m => Monad (HaskeyT root m) Source # 

Methods

(>>=) :: HaskeyT root m a -> (a -> HaskeyT root m b) -> HaskeyT root m b #

(>>) :: HaskeyT root m a -> HaskeyT root m b -> HaskeyT root m b #

return :: a -> HaskeyT root m a #

fail :: String -> HaskeyT root m a #

Functor m => Functor (HaskeyT root m) Source # 

Methods

fmap :: (a -> b) -> HaskeyT root m a -> HaskeyT root m b #

(<$) :: a -> HaskeyT root m b -> HaskeyT root m a #

Applicative m => Applicative (HaskeyT root m) Source # 

Methods

pure :: a -> HaskeyT root m a #

(<*>) :: HaskeyT root m (a -> b) -> HaskeyT root m a -> HaskeyT root m b #

(*>) :: HaskeyT root m a -> HaskeyT root m b -> HaskeyT root m b #

(<*) :: HaskeyT root m a -> HaskeyT root m b -> HaskeyT root m a #

MonadIO m => MonadIO (HaskeyT root m) Source # 

Methods

liftIO :: IO a -> HaskeyT root m a #

MonadThrow m => MonadThrow (HaskeyT root m) Source # 

Methods

throwM :: Exception e => e -> HaskeyT root m a #

MonadCatch m => MonadCatch (HaskeyT root m) Source # 

Methods

catch :: Exception e => HaskeyT root m a -> (e -> HaskeyT root m a) -> HaskeyT root m a #

MonadMask m => MonadMask (HaskeyT root m) Source # 

Methods

mask :: ((forall a. HaskeyT root m a -> HaskeyT root m a) -> HaskeyT root m b) -> HaskeyT root m b #

uninterruptibleMask :: ((forall a. HaskeyT root m a -> HaskeyT root m a) -> HaskeyT root m b) -> HaskeyT root m b #

runHaskeyT :: (Root root, MonadMask m, MonadIO m) => HaskeyT root m a -> ConcurrentDb root -> FileStoreConfig -> m a Source #

Run Haskey transactions, backed by a file store.

Open and create (re-exports)

data FileStoreT fp m a :: * -> (* -> *) -> * -> * #

Monad in which on-disk storage operations can take place.

Two important instances are StoreM making it a storage back-end, and ConcurrentMetaStoreM making it a storage back-end compatible with the concurrent page allocator.

Instances

(Applicative m, Monad m, MonadIO m, MonadThrow m) => StoreM FilePath (FileStoreT FilePath m) 
Monad m => MonadReader FileStoreConfig (FileStoreT fp m) 
Monad m => MonadState (Files fp) (FileStoreT fp m) 

Methods

get :: FileStoreT fp m (Files fp) #

put :: Files fp -> FileStoreT fp m () #

state :: (Files fp -> (a, Files fp)) -> FileStoreT fp m a #

Monad m => Monad (FileStoreT fp m) 

Methods

(>>=) :: FileStoreT fp m a -> (a -> FileStoreT fp m b) -> FileStoreT fp m b #

(>>) :: FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m b #

return :: a -> FileStoreT fp m a #

fail :: String -> FileStoreT fp m a #

Functor m => Functor (FileStoreT fp m) 

Methods

fmap :: (a -> b) -> FileStoreT fp m a -> FileStoreT fp m b #

(<$) :: a -> FileStoreT fp m b -> FileStoreT fp m a #

Monad m => Applicative (FileStoreT fp m) 

Methods

pure :: a -> FileStoreT fp m a #

(<*>) :: FileStoreT fp m (a -> b) -> FileStoreT fp m a -> FileStoreT fp m b #

(*>) :: FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m b #

(<*) :: FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m a #

MonadIO m => MonadIO (FileStoreT fp m) 

Methods

liftIO :: IO a -> FileStoreT fp m a #

MonadThrow m => MonadThrow (FileStoreT fp m) 

Methods

throwM :: Exception e => e -> FileStoreT fp m a #

MonadCatch m => MonadCatch (FileStoreT fp m) 

Methods

catch :: Exception e => FileStoreT fp m a -> (e -> FileStoreT fp m a) -> FileStoreT fp m a #

MonadMask m => MonadMask (FileStoreT fp m) 

Methods

mask :: ((forall a. FileStoreT fp m a -> FileStoreT fp m a) -> FileStoreT fp m b) -> FileStoreT fp m b #

uninterruptibleMask :: ((forall a. FileStoreT fp m a -> FileStoreT fp m a) -> FileStoreT fp m b) -> FileStoreT fp m b #

(Applicative m, Monad m, MonadIO m, MonadCatch m) => ConcurrentMetaStoreM (FileStoreT FilePath m) 

data FileStoreConfig :: * #

File store configuration.

The default configuration can be obtained by using defFileStoreConfig

A configuration with a specific page size can be obtained by using fileStoreConfigWithPageSize.

runFileStoreT #

Arguments

:: Monad m 
=> FileStoreT FilePath m a

Action

-> FileStoreConfig

Configuration

-> m a 

Run the storage operations in the FileStoreT monad, given a collection of open files.

defFileStoreConfig :: FileStoreConfig #

The default configuration

This is an unwrapped fileStoreConfigWithPageSize with a page size of 4096 bytes.

data ConcurrentDb root :: * -> * #

An active concurrent database.

This can be shared amongst threads.

concurrentHandles :: FilePath -> ConcurrentHandles #

Construct a set of ConcurrentHandles from a root directory.

openConcurrentDb :: (Root root, MonadIO m, MonadMask m, ConcurrentMetaStoreM m) => ConcurrentHandles -> m (Maybe (ConcurrentDb root)) #

Open the an existing database, with the given handles.

createConcurrentDb :: (Root root, MonadIO m, MonadMask m, ConcurrentMetaStoreM m) => ConcurrentHandles -> root -> m (ConcurrentDb root) #

Open a new concurrent database, with the given handles.