polysemy-zoo-0.6.0.1: Experimental, user-contributed effects and interpreters for polysemy

Safe HaskellNone
LanguageHaskell2010

Polysemy.KVStore

Contents

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 () 
Instances
type DefiningModule (KVStore :: Type -> Type -> k -> Type -> Type) Source # 
Instance details

Defined in Polysemy.KVStore

type DefiningModule (KVStore :: Type -> Type -> k -> Type -> Type) = "Polysemy.KVStore"

Actions

lookupKV :: forall k v r. MemberWithError (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.3.1.0

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

Since: 0.3.1.0

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

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

updateKV :: forall k v r. MemberWithError (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.3.1.0

Interpretations

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

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

runKVStoreInRedis :: (Member (Embed Redis) r, Member (Error Reply) r, Binary k, Binary v) => (k -> ByteString) -> Sem (KVStore k v ': r) a -> Sem r a Source #