-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | a transactional monad on top of postgresql-simple
--   
--   This package is a simple monadic wrapper around the SQL primitives
--   provided by the postgresql-simple package. It provides simple and
--   predictable semantics for database options, enforces awareness of
--   Postgres's transactional nature at API boundaries, and obviates the
--   need for SQL boilerplate in transactional queries.
@package postgresql-transactional
@version 1.1.1


-- | This module provdes querying with and executing SQL statements that
--   replace the ones found in <tt>Database.PostgreSQL.Simple</tt>.
--   
--   Please note that the parameter order is reversed when compared to the
--   functions provided by postgresql-simple. This is a conscious choice
--   made so as to ease use of a SQL quasiquoter.
module Database.PostgreSQL.Transaction

-- | The Postgres transaction monad transformer. This is implemented as a
--   monad transformer so as to integrate properly with monadic logging
--   libraries like <tt>monad-logger</tt> or <tt>katip</tt>.
data PGTransactionT m a

-- | A type alias for occurrences of <a>PGTransactionT</a> in the IO monad.
type PGTransaction = PGTransactionT IO

-- | As <a>runPGTransactionT'</a>, but with the
--   <tt>DefaultIsolationLevel</tt> isolation level.
runPGTransactionT :: MonadBaseControl IO m => PGTransactionT m a -> Connection -> m a

-- | Runs a transaction in the base monad <tt>m</tt> with a provided
--   <tt>IsolationLevel</tt>. An instance of MonadBaseControl is required
--   so as to handle lifted calls to <tt>catch</tt> correctly.
runPGTransactionT' :: MonadBaseControl IO m => IsolationLevel -> PGTransactionT m a -> Connection -> m a

-- | Convenience function when there are no embedded monadic effects, only
--   IO.
runPGTransactionIO :: MonadIO m => PGTransaction a -> Connection -> m a

-- | Issue an SQL query, taking a <a>ToRow</a> input and yielding
--   <a>FromRow</a> outputs. Please note that the parameter order is
--   different from that in the parent postgresql-simple library; this is
--   an intentional choice to improve the aesthetics when using the SQL
--   quasiquoter (making the query parameters come first means that there
--   is more room for the query string).
query :: (ToRow input, FromRow output, MonadIO m) => input -> Query -> PGTransactionT m [output]

-- | As <a>query</a>, but for queries that take no arguments.
query_ :: (FromRow output, MonadIO m) => Query -> PGTransactionT m [output]

-- | Run a single SQL action and return success.
execute :: (ToRow input, MonadIO m) => input -> Query -> PGTransactionT m Int64

-- | Run a statement and return <a>True</a> if only a single record was
--   modified.
executeOne :: (ToRow input, MonadIO m) => input -> Query -> PGTransactionT m Bool

-- | As <a>executeMany</a>, but operating in the transaction monad. If any
--   one of these computations fails, the entire block will be rolled back.
executeMany :: (ToRow input, MonadIO m) => [input] -> Query -> PGTransactionT m Int64

-- | Identical to <a>returning</a>, save parameter order.
returning :: (ToRow input, FromRow output, MonadIO m) => [input] -> Query -> PGTransactionT m [output]

-- | Run a query and return <a>Just</a> the first result found or
--   <a>Nothing</a>.
queryHead :: (ToRow input, FromRow output, MonadIO m) => input -> Query -> PGTransactionT m (Maybe output)

-- | Lookup a single FromField value. This takes care of handling
--   <tt>Only</tt> for you.
queryOnly :: (ToRow input, FromField f, MonadIO m) => input -> Query -> PGTransactionT m (Maybe f)

-- | As <a>formatQuery</a>, save parameter order.
formatQuery :: (ToRow input, MonadIO m) => input -> Query -> PGTransactionT m Query
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Database.PostgreSQL.Transaction.PGTransactionT m)
instance GHC.Base.Monad m => Control.Monad.Reader.Class.MonadReader Database.PostgreSQL.Simple.Internal.Connection (Database.PostgreSQL.Transaction.PGTransactionT m)
instance Control.Monad.Trans.Class.MonadTrans Database.PostgreSQL.Transaction.PGTransactionT
instance GHC.Base.Monad m => GHC.Base.Monad (Database.PostgreSQL.Transaction.PGTransactionT m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Database.PostgreSQL.Transaction.PGTransactionT m)
instance GHC.Base.Functor m => GHC.Base.Functor (Database.PostgreSQL.Transaction.PGTransactionT m)
