| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Monad.Haskey
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
- module Database.Haskey.Alloc.Transaction
- class Monad m => MonadHaskey root m | m -> root where
- data HaskeyT root m a
- runHaskeyT :: (Root root, MonadMask m, MonadIO m) => HaskeyT root m a -> ConcurrentDb root -> FileStoreConfig -> m a
- data FileStoreT fp (m :: * -> *) a
- data FileStoreConfig
- runFileStoreT :: Monad m => FileStoreT FilePath m a -> FileStoreConfig -> m a
- defFileStoreConfig :: FileStoreConfig
- data ConcurrentDb root
- concurrentHandles :: FilePath -> ConcurrentHandles
- openConcurrentDb :: (Root root, MonadIO m, MonadMask m, ConcurrentMetaStoreM m) => ConcurrentHandles -> m (Maybe (ConcurrentDb root))
- createConcurrentDb :: (Root root, MonadIO m, MonadMask m, ConcurrentMetaStoreM m) => ConcurrentHandles -> root -> m (ConcurrentDb root)
Re-exports
Monad
class Monad m => MonadHaskey root m | m -> root where #
A monad supporting database transactions.
The type root is the data type holding the roots of the database trees.
Minimal complete definition
Methods
transact :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> m a #
transact_ :: Root root => (forall n. (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> m () #
transactReadOnly :: Root root => (forall n. (AllocReaderM n, MonadMask n) => root -> n a) -> m a #
Instances
| (Monoid w, MonadHaskey root m) => MonadHaskey root (WriterT w m) # | |
Defined in Control.Monad.Haskey Methods transact :: Root root => (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> WriterT w m a # transact_ :: (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> WriterT w m () # transactReadOnly :: Root root => (forall (n :: * -> *). (AllocReaderM n, MonadMask n) => root -> n a) -> WriterT w m a # | |
| (Monoid w, MonadHaskey root m) => MonadHaskey root (WriterT w m) # | |
Defined in Control.Monad.Haskey Methods transact :: Root root => (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> WriterT w m a # transact_ :: (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> WriterT w m () # transactReadOnly :: Root root => (forall (n :: * -> *). (AllocReaderM n, MonadMask n) => root -> n a) -> WriterT w m a # | |
| MonadHaskey root m => MonadHaskey root (StateT s m) # | |
Defined in Control.Monad.Haskey Methods transact :: Root root => (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> StateT s m a # transact_ :: (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> StateT s m () # transactReadOnly :: Root root => (forall (n :: * -> *). (AllocReaderM n, MonadMask n) => root -> n a) -> StateT s m a # | |
| MonadHaskey root m => MonadHaskey root (StateT s m) # | |
Defined in Control.Monad.Haskey Methods transact :: Root root => (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> StateT s m a # transact_ :: (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> StateT s m () # transactReadOnly :: Root root => (forall (n :: * -> *). (AllocReaderM n, MonadMask n) => root -> n a) -> StateT s m a # | |
| (Root root, Applicative m, MonadMask m, MonadIO m) => MonadHaskey root (HaskeyT root m) # | |
Defined in Control.Monad.Haskey Methods transact :: Root root => (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> HaskeyT root m a # transact_ :: (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> HaskeyT root m () # transactReadOnly :: Root root => (forall (n :: * -> *). (AllocReaderM n, MonadMask n) => root -> n a) -> HaskeyT root m a # | |
| MonadHaskey root m => MonadHaskey root (ReaderT r m) # | |
Defined in Control.Monad.Haskey Methods transact :: Root root => (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> ReaderT r m a # transact_ :: (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> ReaderT r m () # transactReadOnly :: Root root => (forall (n :: * -> *). (AllocReaderM n, MonadMask n) => root -> n a) -> ReaderT r m a # | |
| (Monoid w, MonadHaskey root m) => MonadHaskey root (RWST r w s m) # | |
Defined in Control.Monad.Haskey Methods transact :: Root root => (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> RWST r w s m a # transact_ :: (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> RWST r w s m () # transactReadOnly :: Root root => (forall (n :: * -> *). (AllocReaderM n, MonadMask n) => root -> n a) -> RWST r w s m a # | |
| (Monoid w, MonadHaskey root m) => MonadHaskey root (RWST r w s m) # | |
Defined in Control.Monad.Haskey Methods transact :: Root root => (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> RWST r w s m a # transact_ :: (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> RWST r w s m () # transactReadOnly :: Root root => (forall (n :: * -> *). (AllocReaderM n, MonadMask n) => root -> n a) -> RWST r w s m a # | |
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) # | |
Defined in Control.Monad.Haskey | |
| MonadBaseControl IO m => MonadBaseControl IO (HaskeyT root m) # | |
| MonadBase IO m => MonadBase IO (HaskeyT root m) # | |
Defined in Control.Monad.Haskey | |
| MonadWriter w m => MonadWriter w (HaskeyT root m) # | |
| MonadState s m => MonadState s (HaskeyT root m) # | |
| MonadReader r m => MonadReader r (HaskeyT root m) # | |
| (Root root, Applicative m, MonadMask m, MonadIO m) => MonadHaskey root (HaskeyT root m) # | |
Defined in Control.Monad.Haskey Methods transact :: Root root => (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root a)) -> HaskeyT root m a # transact_ :: (forall (n :: * -> *). (AllocM n, MonadMask n) => root -> n (Transaction root ())) -> HaskeyT root m () # transactReadOnly :: Root root => (forall (n :: * -> *). (AllocReaderM n, MonadMask n) => root -> n a) -> HaskeyT root m a # | |
| MonadTransControl (HaskeyT root) # | |
| MonadTrans (HaskeyT root) # | |
Defined in Control.Monad.Haskey | |
| Monad m => Monad (HaskeyT root m) # | |
| Functor m => Functor (HaskeyT root m) # | |
| Applicative m => Applicative (HaskeyT root m) # | |
Defined in Control.Monad.Haskey Methods pure :: a -> HaskeyT root m a # (<*>) :: HaskeyT root m (a -> b) -> HaskeyT root m a -> HaskeyT root m b # liftA2 :: (a -> b -> c) -> HaskeyT root m a -> HaskeyT root m b -> HaskeyT root m c # (*>) :: 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) # | |
Defined in Control.Monad.Haskey | |
| MonadThrow m => MonadThrow (HaskeyT root m) # | |
Defined in Control.Monad.Haskey | |
| MonadCatch m => MonadCatch (HaskeyT root m) # | |
| MonadMask m => MonadMask (HaskeyT root m) # | |
Defined in Control.Monad.Haskey 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 # generalBracket :: HaskeyT root m a -> (a -> ExitCase b -> HaskeyT root m c) -> (a -> HaskeyT root m b) -> HaskeyT root m (b, c) # | |
| type StT (HaskeyT root) a # | |
Defined in Control.Monad.Haskey type StT (HaskeyT root) a = StT (ReaderT (ConcurrentDb root, FileStoreConfig) :: (* -> *) -> * -> *) a | |
| type StM (HaskeyT root m) a # | |
Defined in Control.Monad.Haskey | |
runHaskeyT :: (Root root, MonadMask m, MonadIO m) => HaskeyT root m a -> ConcurrentDb root -> FileStoreConfig -> m a #
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
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.
Instances
| Show FileStoreConfig | |
Defined in Database.Haskey.Store.File Methods showsPrec :: Int -> FileStoreConfig -> ShowS # show :: FileStoreConfig -> String # showList :: [FileStoreConfig] -> ShowS # | |
| Monad m => MonadReader FileStoreConfig (FileStoreT fp m) | |
Defined in Database.Haskey.Store.File Methods ask :: FileStoreT fp m FileStoreConfig # local :: (FileStoreConfig -> FileStoreConfig) -> FileStoreT fp m a -> FileStoreT fp m a # reader :: (FileStoreConfig -> a) -> FileStoreT fp m a # | |
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.