{-# LANGUAGE
MonoLocalBinds
, RankNTypes
#-}
module Squeal.PostgreSQL.Session.Transaction
(
Transaction
, transactionally
, transactionally_
, transactionallyRetry
, transactionallyRetry_
, ephemerally
, ephemerally_
, withSavepoint
, TransactionMode (..)
, defaultMode
, longRunningMode
, retryMode
, IsolationLevel (..)
, AccessMode (..)
, DeferrableMode (..)
) where
import Control.Monad.Catch
import Data.ByteString
import Squeal.PostgreSQL.Session.Monad
import Squeal.PostgreSQL.Session.Result
import Squeal.PostgreSQL.Session.Transaction.Unsafe
( TransactionMode (..)
, defaultMode
, longRunningMode
, retryMode
, IsolationLevel (..)
, AccessMode (..)
, DeferrableMode (..)
)
import qualified Squeal.PostgreSQL.Session.Transaction.Unsafe as Unsafe
type Transaction db x = forall m.
( MonadPQ db m
, MonadResult m
, MonadCatch m
) => m x
transactionally
:: (MonadMask tx, MonadResult tx, MonadPQ db tx)
=> TransactionMode
-> Transaction db x
-> tx x
transactionally :: TransactionMode -> Transaction db x -> tx x
transactionally TransactionMode
mode Transaction db x
tx = TransactionMode -> tx x -> tx x
forall (tx :: * -> *) (db :: SchemasType) x.
(MonadMask tx, MonadPQ db tx) =>
TransactionMode -> tx x -> tx x
Unsafe.transactionally TransactionMode
mode tx x
Transaction db x
tx
transactionally_
:: (MonadMask tx, MonadResult tx, MonadPQ db tx)
=> Transaction db x
-> tx x
transactionally_ :: Transaction db x -> tx x
transactionally_ Transaction db x
tx = tx x -> tx x
forall (tx :: * -> *) (db :: SchemasType) x.
(MonadMask tx, MonadPQ db tx) =>
tx x -> tx x
Unsafe.transactionally_ tx x
Transaction db x
tx
transactionallyRetry
:: (MonadMask tx, MonadResult tx, MonadPQ db tx)
=> TransactionMode
-> Transaction db x
-> tx x
transactionallyRetry :: TransactionMode -> Transaction db x -> tx x
transactionallyRetry TransactionMode
mode Transaction db x
tx = TransactionMode -> tx x -> tx x
forall (tx :: * -> *) (db :: SchemasType) x.
(MonadMask tx, MonadPQ db tx) =>
TransactionMode -> tx x -> tx x
Unsafe.transactionallyRetry TransactionMode
mode tx x
Transaction db x
tx
transactionallyRetry_
:: (MonadMask tx, MonadResult tx, MonadPQ db tx)
=> Transaction db x
-> tx x
transactionallyRetry_ :: Transaction db x -> tx x
transactionallyRetry_ Transaction db x
tx = tx x -> tx x
forall (tx :: * -> *) (db :: SchemasType) x.
(MonadMask tx, MonadPQ db tx) =>
tx x -> tx x
Unsafe.transactionallyRetry_ tx x
Transaction db x
tx
ephemerally
:: (MonadMask tx, MonadResult tx, MonadPQ db tx)
=> TransactionMode
-> Transaction db x
-> tx x
ephemerally :: TransactionMode -> Transaction db x -> tx x
ephemerally TransactionMode
mode Transaction db x
tx = TransactionMode -> tx x -> tx x
forall (tx :: * -> *) (db :: SchemasType) x.
(MonadMask tx, MonadPQ db tx) =>
TransactionMode -> tx x -> tx x
Unsafe.ephemerally TransactionMode
mode tx x
Transaction db x
tx
ephemerally_
:: (MonadMask tx, MonadResult tx, MonadPQ db tx)
=> Transaction db x
-> tx x
ephemerally_ :: Transaction db x -> tx x
ephemerally_ Transaction db x
tx = tx x -> tx x
forall (tx :: * -> *) (db :: SchemasType) x.
(MonadMask tx, MonadPQ db tx) =>
tx x -> tx x
Unsafe.ephemerally_ tx x
Transaction db x
tx
withSavepoint
:: ByteString
-> Transaction db (Either e x)
-> Transaction db (Either e x)
withSavepoint :: ByteString
-> Transaction db (Either e x) -> Transaction db (Either e x)
withSavepoint ByteString
sv Transaction db (Either e x)
tx = ByteString -> m (Either e x) -> m (Either e x)
forall (db :: SchemasType) (tx :: * -> *) e x.
MonadPQ db tx =>
ByteString -> tx (Either e x) -> tx (Either e x)
Unsafe.withSavepoint ByteString
sv m (Either e x)
Transaction db (Either e x)
tx