{-# LANGUAGE CPP #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE TemplateHaskell #-}
module Effectful.PostgreSQL.Effect
(
PostgreSQL (..)
, runPostgreSQL
#if OTEL
, runPostgreSQLOT
#endif
, query
, query_
, queryWith
, queryWith_
, execute
, execute_
, executeMany
, withTransaction
, withTransactionLevel
, PSQL.IsolationLevel (..)
, withTransactionMode
, PSQL.TransactionMode (..)
, PSQL.ReadWriteMode (..)
, withTransactionModeRetry
, withTransactionModeRetry'
, withTransactionSerializable
, withTransactionSerialisable
, withSavepoint
, begin
, commit
, rollback
, fold
, foldWithOptions
, fold_
, foldWithOptions_
, forEach
, forEach_
, returning
, foldWith
, foldWithOptionsAndParser
, foldWith_
, foldWithOptionsAndParser_
, forEachWith
, forEachWith_
, returningWith
)
where
import qualified Control.Exception as E
import Data.Int (Int64)
import qualified Database.PostgreSQL.Simple as PSQL
import qualified Database.PostgreSQL.Simple.Transaction as PSQL
import qualified Database.PostgreSQL.Simple.FromRow as PSQL
import Effectful
import Effectful.Dispatch.Dynamic
import Effectful.PostgreSQL.Connection
import Effectful.TH
#if OTEL
import qualified "hs-opentelemetry-instrumentation-postgresql-simple" OpenTelemetry.Instrumentation.PostgresqlSimple as OT
#endif
data PostgreSQL :: Effect where
Query :: (PSQL.ToRow q, PSQL.FromRow r) => PSQL.Query -> q -> PostgreSQL m [r]
QueryWith :: (PSQL.ToRow q) => PSQL.RowParser r -> PSQL.Query -> q -> PostgreSQL m [r]
Query_ :: (PSQL.FromRow r) => PSQL.Query -> PostgreSQL m [r]
QueryWith_ :: PSQL.RowParser r -> PSQL.Query -> PostgreSQL m [r]
Execute :: (PSQL.ToRow q) => PSQL.Query -> q -> PostgreSQL m Int64
Execute_ :: PSQL.Query -> PostgreSQL m Int64
ExecuteMany :: (PSQL.ToRow q) => PSQL.Query -> [q] -> PostgreSQL m Int64
WithTransaction :: m a -> PostgreSQL m a
WithTransactionLevel :: PSQL.IsolationLevel -> m a -> PostgreSQL m a
WithTransactionMode :: PSQL.TransactionMode -> m a -> PostgreSQL m a
WithTransactionModeRetry :: PSQL.TransactionMode -> (PSQL.SqlError -> Bool) -> m a -> PostgreSQL m a
WithTransactionModeRetry' :: E.Exception e => PSQL.TransactionMode -> (e -> Bool) -> m a -> PostgreSQL m a
WithTransactionSerializable :: m a -> PostgreSQL m a
WithSavepoint :: m a -> PostgreSQL m a
Begin :: PostgreSQL m ()
Commit :: PostgreSQL m ()
Rollback :: PostgreSQL m ()
Fold ::
(PSQL.FromRow row, PSQL.ToRow params) =>
PSQL.Query ->
params ->
a ->
(a -> row -> m a) ->
PostgreSQL m a
Fold_ ::
(PSQL.FromRow row) =>
PSQL.Query ->
a ->
(a -> row -> m a) ->
PostgreSQL m a
FoldWithOptions ::
(PSQL.FromRow row, PSQL.ToRow params) =>
PSQL.FoldOptions ->
PSQL.Query ->
params ->
a ->
(a -> row -> m a) ->
PostgreSQL m a
FoldWithOptions_ ::
(PSQL.FromRow row) =>
PSQL.FoldOptions ->
PSQL.Query ->
a ->
(a -> row -> m a) ->
PostgreSQL m a
ForEach ::
(PSQL.FromRow r, PSQL.ToRow q) =>
PSQL.Query ->
q ->
(r -> m ()) ->
PostgreSQL m ()
ForEach_ ::
(PSQL.FromRow r) =>
PSQL.Query ->
(r -> m ()) ->
PostgreSQL m ()
Returning :: (PSQL.ToRow q, PSQL.FromRow r) => PSQL.Query -> [q] -> PostgreSQL m [r]
FoldWith ::
(PSQL.ToRow params) =>
PSQL.RowParser row ->
PSQL.Query ->
params ->
a ->
(a -> row -> m a) ->
PostgreSQL m a
FoldWithOptionsAndParser ::
(PSQL.ToRow params) =>
PSQL.FoldOptions ->
PSQL.RowParser row ->
PSQL.Query ->
params ->
a ->
(a -> row -> m a) ->
PostgreSQL m a
FoldWith_ ::
() =>
PSQL.RowParser row ->
PSQL.Query ->
a ->
(a -> row -> m a) ->
PostgreSQL m a
FoldWithOptionsAndParser_ ::
() =>
PSQL.FoldOptions ->
PSQL.RowParser row ->
PSQL.Query ->
a ->
(a -> row -> m a) ->
PostgreSQL m a
ForEachWith ::
(PSQL.ToRow q) =>
PSQL.RowParser r ->
PSQL.Query ->
q ->
(r -> m ()) ->
PostgreSQL m ()
ForEachWith_ ::
() =>
PSQL.RowParser r ->
PSQL.Query ->
(r -> m ()) ->
PostgreSQL m ()
ReturningWith :: (PSQL.ToRow q) => PSQL.RowParser r -> PSQL.Query -> [q] -> PostgreSQL m [r]
makeEffect ''PostgreSQL
withTransactionSerialisable ::
(HasCallStack, PostgreSQL :> es) => Eff es a -> Eff es a
withTransactionSerialisable :: forall (es :: [Effect]) a.
(HasCallStack, PostgreSQL :> es) =>
Eff es a -> Eff es a
withTransactionSerialisable = Eff es a -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, PostgreSQL :> es) =>
Eff es a -> Eff es a
withTransactionSerializable
{-# INLINE withTransactionSerialisable #-}
localUnliftWithConn ::
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es ->
(PSQL.Connection -> (forall b. Eff localEs b -> IO b) -> IO a) ->
Eff es a
localUnliftWithConn :: forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env Connection -> (forall b. Eff localEs b -> IO b) -> IO a
f =
(Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn ->
LocalEnv localEs es
-> ((forall b. Eff localEs b -> IO b) -> IO a) -> Eff es a
forall (es :: [Effect]) (handlerEs :: [Effect])
(localEs :: [Effect]) a.
(HasCallStack, SharedSuffix es handlerEs, IOE :> es) =>
LocalEnv localEs handlerEs
-> ((forall r. Eff localEs r -> IO r) -> IO a) -> Eff es a
localSeqUnliftIO LocalEnv localEs es
env (((forall b. Eff localEs b -> IO b) -> IO a) -> Eff es a)
-> ((forall b. Eff localEs b -> IO b) -> IO a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \forall b. Eff localEs b -> IO b
unlift ->
IO a -> IO a
forall a. IO a -> IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> IO a) -> IO a -> IO a
forall a b. (a -> b) -> a -> b
$ Connection -> (forall b. Eff localEs b -> IO b) -> IO a
f Connection
conn Eff localEs b -> IO b
forall b. Eff localEs b -> IO b
unlift
{-# INLINE localUnliftWithConn #-}
(...) :: (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
a -> b
unlift ... :: forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... t1 -> t2 -> a
f = \t1
a' t2
row -> a -> b
unlift (a -> b) -> a -> b
forall a b. (a -> b) -> a -> b
$ t1 -> t2 -> a
f t1
a' t2
row
runPostgreSQL :: forall es a. (HasCallStack, WithConnection :> es, IOE :> es) => Eff (PostgreSQL : es) a -> Eff es a
runPostgreSQL :: forall (es :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
Eff (PostgreSQL : es) a -> Eff es a
runPostgreSQL = EffectHandler PostgreSQL es -> Eff (PostgreSQL : es) a -> Eff es a
forall (e :: Effect) (es :: [Effect]) a.
(DispatchOf e ~ 'Dynamic) =>
EffectHandler e es -> Eff (e : es) a -> Eff es a
interpret (EffectHandler PostgreSQL es
-> Eff (PostgreSQL : es) a -> Eff es a)
-> EffectHandler PostgreSQL es
-> Eff (PostgreSQL : es) a
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \LocalEnv localEs es
env -> \case
Query Query
q q
row ->
(Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Connection -> Query -> q -> IO [r]
forall q r.
(ToRow q, FromRow r) =>
Connection -> Query -> q -> IO [r]
PSQL.query Connection
conn Query
q q
row)
QueryWith RowParser r
parser Query
q q
row ->
(Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (RowParser r -> Connection -> Query -> q -> IO [r]
forall q r.
ToRow q =>
RowParser r -> Connection -> Query -> q -> IO [r]
PSQL.queryWith RowParser r
parser Connection
conn Query
q q
row)
Query_ Query
row ->
(Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Connection -> Query -> IO [r]
forall r. FromRow r => Connection -> Query -> IO [r]
PSQL.query_ Connection
conn Query
row)
QueryWith_ RowParser r
parser Query
row ->
(Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (RowParser r -> Connection -> Query -> IO [r]
forall r. RowParser r -> Connection -> Query -> IO [r]
PSQL.queryWith_ RowParser r
parser Connection
conn Query
row)
Execute Query
q q
row -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Connection -> Query -> q -> IO Int64
forall q. ToRow q => Connection -> Query -> q -> IO Int64
PSQL.execute Connection
conn Query
q q
row)
Execute_ Query
q -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Connection -> Query -> IO Int64
PSQL.execute_ Connection
conn Query
q)
ExecuteMany Query
q [q]
row -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Connection -> Query -> [q] -> IO Int64
forall q. ToRow q => Connection -> Query -> [q] -> IO Int64
PSQL.executeMany Connection
conn Query
q [q]
row)
WithTransaction Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> Connection -> IO a -> IO a
forall a. Connection -> IO a -> IO a
PSQL.withTransaction Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionLevel IsolationLevel
level Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> IsolationLevel -> Connection -> IO a -> IO a
forall a. IsolationLevel -> Connection -> IO a -> IO a
PSQL.withTransactionLevel IsolationLevel
level Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionMode TransactionMode
mode Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> TransactionMode -> Connection -> IO a -> IO a
forall a. TransactionMode -> Connection -> IO a -> IO a
PSQL.withTransactionMode TransactionMode
mode Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionModeRetry TransactionMode
mode SqlError -> Bool
shouldRetry Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> TransactionMode -> (SqlError -> Bool) -> Connection -> IO a -> IO a
forall a.
TransactionMode -> (SqlError -> Bool) -> Connection -> IO a -> IO a
PSQL.withTransactionModeRetry TransactionMode
mode SqlError -> Bool
shouldRetry Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionModeRetry' TransactionMode
mode e -> Bool
shouldRetry Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> TransactionMode -> (e -> Bool) -> Connection -> IO a -> IO a
forall a e.
Exception e =>
TransactionMode -> (e -> Bool) -> Connection -> IO a -> IO a
PSQL.withTransactionModeRetry' TransactionMode
mode e -> Bool
shouldRetry Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionSerializable Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> Connection -> IO a -> IO a
forall a. Connection -> IO a -> IO a
PSQL.withTransactionSerializable Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithSavepoint Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> Connection -> IO a -> IO a
forall a. Connection -> IO a -> IO a
PSQL.withSavepoint Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
PostgreSQL (Eff localEs) a
Begin -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> Eff es a)
-> (Connection -> IO a) -> Connection -> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Connection -> IO a
Connection -> IO ()
PSQL.begin
PostgreSQL (Eff localEs) a
Commit -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> Eff es a)
-> (Connection -> IO a) -> Connection -> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Connection -> IO a
Connection -> IO ()
PSQL.commit
PostgreSQL (Eff localEs) a
Rollback -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> Eff es a)
-> (Connection -> IO a) -> Connection -> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Connection -> IO a
Connection -> IO ()
PSQL.rollback
Fold Query
q params
params a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a
forall row params a.
(FromRow row, ToRow params) =>
Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a
PSQL.fold Connection
conn Query
q params
params a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
Fold_ Query
q a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
Connection -> Query -> a -> (a -> row -> IO a) -> IO a
forall r a.
FromRow r =>
Connection -> Query -> a -> (a -> r -> IO a) -> IO a
PSQL.fold_ Connection
conn Query
q a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWithOptions FoldOptions
opts Query
q params
params a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
FoldOptions
-> Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a
forall row params a.
(FromRow row, ToRow params) =>
FoldOptions
-> Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a
PSQL.foldWithOptions FoldOptions
opts Connection
conn Query
q params
params a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWithOptions_ FoldOptions
opts Query
q a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
FoldOptions
-> Connection -> Query -> a -> (a -> row -> IO a) -> IO a
forall r a.
FromRow r =>
FoldOptions -> Connection -> Query -> a -> (a -> r -> IO a) -> IO a
PSQL.foldWithOptions_ FoldOptions
opts Connection
conn Query
q a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
ForEach Query
q q
row r -> Eff localEs ()
forR ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
Connection -> Query -> q -> (r -> IO ()) -> IO ()
forall q r.
(ToRow q, FromRow r) =>
Connection -> Query -> q -> (r -> IO ()) -> IO ()
PSQL.forEach Connection
conn Query
q q
row (Eff localEs () -> IO ()
forall b. Eff localEs b -> IO b
unlift (Eff localEs () -> IO ()) -> (r -> Eff localEs ()) -> r -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Eff localEs ()
forR)
ForEach_ Query
q r -> Eff localEs ()
forR ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
Connection -> Query -> (r -> IO ()) -> IO ()
forall r. FromRow r => Connection -> Query -> (r -> IO ()) -> IO ()
PSQL.forEach_ Connection
conn Query
q (Eff localEs () -> IO ()
forall b. Eff localEs b -> IO b
unlift (Eff localEs () -> IO ()) -> (r -> Eff localEs ()) -> r -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Eff localEs ()
forR)
Returning Query
q [q]
rows -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> Eff es a) -> IO a -> Eff es a
forall a b. (a -> b) -> a -> b
$ Connection -> Query -> [q] -> IO [r]
forall q r.
(ToRow q, FromRow r) =>
Connection -> Query -> [q] -> IO [r]
PSQL.returning Connection
conn Query
q [q]
rows
FoldWith RowParser row
parser Query
q params
params a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
RowParser row
-> Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a
forall params row a.
ToRow params =>
RowParser row
-> Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a
PSQL.foldWith RowParser row
parser Connection
conn Query
q params
params a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWithOptionsAndParser FoldOptions
opts RowParser row
parser Query
q params
params a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
FoldOptions
-> RowParser row
-> Connection
-> Query
-> params
-> a
-> (a -> row -> IO a)
-> IO a
forall params row a.
ToRow params =>
FoldOptions
-> RowParser row
-> Connection
-> Query
-> params
-> a
-> (a -> row -> IO a)
-> IO a
PSQL.foldWithOptionsAndParser FoldOptions
opts RowParser row
parser Connection
conn Query
q params
params a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWith_ RowParser row
parser Query
q a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
RowParser row
-> Connection -> Query -> a -> (a -> row -> IO a) -> IO a
forall r a.
RowParser r -> Connection -> Query -> a -> (a -> r -> IO a) -> IO a
PSQL.foldWith_ RowParser row
parser Connection
conn Query
q a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWithOptionsAndParser_ FoldOptions
opts RowParser row
parser Query
q a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
FoldOptions
-> RowParser row
-> Connection
-> Query
-> a
-> (a -> row -> IO a)
-> IO a
forall r a.
FoldOptions
-> RowParser r
-> Connection
-> Query
-> a
-> (a -> r -> IO a)
-> IO a
PSQL.foldWithOptionsAndParser_ FoldOptions
opts RowParser row
parser Connection
conn Query
q a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
ForEachWith RowParser r
parser Query
q q
row r -> Eff localEs ()
forR ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
RowParser r -> Connection -> Query -> q -> (r -> IO ()) -> IO ()
forall q r.
ToRow q =>
RowParser r -> Connection -> Query -> q -> (r -> IO ()) -> IO ()
PSQL.forEachWith RowParser r
parser Connection
conn Query
q q
row (Eff localEs () -> IO ()
forall b. Eff localEs b -> IO b
unlift (Eff localEs () -> IO ()) -> (r -> Eff localEs ()) -> r -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Eff localEs ()
forR)
ForEachWith_ RowParser r
parser Query
q r -> Eff localEs ()
forR ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
RowParser r -> Connection -> Query -> (r -> IO ()) -> IO ()
forall r.
RowParser r -> Connection -> Query -> (r -> IO ()) -> IO ()
PSQL.forEachWith_ RowParser r
parser Connection
conn Query
q (Eff localEs () -> IO ()
forall b. Eff localEs b -> IO b
unlift (Eff localEs () -> IO ()) -> (r -> Eff localEs ()) -> r -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Eff localEs ()
forR)
ReturningWith RowParser r
parser Query
q [q]
rows -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> Eff es a) -> IO a -> Eff es a
forall a b. (a -> b) -> a -> b
$ RowParser r -> Connection -> Query -> [q] -> IO [r]
forall q r.
ToRow q =>
RowParser r -> Connection -> Query -> [q] -> IO [r]
PSQL.returningWith RowParser r
parser Connection
conn Query
q [q]
rows
#if OTEL
runPostgreSQLOT :: forall es 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
runPostgreSQLOT = EffectHandler PostgreSQL es -> Eff (PostgreSQL : es) a -> Eff es a
forall (e :: Effect) (es :: [Effect]) a.
(DispatchOf e ~ 'Dynamic) =>
EffectHandler e es -> Eff (e : es) a -> Eff es a
interpret (EffectHandler PostgreSQL es
-> Eff (PostgreSQL : es) a -> Eff es a)
-> EffectHandler PostgreSQL es
-> Eff (PostgreSQL : es) a
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \LocalEnv localEs es
env -> \case
Query Query
q q
row ->
(Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> Connection -> Query -> q -> Eff es [r]
forall (m :: * -> *) q r.
(HasCallStack, MonadIO m, ToRow q, FromRow r) =>
Connection -> Query -> q -> m [r]
OT.query Connection
conn Query
q q
row
QueryWith RowParser r
parser Query
q q
row ->
(Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> RowParser r -> Connection -> Query -> q -> Eff es [r]
forall (m :: * -> *) q r.
(HasCallStack, MonadIO m, ToRow q) =>
RowParser r -> Connection -> Query -> q -> m [r]
OT.queryWith RowParser r
parser Connection
conn Query
q q
row
Query_ Query
row ->
(Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> Connection -> Query -> Eff es [r]
forall (m :: * -> *) r.
(HasCallStack, MonadIO m, FromRow r) =>
Connection -> Query -> m [r]
OT.query_ Connection
conn Query
row
QueryWith_ RowParser r
parser Query
row ->
(Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> RowParser r -> Connection -> Query -> Eff es [r]
forall (m :: * -> *) r.
MonadIO m =>
RowParser r -> Connection -> Query -> m [r]
OT.queryWith_ RowParser r
parser Connection
conn Query
row
Execute Query
q q
row -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> Connection -> Query -> q -> Eff es Int64
forall (m :: * -> *) q.
(HasCallStack, MonadIO m, ToRow q) =>
Connection -> Query -> q -> m Int64
OT.execute Connection
conn Query
q q
row
Execute_ Query
q -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> Connection -> Query -> Eff es Int64
forall (m :: * -> *). MonadIO m => Connection -> Query -> m Int64
OT.execute_ Connection
conn Query
q
ExecuteMany Query
q [q]
row -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> Connection -> Query -> [q] -> Eff es Int64
forall (m :: * -> *) q.
(HasCallStack, MonadIO m, ToRow q) =>
Connection -> Query -> [q] -> m Int64
OT.executeMany Connection
conn Query
q [q]
row
WithTransaction Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> Connection -> IO a -> IO a
forall a. Connection -> IO a -> IO a
OT.withTransaction Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionLevel IsolationLevel
level Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> IsolationLevel -> Connection -> IO a -> IO a
forall a. IsolationLevel -> Connection -> IO a -> IO a
PSQL.withTransactionLevel IsolationLevel
level Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionMode TransactionMode
mode Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> TransactionMode -> Connection -> IO a -> IO a
forall a. TransactionMode -> Connection -> IO a -> IO a
PSQL.withTransactionMode TransactionMode
mode Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionModeRetry TransactionMode
mode SqlError -> Bool
shouldRetry Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> TransactionMode -> (SqlError -> Bool) -> Connection -> IO a -> IO a
forall a.
TransactionMode -> (SqlError -> Bool) -> Connection -> IO a -> IO a
PSQL.withTransactionModeRetry TransactionMode
mode SqlError -> Bool
shouldRetry Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionModeRetry' TransactionMode
mode e -> Bool
shouldRetry Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> TransactionMode -> (e -> Bool) -> Connection -> IO a -> IO a
forall a e.
Exception e =>
TransactionMode -> (e -> Bool) -> Connection -> IO a -> IO a
PSQL.withTransactionModeRetry' TransactionMode
mode e -> Bool
shouldRetry Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithTransactionSerializable Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> Connection -> IO a -> IO a
forall a. Connection -> IO a -> IO a
PSQL.withTransactionSerializable Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
WithSavepoint Eff localEs a
f -> LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift -> Connection -> IO a -> IO a
forall a. Connection -> IO a -> IO a
OT.withSavepoint Connection
conn (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift Eff localEs a
f)
PostgreSQL (Eff localEs) a
Begin -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> Eff es a)
-> (Connection -> IO a) -> Connection -> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Connection -> IO a
Connection -> IO ()
OT.begin
PostgreSQL (Eff localEs) a
Commit -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> Eff es a)
-> (Connection -> IO a) -> Connection -> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Connection -> IO a
Connection -> IO ()
OT.commit
PostgreSQL (Eff localEs) a
Rollback -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ IO a -> Eff es a
forall a. IO a -> Eff es a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> Eff es a)
-> (Connection -> IO a) -> Connection -> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Connection -> IO a
Connection -> IO ()
OT.rollback
Fold Query
q params
params a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a
forall (m :: * -> *) row params a.
(HasCallStack, MonadUnliftIO m, FromRow row, ToRow params) =>
Connection -> Query -> params -> a -> (a -> row -> m a) -> m a
OT.fold Connection
conn Query
q params
params a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
Fold_ Query
q a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
Connection -> Query -> a -> (a -> row -> IO a) -> IO a
forall (m :: * -> *) r a.
(HasCallStack, MonadUnliftIO m, FromRow r) =>
Connection -> Query -> a -> (a -> r -> m a) -> m a
OT.fold_ Connection
conn Query
q a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWithOptions FoldOptions
opts Query
q params
params a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
FoldOptions
-> Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a
forall (m :: * -> *) row params a.
(HasCallStack, MonadUnliftIO m, FromRow row, ToRow params) =>
FoldOptions
-> Connection -> Query -> params -> a -> (a -> row -> m a) -> m a
OT.foldWithOptions FoldOptions
opts Connection
conn Query
q params
params a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWithOptions_ FoldOptions
opts Query
q a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
FoldOptions
-> Connection -> Query -> a -> (a -> row -> IO a) -> IO a
forall (m :: * -> *) r a.
(HasCallStack, MonadUnliftIO m, FromRow r) =>
FoldOptions -> Connection -> Query -> a -> (a -> r -> m a) -> m a
OT.foldWithOptions_ FoldOptions
opts Connection
conn Query
q a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
ForEach Query
q q
row r -> Eff localEs ()
forR ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
RowParser r -> Connection -> Query -> q -> (r -> IO ()) -> IO ()
forall (m :: * -> *) q r.
(HasCallStack, MonadUnliftIO m, ToRow q) =>
RowParser r -> Connection -> Query -> q -> (r -> m ()) -> m ()
OT.forEachWith RowParser r
forall a. FromRow a => RowParser a
PSQL.fromRow Connection
conn Query
q q
row (Eff localEs () -> IO ()
forall b. Eff localEs b -> IO b
unlift (Eff localEs () -> IO ()) -> (r -> Eff localEs ()) -> r -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Eff localEs ()
forR)
ForEach_ Query
q r -> Eff localEs ()
forR ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
Connection -> Query -> (r -> IO ()) -> IO ()
forall (m :: * -> *) r.
(HasCallStack, MonadUnliftIO m, FromRow r) =>
Connection -> Query -> (r -> m ()) -> m ()
OT.forEach_ Connection
conn Query
q (Eff localEs () -> IO ()
forall b. Eff localEs b -> IO b
unlift (Eff localEs () -> IO ()) -> (r -> Eff localEs ()) -> r -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Eff localEs ()
forR)
Returning Query
q [q]
rows -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> Connection -> Query -> [q] -> Eff es [r]
forall (m :: * -> *) q r.
(HasCallStack, MonadIO m, ToRow q, FromRow r) =>
Connection -> Query -> [q] -> m [r]
OT.returning Connection
conn Query
q [q]
rows
FoldWith RowParser row
parser Query
q params
params a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
RowParser row
-> Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a
forall (m :: * -> *) params row a.
(HasCallStack, MonadUnliftIO m, ToRow params) =>
RowParser row
-> Connection -> Query -> params -> a -> (a -> row -> m a) -> m a
OT.foldWith RowParser row
parser Connection
conn Query
q params
params a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWithOptionsAndParser FoldOptions
opts RowParser row
parser Query
q params
params a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
FoldOptions
-> RowParser row
-> Connection
-> Query
-> params
-> a
-> (a -> row -> IO a)
-> IO a
forall (m :: * -> *) params row a.
(HasCallStack, MonadUnliftIO m, ToRow params) =>
FoldOptions
-> RowParser row
-> Connection
-> Query
-> params
-> a
-> (a -> row -> m a)
-> m a
OT.foldWithOptionsAndParser FoldOptions
opts RowParser row
parser Connection
conn Query
q params
params a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWith_ RowParser row
parser Query
q a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
RowParser row
-> Connection -> Query -> a -> (a -> row -> IO a) -> IO a
forall (m :: * -> *) r a.
MonadUnliftIO m =>
RowParser r -> Connection -> Query -> a -> (a -> r -> m a) -> m a
OT.foldWith_ RowParser row
parser Connection
conn Query
q a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
FoldWithOptionsAndParser_ FoldOptions
opts RowParser row
parser Query
q a
a a -> row -> Eff localEs a
f ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
FoldOptions
-> RowParser row
-> Connection
-> Query
-> a
-> (a -> row -> IO a)
-> IO a
forall (m :: * -> *) r a.
MonadUnliftIO m =>
FoldOptions
-> RowParser r
-> Connection
-> Query
-> a
-> (a -> r -> m a)
-> m a
OT.foldWithOptionsAndParser_ FoldOptions
opts RowParser row
parser Connection
conn Query
q a
a (Eff localEs a -> IO a
forall b. Eff localEs b -> IO b
unlift (Eff localEs a -> IO a)
-> (a -> row -> Eff localEs a) -> a -> row -> IO a
forall a b t1 t2. (a -> b) -> (t1 -> t2 -> a) -> t1 -> t2 -> b
... a -> row -> Eff localEs a
f)
ForEachWith RowParser r
parser Query
q q
row r -> Eff localEs ()
forR ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
RowParser r -> Connection -> Query -> q -> (r -> IO ()) -> IO ()
forall (m :: * -> *) q r.
(HasCallStack, MonadUnliftIO m, ToRow q) =>
RowParser r -> Connection -> Query -> q -> (r -> m ()) -> m ()
OT.forEachWith RowParser r
parser Connection
conn Query
q q
row (Eff localEs () -> IO ()
forall b. Eff localEs b -> IO b
unlift (Eff localEs () -> IO ()) -> (r -> Eff localEs ()) -> r -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Eff localEs ()
forR)
ForEachWith_ RowParser r
parser Query
q r -> Eff localEs ()
forR ->
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall (es :: [Effect]) (localEs :: [Effect]) a.
(HasCallStack, WithConnection :> es, IOE :> es) =>
LocalEnv localEs es
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
localUnliftWithConn LocalEnv localEs es
env ((Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a)
-> (Connection -> (forall b. Eff localEs b -> IO b) -> IO a)
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn forall b. Eff localEs b -> IO b
unlift ->
RowParser r -> Connection -> Query -> (r -> IO ()) -> IO ()
forall (m :: * -> *) r.
MonadUnliftIO m =>
RowParser r -> Connection -> Query -> (r -> m ()) -> m ()
OT.forEachWith_ RowParser r
parser Connection
conn Query
q (Eff localEs () -> IO ()
forall b. Eff localEs b -> IO b
unlift (Eff localEs () -> IO ()) -> (r -> Eff localEs ()) -> r -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Eff localEs ()
forR)
ReturningWith RowParser r
parser Query
q [q]
rows -> (Connection -> Eff es a) -> Eff es a
forall a (es :: [Effect]).
(HasCallStack, WithConnection :> es) =>
(Connection -> Eff es a) -> Eff es a
withConnection ((Connection -> Eff es a) -> Eff es a)
-> (Connection -> Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ \Connection
conn -> RowParser r -> Connection -> Query -> [q] -> Eff es [r]
forall (m :: * -> *) q r.
(HasCallStack, MonadIO m, ToRow q) =>
RowParser r -> Connection -> Query -> [q] -> m [r]
OT.returningWith RowParser r
parser Connection
conn Query
q [q]
rows
#endif