polysemy-kvstore-0.1.3.0: KVStore effect for polysemy.
Safe HaskellNone
LanguageHaskell2010

Polysemy.KVStore

Synopsis

Effect

data KVStore k v m a where Source #

Models things like Redis, HTTP GET/POST, etc. Things that are keyed, have a value, and may or may not be there.

Constructors

LookupKV :: k -> KVStore k v m (Maybe v) 
UpdateKV :: k -> Maybe v -> KVStore k v m () 

Actions

lookupKV :: forall k v r. Member (KVStore k v) r => k -> Sem r (Maybe v) Source #

lookupOrThrowKV :: Members '[KVStore k v, Error e] r => (k -> e) -> k -> Sem r v Source #

Since: 0.1.0.0

existsKV :: forall k v r. Member (KVStore k v) r => k -> Sem r Bool Source #

Since: 0.1.0.0

writeKV :: Member (KVStore k v) r => k -> v -> Sem r () Source #

Since: 0.1.0.0

deleteKV :: forall k v r. Member (KVStore k v) r => k -> Sem r () Source #

Since: 0.1.0.0

updateKV :: forall k v r. Member (KVStore k v) r => k -> Maybe v -> Sem r () Source #

modifyKV Source #

Arguments

:: Member (KVStore k v) r 
=> v

Default value if the key isn't present

-> (v -> v) 
-> k 
-> Sem r () 

Since: 0.1.0.0

Interpreters

runKVStoreAsState :: Ord k => Sem (KVStore k v ': r) a -> Sem (State (Map k v) ': r) a Source #

Run a KVStore as a State effect containing a Map.

Since: 0.1.0.0

runKVStorePure :: Ord k => Map k v -> Sem (KVStore k v ': r) a -> Sem r (Map k v, a) Source #

Run a KVStore purely as a Map.

Since: 0.1.0.0

runKVStoreAsKVStore Source #

Arguments

:: forall k v k' v' r a. (k -> k')

A function to transform the key into the interpreted key.

-> (v -> v')

A function to transform the value into the interpreted value.

-> (v' -> v)

A function to transform the interpreted key back into the current value.

-> Sem (KVStore k v ': r) a 
-> Sem (KVStore k' v' ': r) a 

Run a KVStore in terms of another KVStore by way of pure key and value transformations.

Since: 0.1.1.0

runKVStoreAsKVStoreSem Source #

Arguments

:: forall k v k' v' r a. Members '[KVStore k' v'] r 
=> (k -> Sem r k')

A function to transform the key into the interpreted key.

-> (v -> Sem r v')

A function to transform the value into the interpreted value.

-> (v' -> Sem r v)

A function to transform the interpreted value back into the current value.

-> Sem (KVStore k v ': r) a 
-> Sem r a 

Run a KVStore in terms of another KVStore by way of transforming the keys and values with Sem functions.

Since: 0.1.1.0