| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Effectful.PostgreSQL.Effect
Synopsis
- data PostgreSQL (a :: Type -> Type) b where
- Query :: forall q r (a :: Type -> Type). (ToRow q, FromRow r) => Query -> q -> PostgreSQL a [r]
- QueryWith :: forall q r (a :: Type -> Type). ToRow q => RowParser r -> Query -> q -> PostgreSQL a [r]
- Query_ :: forall r (a :: Type -> Type). FromRow r => Query -> PostgreSQL a [r]
- QueryWith_ :: forall r (a :: Type -> Type). RowParser r -> Query -> PostgreSQL a [r]
- Execute :: forall q (a :: Type -> Type). ToRow q => Query -> q -> PostgreSQL a Int64
- Execute_ :: forall (a :: Type -> Type). Query -> PostgreSQL a Int64
- ExecuteMany :: forall q (a :: Type -> Type). ToRow q => Query -> [q] -> PostgreSQL a Int64
- WithTransaction :: forall (a :: Type -> Type) b. a b -> PostgreSQL a b
- WithTransactionLevel :: forall (a :: Type -> Type) b. IsolationLevel -> a b -> PostgreSQL a b
- WithTransactionMode :: forall (a :: Type -> Type) b. TransactionMode -> a b -> PostgreSQL a b
- WithTransactionModeRetry :: forall (a :: Type -> Type) b. TransactionMode -> (SqlError -> Bool) -> a b -> PostgreSQL a b
- WithTransactionModeRetry' :: forall e (a :: Type -> Type) b. Exception e => TransactionMode -> (e -> Bool) -> a b -> PostgreSQL a b
- WithTransactionSerializable :: forall (a :: Type -> Type) b. a b -> PostgreSQL a b
- WithSavepoint :: forall (a :: Type -> Type) b. a b -> PostgreSQL a b
- Begin :: forall (a :: Type -> Type). PostgreSQL a ()
- Commit :: forall (a :: Type -> Type). PostgreSQL a ()
- Rollback :: forall (a :: Type -> Type). PostgreSQL a ()
- Fold :: forall row params b (a :: Type -> Type). (FromRow row, ToRow params) => Query -> params -> b -> (b -> row -> a b) -> PostgreSQL a b
- Fold_ :: forall row b (a :: Type -> Type). FromRow row => Query -> b -> (b -> row -> a b) -> PostgreSQL a b
- FoldWithOptions :: forall row params b (a :: Type -> Type). (FromRow row, ToRow params) => FoldOptions -> Query -> params -> b -> (b -> row -> a b) -> PostgreSQL a b
- FoldWithOptions_ :: forall row b (a :: Type -> Type). FromRow row => FoldOptions -> Query -> b -> (b -> row -> a b) -> PostgreSQL a b
- ForEach :: forall r q (a :: Type -> Type). (FromRow r, ToRow q) => Query -> q -> (r -> a ()) -> PostgreSQL a ()
- ForEach_ :: forall r (a :: Type -> Type). FromRow r => Query -> (r -> a ()) -> PostgreSQL a ()
- Returning :: forall q r (a :: Type -> Type). (ToRow q, FromRow r) => Query -> [q] -> PostgreSQL a [r]
- FoldWith :: forall params row b (a :: Type -> Type). ToRow params => RowParser row -> Query -> params -> b -> (b -> row -> a b) -> PostgreSQL a b
- FoldWithOptionsAndParser :: forall params row b (a :: Type -> Type). ToRow params => FoldOptions -> RowParser row -> Query -> params -> b -> (b -> row -> a b) -> PostgreSQL a b
- FoldWith_ :: forall row b (a :: Type -> Type). RowParser row -> Query -> b -> (b -> row -> a b) -> PostgreSQL a b
- FoldWithOptionsAndParser_ :: forall row b (a :: Type -> Type). FoldOptions -> RowParser row -> Query -> b -> (b -> row -> a b) -> PostgreSQL a b
- ForEachWith :: forall q r (a :: Type -> Type). ToRow q => RowParser r -> Query -> q -> (r -> a ()) -> PostgreSQL a ()
- ForEachWith_ :: forall r (a :: Type -> Type). RowParser r -> Query -> (r -> a ()) -> PostgreSQL a ()
- ReturningWith :: forall q r (a :: Type -> Type). ToRow q => RowParser r -> Query -> [q] -> PostgreSQL a [r]
- runPostgreSQL :: forall (es :: [Effect]) a. (HasCallStack, WithConnection :> es, IOE :> es) => Eff (PostgreSQL ': es) a -> Eff es a
- runPostgreSQLOT :: forall (es :: [Effect]) a. (HasCallStack, WithConnection :> es, IOE :> es) => Eff (PostgreSQL ': es) a -> Eff es a
- query :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q, FromRow r) => Query -> q -> Eff es [r]
- query_ :: forall r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow r) => Query -> Eff es [r]
- queryWith :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => RowParser r -> Query -> q -> Eff es [r]
- queryWith_ :: forall r (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => RowParser r -> Query -> Eff es [r]
- execute :: forall q (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => Query -> q -> Eff es Int64
- execute_ :: forall (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Query -> Eff es Int64
- executeMany :: forall q (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => Query -> [q] -> Eff es Int64
- withTransaction :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es a -> Eff es a
- withTransactionLevel :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => IsolationLevel -> Eff es a -> Eff es a
- data IsolationLevel
- withTransactionMode :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => TransactionMode -> Eff es a -> Eff es a
- data TransactionMode = TransactionMode {}
- data ReadWriteMode
- withTransactionModeRetry :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => TransactionMode -> (SqlError -> Bool) -> Eff es a -> Eff es a
- withTransactionModeRetry' :: forall e a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, Exception e) => TransactionMode -> (e -> Bool) -> Eff es a -> Eff es a
- withTransactionSerializable :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es a -> Eff es a
- withTransactionSerialisable :: forall (es :: [Effect]) a. (HasCallStack, PostgreSQL :> es) => Eff es a -> Eff es a
- withSavepoint :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es a -> Eff es a
- begin :: forall (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es ()
- commit :: forall (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es ()
- rollback :: forall (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es ()
- fold :: forall row params a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow row, ToRow params) => Query -> params -> a -> (a -> row -> Eff es a) -> Eff es a
- foldWithOptions :: forall row params a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow row, ToRow params) => FoldOptions -> Query -> params -> a -> (a -> row -> Eff es a) -> Eff es a
- fold_ :: forall row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow row) => Query -> a -> (a -> row -> Eff es a) -> Eff es a
- foldWithOptions_ :: forall row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow row) => FoldOptions -> Query -> a -> (a -> row -> Eff es a) -> Eff es a
- forEach :: forall r q (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow r, ToRow q) => Query -> q -> (r -> Eff es ()) -> Eff es ()
- forEach_ :: forall r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow r) => Query -> (r -> Eff es ()) -> Eff es ()
- returning :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q, FromRow r) => Query -> [q] -> Eff es [r]
- foldWith :: forall params row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow params) => RowParser row -> Query -> params -> a -> (a -> row -> Eff es a) -> Eff es a
- foldWithOptionsAndParser :: forall params row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow params) => FoldOptions -> RowParser row -> Query -> params -> a -> (a -> row -> Eff es a) -> Eff es a
- foldWith_ :: forall row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => RowParser row -> Query -> a -> (a -> row -> Eff es a) -> Eff es a
- foldWithOptionsAndParser_ :: forall row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => FoldOptions -> RowParser row -> Query -> a -> (a -> row -> Eff es a) -> Eff es a
- forEachWith :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => RowParser r -> Query -> q -> (r -> Eff es ()) -> Eff es ()
- forEachWith_ :: forall r (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => RowParser r -> Query -> (r -> Eff es ()) -> Eff es ()
- returningWith :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => RowParser r -> Query -> [q] -> Eff es [r]
Effect
data PostgreSQL (a :: Type -> Type) b where Source #
Dynamic effect representing all the Postgres operations we want to perform.
Constructors
| Query :: forall q r (a :: Type -> Type). (ToRow q, FromRow r) => Query -> q -> PostgreSQL a [r] | Lifted |
| QueryWith :: forall q r (a :: Type -> Type). ToRow q => RowParser r -> Query -> q -> PostgreSQL a [r] | Lifted |
| Query_ :: forall r (a :: Type -> Type). FromRow r => Query -> PostgreSQL a [r] | Lifted |
| QueryWith_ :: forall r (a :: Type -> Type). RowParser r -> Query -> PostgreSQL a [r] | Lifted |
| Execute :: forall q (a :: Type -> Type). ToRow q => Query -> q -> PostgreSQL a Int64 | Lifted |
| Execute_ :: forall (a :: Type -> Type). Query -> PostgreSQL a Int64 | Lifted |
| ExecuteMany :: forall q (a :: Type -> Type). ToRow q => Query -> [q] -> PostgreSQL a Int64 | Lifted |
| WithTransaction :: forall (a :: Type -> Type) b. a b -> PostgreSQL a b | Lifted |
| WithTransactionLevel :: forall (a :: Type -> Type) b. IsolationLevel -> a b -> PostgreSQL a b | Lifted |
| WithTransactionMode :: forall (a :: Type -> Type) b. TransactionMode -> a b -> PostgreSQL a b | Lifted |
| WithTransactionModeRetry :: forall (a :: Type -> Type) b. TransactionMode -> (SqlError -> Bool) -> a b -> PostgreSQL a b | Lifted |
| WithTransactionModeRetry' :: forall e (a :: Type -> Type) b. Exception e => TransactionMode -> (e -> Bool) -> a b -> PostgreSQL a b | Lifted |
| WithTransactionSerializable :: forall (a :: Type -> Type) b. a b -> PostgreSQL a b | Lifted |
| WithSavepoint :: forall (a :: Type -> Type) b. a b -> PostgreSQL a b | Lifted |
| Begin :: forall (a :: Type -> Type). PostgreSQL a () | Lifted |
| Commit :: forall (a :: Type -> Type). PostgreSQL a () | Lifted |
| Rollback :: forall (a :: Type -> Type). PostgreSQL a () | Lifted |
| Fold :: forall row params b (a :: Type -> Type). (FromRow row, ToRow params) => Query -> params -> b -> (b -> row -> a b) -> PostgreSQL a b | Lifted |
| Fold_ :: forall row b (a :: Type -> Type). FromRow row => Query -> b -> (b -> row -> a b) -> PostgreSQL a b | Lifted |
| FoldWithOptions :: forall row params b (a :: Type -> Type). (FromRow row, ToRow params) => FoldOptions -> Query -> params -> b -> (b -> row -> a b) -> PostgreSQL a b | Lifted |
| FoldWithOptions_ :: forall row b (a :: Type -> Type). FromRow row => FoldOptions -> Query -> b -> (b -> row -> a b) -> PostgreSQL a b | Lifted |
| ForEach :: forall r q (a :: Type -> Type). (FromRow r, ToRow q) => Query -> q -> (r -> a ()) -> PostgreSQL a () | Lifted |
| ForEach_ :: forall r (a :: Type -> Type). FromRow r => Query -> (r -> a ()) -> PostgreSQL a () | Lifted |
| Returning :: forall q r (a :: Type -> Type). (ToRow q, FromRow r) => Query -> [q] -> PostgreSQL a [r] | Lifted |
| FoldWith :: forall params row b (a :: Type -> Type). ToRow params => RowParser row -> Query -> params -> b -> (b -> row -> a b) -> PostgreSQL a b | Lifted |
| FoldWithOptionsAndParser :: forall params row b (a :: Type -> Type). ToRow params => FoldOptions -> RowParser row -> Query -> params -> b -> (b -> row -> a b) -> PostgreSQL a b | Lifted |
| FoldWith_ :: forall row b (a :: Type -> Type). RowParser row -> Query -> b -> (b -> row -> a b) -> PostgreSQL a b | Lifted |
| FoldWithOptionsAndParser_ :: forall row b (a :: Type -> Type). FoldOptions -> RowParser row -> Query -> b -> (b -> row -> a b) -> PostgreSQL a b | Lifted |
| ForEachWith :: forall q r (a :: Type -> Type). ToRow q => RowParser r -> Query -> q -> (r -> a ()) -> PostgreSQL a () | Lifted |
| ForEachWith_ :: forall r (a :: Type -> Type). RowParser r -> Query -> (r -> a ()) -> PostgreSQL a () | Lifted |
| ReturningWith :: forall q r (a :: Type -> Type). ToRow q => RowParser r -> Query -> [q] -> PostgreSQL a [r] | Lifted |
Instances
| type DispatchOf PostgreSQL Source # | |
Defined in Effectful.PostgreSQL.Effect | |
Interpreters
runPostgreSQL :: forall (es :: [Effect]) a. (HasCallStack, WithConnection :> es, IOE :> es) => Eff (PostgreSQL ': es) a -> Eff es a Source #
Obvious interepreter for PostgreSQL. Just gets a Connection from WithConnection and calls the
corresponding function from Database.PostgreSQL.Simple.
runPostgreSQLOT :: forall (es :: [Effect]) a. (HasCallStack, WithConnection :> es, IOE :> es) => Eff (PostgreSQL ': es) a -> Eff es a Source #
An interpreter for the PostgreSQL effect that runs database operations using OpenTelemetry instrumentation.
Basically the same as runPostgreSQL except it uses the functions from
OpenTelemetry.Instrumentation.PostgresqlSimple.
Note that the enable-opentel cabal flag must be set to enable this functionality.
Lifted versions of functions from Database.PostgreSQL.Simple
Queries that return results
query :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q, FromRow r) => Query -> q -> Eff es [r] Source #
Lifted query.
query_ :: forall r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow r) => Query -> Eff es [r] Source #
Lifted query_.
queryWith :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => RowParser r -> Query -> q -> Eff es [r] Source #
Lifted queryWith.
queryWith_ :: forall r (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => RowParser r -> Query -> Eff es [r] Source #
Lifted queryWith_.
Statements that do not return results
execute :: forall q (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => Query -> q -> Eff es Int64 Source #
Lifted execute.
execute_ :: forall (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Query -> Eff es Int64 Source #
Lifted execute_.
executeMany :: forall q (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => Query -> [q] -> Eff es Int64 Source #
Lifted executeMany.
Transaction handling
withTransaction :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es a -> Eff es a Source #
Lifted withTransaction.
withTransactionLevel :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => IsolationLevel -> Eff es a -> Eff es a Source #
Lifted withTransactionLevel.
data IsolationLevel #
Of the four isolation levels defined by the SQL standard,
these are the three levels distinguished by PostgreSQL as of version 9.0.
See https://www.postgresql.org/docs/9.5/static/transaction-iso.html
for more information. Note that prior to PostgreSQL 9.0, RepeatableRead
was equivalent to Serializable.
Constructors
| DefaultIsolationLevel | the isolation level will be taken from
PostgreSQL's per-connection
|
| ReadCommitted | |
| RepeatableRead | |
| Serializable |
Instances
withTransactionMode :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => TransactionMode -> Eff es a -> Eff es a Source #
Lifted withTransactionMode.
data TransactionMode #
Constructors
| TransactionMode | |
Fields | |
Instances
| Show TransactionMode | |
Defined in Database.PostgreSQL.Simple.Transaction Methods showsPrec :: Int -> TransactionMode -> ShowS # show :: TransactionMode -> String # showList :: [TransactionMode] -> ShowS # | |
| Eq TransactionMode | |
Defined in Database.PostgreSQL.Simple.Transaction Methods (==) :: TransactionMode -> TransactionMode -> Bool # (/=) :: TransactionMode -> TransactionMode -> Bool # | |
data ReadWriteMode #
Constructors
| DefaultReadWriteMode | the read-write mode will be taken from
PostgreSQL's per-connection
|
| ReadWrite | |
| ReadOnly |
Instances
withTransactionModeRetry :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => TransactionMode -> (SqlError -> Bool) -> Eff es a -> Eff es a Source #
Lifted withTransactionModeRetry.
withTransactionModeRetry' :: forall e a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, Exception e) => TransactionMode -> (e -> Bool) -> Eff es a -> Eff es a Source #
Lifted withTransactionModeRetry'.
withTransactionSerializable :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es a -> Eff es a Source #
Lifted withTransactionSerializable.
withTransactionSerialisable :: forall (es :: [Effect]) a. (HasCallStack, PostgreSQL :> es) => Eff es a -> Eff es a Source #
British alias of withTransactionSerializable.
withSavepoint :: forall a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es a -> Eff es a Source #
Lifted withSavepoint.
begin :: forall (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es () Source #
Lifted begin.
commit :: forall (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es () Source #
Lifted commit.
rollback :: forall (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => Eff es () Source #
Lifted rollback.
Queries that stream results
fold :: forall row params a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow row, ToRow params) => Query -> params -> a -> (a -> row -> Eff es a) -> Eff es a Source #
Lifted fold.
foldWithOptions :: forall row params a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow row, ToRow params) => FoldOptions -> Query -> params -> a -> (a -> row -> Eff es a) -> Eff es a Source #
Lifted foldWithOptions.
fold_ :: forall row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow row) => Query -> a -> (a -> row -> Eff es a) -> Eff es a Source #
Lifted fold_.
foldWithOptions_ :: forall row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow row) => FoldOptions -> Query -> a -> (a -> row -> Eff es a) -> Eff es a Source #
Lifted foldWithOptions_.
forEach :: forall r q (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow r, ToRow q) => Query -> q -> (r -> Eff es ()) -> Eff es () Source #
Lifted forEach.
forEach_ :: forall r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, FromRow r) => Query -> (r -> Eff es ()) -> Eff es () Source #
Lifted forEach_.
returning :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q, FromRow r) => Query -> [q] -> Eff es [r] Source #
Lifted returning.
foldWith :: forall params row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow params) => RowParser row -> Query -> params -> a -> (a -> row -> Eff es a) -> Eff es a Source #
Lifted foldWith.
foldWithOptionsAndParser :: forall params row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow params) => FoldOptions -> RowParser row -> Query -> params -> a -> (a -> row -> Eff es a) -> Eff es a Source #
Lifted foldWithOptionsAndParser.
foldWith_ :: forall row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => RowParser row -> Query -> a -> (a -> row -> Eff es a) -> Eff es a Source #
Lifted foldWith_.
foldWithOptionsAndParser_ :: forall row a (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => FoldOptions -> RowParser row -> Query -> a -> (a -> row -> Eff es a) -> Eff es a Source #
Lifted foldWithOptionsAndParser_.
forEachWith :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => RowParser r -> Query -> q -> (r -> Eff es ()) -> Eff es () Source #
Lifted forEachWith.
forEachWith_ :: forall r (es :: [Effect]). (HasCallStack, PostgreSQL :> es) => RowParser r -> Query -> (r -> Eff es ()) -> Eff es () Source #
Lifted forEachWith_.
returningWith :: forall q r (es :: [Effect]). (HasCallStack, PostgreSQL :> es, ToRow q) => RowParser r -> Query -> [q] -> Eff es [r] Source #
Lifted returningWith.