postgresql-tx-0.3.0.0: A safe transaction monad for use with various PostgreSQL Haskell libraries.
Safe HaskellNone
LanguageHaskell2010

Database.PostgreSQL.Tx.Unsafe

Synopsis

Introduction

postgresql-tx discourages performing arbitrary IO within a database transaction, but sometimes performing this IO is necessary. This module provides operations and infrastructure for performing "unsafe" IO actions within TxM or a specific database library implementation monad. It also provides utilities for use in adaptor libraries.

Clients must explicitly import this module to perform IO in TxM or a specific database library implementation monad. All functions this module provides are prefixed with unsafe*. These two factors serve as annotation to simplify understanding exactly which parts of transactional database code are performing arbitary IO.

Operations

unsafeRunIOInTxM :: IO a -> TxM r a Source #

Run an IO action in TxM. Use this function with care - arbitrary IO should only be run within a transaction when truly necessary.

Since: 0.2.0.0

unsafeWithRunInIOTxM :: ((forall a. TxM r a -> IO a) -> IO b) -> TxM r b Source #

Run a TxM action in IO via the provided runner function. Use this function with care - arbitrary IO should only be run within a transaction when truly necessary.

Since: 0.2.0.0

For adaptor libraries

unsafeUnTxM :: TxM r a -> ReaderT r IO a Source #

Convert a TxM action to raw ReaderT over IO. This is provided only to give adaptor libraries access to the underlying IO that TxM wraps.

Since: 0.2.0.0

unsafeRunTxM :: r -> TxM r a -> IO a Source #

Run a TxM to IO given the database runtime environment r. Use of this function outside of test suites should be rare.

Since: 0.2.0.0

unsafeMkTxM :: (r -> IO a) -> TxM r a Source #

Construct a TxM using a reader function. Use this function with care - arbitrary IO should only be run within a transaction when truly necessary.

Since: 0.2.0.0

unsafeMksTxM :: TxEnv a r => (a -> IO b) -> TxM r b Source #

Similar to unsafeMkTxM but allows for constructing a TxM with a reader function using a specific value from the environment. Use this function with care - arbitrary IO should only be run within a transaction when truly necessary.

Since: 0.2.0.0

unsafeLookupTxEnvIO :: TxEnv a r => r -> IO a Source #

Analogous to lookupTxEnv but can be run in IO instead of TxM.

Since: 0.2.0.0

unsafeMkTxException :: Exception e => (e -> Maybe String) -> e -> TxException Source #

Construct a TxException from an errcode accessing function and the cause exception.

Note that this function should only be used by libraries which are implementing a database backend for postgresql-tx.