Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data QStore f q d :: Effect
- type Store i d = QStore Maybe i (Uid i d)
- insert :: forall f i d r. Member (QStore f i d) r => d -> Sem r ()
- upsert :: forall f i d r. Member (QStore f i d) r => d -> Sem r ()
- delete :: forall f i d r. Member (QStore f i d) r => i -> Sem r (f d)
- deleteAll :: forall f i d r. Member (QStore f i d) r => Sem r [d]
- fetch :: forall f i d r. Member (QStore f i d) r => i -> Sem r (f d)
- fetchAll :: forall f i d r. Member (QStore f i d) r => Sem r [d]
- elem :: forall i d r. Member (Store i d) r => i -> Sem r Bool
- fetchPayload :: forall i d r. Member (Store i d) r => i -> Sem r (Maybe d)
- alter :: forall i d r. Member (Store i d) r => i -> (d -> d) -> Sem r ()
- data Query q o :: Effect
- query :: forall q o r. Member (Query q o) r => q -> Sem r o
- data Random a :: Effect
- random :: forall a r. Member (Random a) r => Sem r a
- randomR :: forall a r. Member (Random a) r => (a, a) -> Sem r a
- data Id i :: Effect
- newId :: forall i r. Member (Id i) r => Sem r i
- interpretStoreConc :: forall i a r. Ord i => Show i => Member (Embed IO) r => PureStore i a -> InterpretersFor [Store i a !! DbError, AtomicState (PureStore i a)] r
- interpretStoreLocal :: forall i a r. Ord i => Show i => PureStore i a -> InterpretersFor [Store i a !! DbError, State (PureStore i a)] r
- interpretStoreAtomicState :: forall i a r. Ord i => Show i => Member (AtomicState (PureStore i a)) r => InterpreterFor (Store i a !! DbError) r
- interpretStoreState :: forall i a r. Ord i => Show i => Member (State (PureStore i a)) r => InterpreterFor (Store i a !! DbError) r
- interpretStoreNull :: InterpreterFor (Store i a !! e) r
- newtype PureStore i a = PureStore (Map i (Uid i a))
- pureStore :: Ord i => [Uid i a] -> PureStore i a
- interpretQueryConc :: Ord i => QueryCheckResult f => Member (Embed IO) r => (q -> Uid i a -> Maybe d) -> [Uid i a] -> InterpreterFor (Query q (f d) !! DbError) r
- interpretQueryConst :: Ord q => QueryCheckResult f => Map q [d] -> InterpreterFor (Query q (f d) !! DbError) r
- interpretQueryAtomicState :: forall i a d q f r. Member (AtomicState (PureStore i a)) r => QueryCheckResult f => (q -> Uid i a -> Maybe d) -> InterpreterFor (Query q (f d) !! DbError) r
- interpretQueryStoreConc :: Ord i => Show i => QueryCheckResult f => Member (Embed IO) r => (q -> Uid i a -> Maybe d) -> [Uid i a] -> InterpretersFor [Query q (f d) !! DbError, Store i a !! DbError, AtomicState (PureStore i a)] r
- interpretQueryStoreAny :: forall q d i e r. Member (Store i d !! e) r => (q -> d -> Bool) -> InterpreterFor (Query q Bool !! e) r
- interpretRandom :: forall a r. Random a => Member (Embed IO) r => InterpreterFor (Random a) r
- interpretRandomAtomic :: forall a q r. Random a => RandomGen q => Member (Embed IO) r => q -> InterpreterFor (Random a) r
- interpretRandomState :: forall a q r. Random a => RandomGen q => q -> InterpreterFor (Random a) r
- interpretRandomAtomicState :: forall a q r. Random a => RandomGen q => Member (AtomicState q) r => InterpreterFor (Random a) r
- interpretIdUuid :: Member (Random UUID) r => InterpreterFor (Id UUID) r
- interpretIdUuidIO :: Member (Embed IO) r => InterpreterFor (Id UUID) r
- interpretIdAtomicState :: forall i r. Members [AtomicState [i], Error Text] r => InterpreterFor (Id i) r
- interpretIdNum :: forall i r. Member (Embed IO) r => Num i => InterpreterFor (Id i) r
- interpretIdNumFrom :: forall i r. Member (Embed IO) r => Num i => i -> InterpreterFor (Id i) r
- interpretIdNumLocal :: forall i r. Num i => InterpreterFor (Id i) r
- interpretIdList :: forall i r. Members [Error Text, Embed IO] r => [i] -> InterpreterFor (Id i) r
- interpretIdConst :: forall i r. i -> InterpreterFor (Id i) r
- interpretIdUuidZero :: InterpreterFor (Id UUID) r
- interpretAtomicStateStore :: forall tag d err r. Members [QStore Maybe () d !! err, Lock @@ tag] r => Sem (Stop err ': r) d -> InterpreterFor (AtomicState d !! err) r
- interpretAtomicStateStoreAs :: forall tag d err r. Members [QStore Maybe () d !! err, Lock @@ tag] r => d -> InterpreterFor (AtomicState d !! err) r
- interpretAtomicStateStoreScoped :: forall tag param d err r. Members [Scoped param (QStore Maybe () d !! err) !! err, Lock @@ tag] r => Sem (Stop err ': r) d -> InterpreterFor (Scoped param (AtomicState d !! err) !! err) r
- interpretAtomicStateStoreScopedAs :: forall tag param d err r. Members [Scoped param (QStore Maybe () d !! err) !! err, Lock @@ tag] r => d -> InterpreterFor (Scoped param (AtomicState d !! err) !! err) r
- interpretAtomicStatesStore :: forall tag param d err r. Members [QStore Maybe () d !! err, Scoped param (QStore Maybe () d !! err) !! err, Lock @@ tag] r => Sem (Stop err ': r) d -> InterpretersFor [AtomicState d !! err, Scoped param (AtomicState d !! err) !! err] r
- interpretReaderStore :: forall d e r. Member (QStore Maybe () d !! e) r => Sem r d -> InterpreterFor (Reader d !! e) r
- interpretReaderStoreAs :: forall d e r. Member (QStore Maybe () d !! e) r => d -> InterpreterFor (Reader d !! e) r
- data DbConfig = DbConfig DbHost DbPort DbName DbUser DbPassword
- newtype DbHost = DbHost {}
- newtype DbPort = DbPort {}
- newtype DbName = DbName {}
- newtype DbUser = DbUser {}
- newtype DbPassword = DbPassword {
- unDbPassword :: Text
- data DbError
- newtype InitDbError = InitDbError {}
- data DbConnectionError
Documentation
The Polysemy
effects Store
and Query
provide a high-level abstraction of database operations for
CRUD and arbitrary queries.
Effects
Interpreters
interpretStoreConc :: forall i a r. Ord i => Show i => Member (Embed IO) r => PureStore i a -> InterpretersFor [Store i a !! DbError, AtomicState (PureStore i a)] r Source #
interpretStoreLocal :: forall i a r. Ord i => Show i => PureStore i a -> InterpretersFor [Store i a !! DbError, State (PureStore i a)] r Source #
interpretStoreAtomicState :: forall i a r. Ord i => Show i => Member (AtomicState (PureStore i a)) r => InterpreterFor (Store i a !! DbError) r Source #
interpretStoreState :: forall i a r. Ord i => Show i => Member (State (PureStore i a)) r => InterpreterFor (Store i a !! DbError) r Source #
interpretStoreNull :: InterpreterFor (Store i a !! e) r Source #
newtype PureStore i a Source #
Instances
Ord i => Monoid (PureStore i a) Source # | |
Ord i => Semigroup (PureStore i a) Source # | |
Generic (PureStore i a) Source # | |
(Show i, Show a) => Show (PureStore i a) Source # | |
Default (PureStore i a) Source # | |
Defined in Polysemy.Db.Interpreter.Store | |
(Eq i, Eq a) => Eq (PureStore i a) Source # | |
type Rep (PureStore i a) Source # | |
Defined in Polysemy.Db.Interpreter.Store |
interpretQueryConc :: Ord i => QueryCheckResult f => Member (Embed IO) r => (q -> Uid i a -> Maybe d) -> [Uid i a] -> InterpreterFor (Query q (f d) !! DbError) r Source #
interpretQueryConst :: Ord q => QueryCheckResult f => Map q [d] -> InterpreterFor (Query q (f d) !! DbError) r Source #
interpretQueryAtomicState :: forall i a d q f r. Member (AtomicState (PureStore i a)) r => QueryCheckResult f => (q -> Uid i a -> Maybe d) -> InterpreterFor (Query q (f d) !! DbError) r Source #
interpretQueryStoreConc :: Ord i => Show i => QueryCheckResult f => Member (Embed IO) r => (q -> Uid i a -> Maybe d) -> [Uid i a] -> InterpretersFor [Query q (f d) !! DbError, Store i a !! DbError, AtomicState (PureStore i a)] r Source #
interpretQueryStoreAny :: forall q d i e r. Member (Store i d !! e) r => (q -> d -> Bool) -> InterpreterFor (Query q Bool !! e) r Source #
interpretRandom :: forall a r. Random a => Member (Embed IO) r => InterpreterFor (Random a) r Source #
interpretRandomAtomic :: forall a q r. Random a => RandomGen q => Member (Embed IO) r => q -> InterpreterFor (Random a) r Source #
interpretRandomState :: forall a q r. Random a => RandomGen q => q -> InterpreterFor (Random a) r Source #
interpretRandomAtomicState :: forall a q r. Random a => RandomGen q => Member (AtomicState q) r => InterpreterFor (Random a) r Source #
interpretIdUuid :: Member (Random UUID) r => InterpreterFor (Id UUID) r Source #
interpretIdUuidIO :: Member (Embed IO) r => InterpreterFor (Id UUID) r Source #
interpretIdAtomicState :: forall i r. Members [AtomicState [i], Error Text] r => InterpreterFor (Id i) r Source #
interpretIdNum :: forall i r. Member (Embed IO) r => Num i => InterpreterFor (Id i) r Source #
interpretIdNumFrom :: forall i r. Member (Embed IO) r => Num i => i -> InterpreterFor (Id i) r Source #
interpretIdNumLocal :: forall i r. Num i => InterpreterFor (Id i) r Source #
interpretIdList :: forall i r. Members [Error Text, Embed IO] r => [i] -> InterpreterFor (Id i) r Source #
interpretIdConst :: forall i r. i -> InterpreterFor (Id i) r Source #
interpretIdUuidZero :: InterpreterFor (Id UUID) r Source #
interpretAtomicStateStore :: forall tag d err r. Members [QStore Maybe () d !! err, Lock @@ tag] r => Sem (Stop err ': r) d -> InterpreterFor (AtomicState d !! err) r Source #
Interpret AtomicState
as a singleton table.
Given an action that produces an initial value, every action reads the value from the database and writes it back.
interpretAtomicStateStoreAs :: forall tag d err r. Members [QStore Maybe () d !! err, Lock @@ tag] r => d -> InterpreterFor (AtomicState d !! err) r Source #
Interpret AtomicState
as a singleton table.
Given an initial value, every action reads the value from the database and writes it back.
interpretAtomicStateStoreScoped :: forall tag param d err r. Members [Scoped param (QStore Maybe () d !! err) !! err, Lock @@ tag] r => Sem (Stop err ': r) d -> InterpreterFor (Scoped param (AtomicState d !! err) !! err) r Source #
interpretAtomicStateStoreScopedAs :: forall tag param d err r. Members [Scoped param (QStore Maybe () d !! err) !! err, Lock @@ tag] r => d -> InterpreterFor (Scoped param (AtomicState d !! err) !! err) r Source #
interpretAtomicStatesStore :: forall tag param d err r. Members [QStore Maybe () d !! err, Scoped param (QStore Maybe () d !! err) !! err, Lock @@ tag] r => Sem (Stop err ': r) d -> InterpretersFor [AtomicState d !! err, Scoped param (AtomicState d !! err) !! err] r Source #
interpretReaderStore :: forall d e r. Member (QStore Maybe () d !! e) r => Sem r d -> InterpreterFor (Reader d !! e) r Source #
Interpret Reader
as a singleton table.
Given an initial value, every action reads the value from the database, potentially writing it on first access.
interpretReaderStoreAs :: forall d e r. Member (QStore Maybe () d !! e) r => d -> InterpreterFor (Reader d !! e) r Source #
Config
Connection information for a database. >>> DbConfig "localhost" 5432 "users" "post" "gres"
Instances
FromJSON DbConfig Source # | |
ToJSON DbConfig Source # | |
Defined in Polysemy.Db.Data.DbConfig | |
Generic DbConfig Source # | |
Show DbConfig Source # | |
Eq DbConfig Source # | |
type Rep DbConfig Source # | |
Defined in Polysemy.Db.Data.DbConfig type Rep DbConfig = D1 ('MetaData "DbConfig" "Polysemy.Db.Data.DbConfig" "polysemy-db-0.0.1.0-EOjm8REiHHR4cimfBw4Ew6" 'False) (C1 ('MetaCons "DbConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "host") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DbHost) :*: S1 ('MetaSel ('Just "port") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DbPort)) :*: (S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DbName) :*: (S1 ('MetaSel ('Just "user") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DbUser) :*: S1 ('MetaSel ('Just "password") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DbPassword))))) |
Instances
FromJSON DbHost Source # | |
ToJSON DbHost Source # | |
Defined in Polysemy.Db.Data.DbHost | |
IsString DbHost Source # | |
Defined in Polysemy.Db.Data.DbHost fromString :: String -> DbHost # | |
Generic DbHost Source # | |
Show DbHost Source # | |
Default DbHost Source # | |
Defined in Polysemy.Db.Data.DbHost | |
Eq DbHost Source # | |
Ord DbHost Source # | |
type Rep DbHost Source # | |
Defined in Polysemy.Db.Data.DbHost |
Instances
FromJSON DbPort Source # | |
ToJSON DbPort Source # | |
Defined in Polysemy.Db.Data.DbPort | |
Enum DbPort Source # | |
Defined in Polysemy.Db.Data.DbPort | |
Generic DbPort Source # | |
Num DbPort Source # | |
Read DbPort Source # | |
Integral DbPort Source # | |
Defined in Polysemy.Db.Data.DbPort | |
Real DbPort Source # | |
Defined in Polysemy.Db.Data.DbPort toRational :: DbPort -> Rational # | |
Show DbPort Source # | |
Default DbPort Source # | |
Defined in Polysemy.Db.Data.DbPort | |
Eq DbPort Source # | |
Ord DbPort Source # | |
type Rep DbPort Source # | |
Defined in Polysemy.Db.Data.DbPort |
Instances
FromJSON DbName Source # | |
ToJSON DbName Source # | |
Defined in Polysemy.Db.Data.DbName | |
IsString DbName Source # | |
Defined in Polysemy.Db.Data.DbName fromString :: String -> DbName # | |
Generic DbName Source # | |
Show DbName Source # | |
Eq DbName Source # | |
Ord DbName Source # | |
type Rep DbName Source # | |
Defined in Polysemy.Db.Data.DbName |
Instances
FromJSON DbUser Source # | |
ToJSON DbUser Source # | |
Defined in Polysemy.Db.Data.DbUser | |
IsString DbUser Source # | |
Defined in Polysemy.Db.Data.DbUser fromString :: String -> DbUser # | |
Generic DbUser Source # | |
Show DbUser Source # | |
Eq DbUser Source # | |
Ord DbUser Source # | |
type Rep DbUser Source # | |
Defined in Polysemy.Db.Data.DbUser |
newtype DbPassword Source #
Instances
Errors
newtype InitDbError Source #
Instances
data DbConnectionError Source #