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


-- | A monad transformer for Opaleye
--   
--   A monad transformer for Opaleye
@package opaleye-trans
@version 0.3.5

module Opaleye.Trans

-- | The <tt>Opaleye</tt> monad transformer
newtype OpaleyeT m a
OpaleyeT :: ReaderT Connection m a -> OpaleyeT m a
[unOpaleyeT] :: OpaleyeT m a -> ReaderT Connection m a

-- | Given a <a>Connection</a>, run an <a>OpaleyeT</a>
runOpaleyeT :: Connection -> OpaleyeT m a -> m a
data Transaction a

-- | Run a postgresql transaction in the <a>OpaleyeT</a> monad
transaction :: MonadIO m => Transaction a -> OpaleyeT m a

-- | Execute a query without a literal transaction
run :: MonadIO m => Transaction a -> OpaleyeT m a

-- | Execute a <a>Query</a>. See <a>runQuery</a>.
query :: Default QueryRunner a b => Query a -> Transaction [b]

-- | Retrieve the first result from a <a>Query</a>. Similar to
--   <tt>listToMaybe <a>$</a> runQuery</tt>.
queryFirst :: Default QueryRunner a b => Query a -> Transaction (Maybe b)

-- | Insert into a <a>Table</a>. See <a>runInsert</a>.
insert :: Table w r -> w -> Transaction Int64

-- | Insert many records into a <a>Table</a>. See <a>runInsertMany</a>.
insertMany :: Table w r -> [w] -> Transaction Int64

-- | Insert a record into a <a>Table</a> with a return value. See
--   <a>runInsertReturning</a>.
insertReturning :: Default QueryRunner a b => Table w r -> (r -> a) -> w -> Transaction [b]

-- | Insert a record into a <a>Table</a> with a return value. Retrieve only
--   the first result. Similar to <tt><a>listToMaybe</a> <a>&lt;$&gt;</a>
--   <a>insertReturning</a></tt>
insertReturningFirst :: Default QueryRunner a b => Table w r -> (r -> a) -> w -> Transaction (Maybe b)

-- | Insert many records into a <a>Table</a> with a return value for each
--   record.
--   
--   Maybe not worth defining. This almost certainly does the wrong thing.
insertManyReturning :: (Default QueryRunner a b) => Table w r -> [w] -> (r -> a) -> Transaction [b]

-- | Update items in a <a>Table</a> where the predicate is true. See
--   <a>runUpdate</a>.
update :: Table w r -> (r -> w) -> (r -> Column PGBool) -> Transaction Int64

-- | Update items in a <a>Table</a> with a return value. See
--   <a>runUpdateReturning</a>.
updateReturning :: Default QueryRunner returned haskells => Table w r -> (r -> w) -> (r -> Column PGBool) -> (r -> returned) -> Transaction [haskells]

-- | Update items in a <a>Table</a> with a return value. Similar to
--   <tt><a>listToMaybe</a> <a>&lt;$&gt;</a> <a>updateReturning</a></tt>.
updateReturningFirst :: Default QueryRunner returned haskells => Table w r -> (r -> w) -> (r -> Column PGBool) -> (r -> returned) -> Transaction (Maybe haskells)
delete :: Table a columnsR -> (columnsR -> Column PGBool) -> Transaction Int64
withConn :: MonadIO m => (Connection -> IO a) -> OpaleyeT m a

-- | Lift a computation from the base monad
liftBase :: MonadBase b m => forall α. b α -> m α
class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase (b :: * -> *) (m :: * -> *) | m -> b

-- | Lift a computation from the base monad
liftBase :: MonadBase b m => b α -> m α

-- | Lift a computation from the <a>IO</a> monad.
liftIO :: MonadIO m => forall a. IO a -> m a

-- | Monads in which <a>IO</a> computations may be embedded. Any monad
--   built by applying a sequence of monad transformers to the <a>IO</a>
--   monad will be an instance of this class.
--   
--   Instances should satisfy the following laws, which state that
--   <a>liftIO</a> is a transformer of monads:
--   
--   <ul>
--   <li><pre><a>liftIO</a> . <a>return</a> = <a>return</a></pre></li>
--   <li><pre><a>liftIO</a> (m &gt;&gt;= f) = <a>liftIO</a> m &gt;&gt;=
--   (<a>liftIO</a> . f)</pre></li>
--   </ul>
class Monad m => MonadIO (m :: * -> *)

-- | Lift a computation from the <a>IO</a> monad.
liftIO :: MonadIO m => IO a -> m a

-- | Retrieves the monad environment.
ask :: MonadReader r m => m r

-- | 64-bit signed integer type
data Int64 :: *
instance Control.Monad.Reader.Class.MonadReader Database.PostgreSQL.Simple.Internal.Connection Opaleye.Trans.Transaction
instance GHC.Base.Monad Opaleye.Trans.Transaction
instance GHC.Base.Applicative Opaleye.Trans.Transaction
instance GHC.Base.Functor Opaleye.Trans.Transaction
instance GHC.Base.Monad m => Control.Monad.Reader.Class.MonadReader Database.PostgreSQL.Simple.Internal.Connection (Opaleye.Trans.OpaleyeT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Opaleye.Trans.OpaleyeT m)
instance Control.Monad.Trans.Class.MonadTrans Opaleye.Trans.OpaleyeT
instance GHC.Base.Monad m => GHC.Base.Monad (Opaleye.Trans.OpaleyeT m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Opaleye.Trans.OpaleyeT m)
instance GHC.Base.Functor m => GHC.Base.Functor (Opaleye.Trans.OpaleyeT m)
instance Control.Monad.Base.MonadBase b m => Control.Monad.Base.MonadBase b (Opaleye.Trans.OpaleyeT m)
