opaleye-trans-0.3.2: A monad transformer for Opaleye

Safe HaskellNone
LanguageHaskell2010

Opaleye.Trans

Contents

Synopsis

Documentation

newtype OpaleyeT m a Source

The Opaleye monad transformer

Constructors

OpaleyeT 

runOpaleyeT :: Connection -> OpaleyeT m a -> m a Source

Given a Connection, run an OpaleyeT

Transactions

transaction :: MonadIO m => Transaction a -> OpaleyeT m a Source

Run a postgresql transaction in the OpaleyeT monad

run :: MonadIO m => Transaction a -> OpaleyeT m a Source

Execute a query without a literal transaction

Queries

query :: Default QueryRunner a b => Query a -> Transaction [b] Source

Execute a Query. See runQuery.

queryFirst :: Default QueryRunner a b => Query a -> Transaction (Maybe b) Source

Retrieve the first result from a Query. Similar to listToMaybe $ runQuery.

Inserts

insert :: Table w r -> w -> Transaction Int64 Source

Insert into a Table. See runInsert.

insertMany :: Table w r -> [w] -> Transaction Int64 Source

Insert many records into a Table. See runInsertMany.

insertReturning :: Default QueryRunner a b => Table w r -> (r -> a) -> w -> Transaction [b] Source

Insert a record into a Table with a return value. See runInsertReturning.

insertReturningFirst :: Default QueryRunner a b => Table w r -> (r -> a) -> w -> Transaction (Maybe b) Source

Insert a record into a Table with a return value. Retrieve only the first result. Similar to listToMaybe <$> insertReturning

insertManyReturning :: (MonadIO m, Default QueryRunner a b) => Table w r -> (r -> a) -> [w] -> OpaleyeT m [[b]] Source

Insert many records into a Table with a return value for each record.

Maybe not worth defining. This almost certainly does the wrong thing.

Updates

update :: Table w r -> (r -> w) -> (r -> Column PGBool) -> Transaction Int64 Source

Update items in a Table where the predicate is true. See runUpdate.

updateReturning :: Default QueryRunner returned haskells => Table w r -> (r -> w) -> (r -> Column PGBool) -> (r -> returned) -> Transaction [haskells] Source

Update items in a Table with a return value. See runUpdateReturning.

updateReturningFirst :: Default QueryRunner returned haskells => Table w r -> (r -> w) -> (r -> Column PGBool) -> (r -> returned) -> Transaction (Maybe haskells) Source

Update items in a Table with a return value. Similar to listToMaybe <$> updateReturning.

Utilities

Reexports

liftBase :: MonadBase b m => forall α. b α -> m α

Lift a computation from the base monad

class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase b m | m -> b where

Methods

liftBase :: b α -> m α

Lift a computation from the base monad

Instances

MonadBase [] [] 
MonadBase IO IO 
MonadBase Maybe Maybe 
MonadBase Identity Identity 
MonadBase STM STM 
MonadBase b m => MonadBase b (MaybeT m) 
MonadBase b m => MonadBase b (ListT m) 
MonadBase b m => MonadBase b (IdentityT m) 
MonadBase b m => MonadBase b (OpaleyeT m) 
(Monoid w, MonadBase b m) => MonadBase b (WriterT w m) 
(Monoid w, MonadBase b m) => MonadBase b (WriterT w m) 
MonadBase b m => MonadBase b (StateT s m) 
MonadBase b m => MonadBase b (StateT s m) 
MonadBase b m => MonadBase b (ReaderT r m) 
MonadBase b m => MonadBase b (ExceptT e m) 
(Error e, MonadBase b m) => MonadBase b (ErrorT e m) 
MonadBase b m => MonadBase b (ContT r m) 
(Monoid w, MonadBase b m) => MonadBase b (RWST r w s m) 
(Monoid w, MonadBase b m) => MonadBase b (RWST r w s m) 
MonadBase ((->) r) ((->) r) 
MonadBase (Either e) (Either e) 
MonadBase (ST s) (ST s) 
MonadBase (ST s) (ST s) 

liftIO :: MonadIO m => forall a. IO a -> m a

Lift a computation from the IO monad.

class Monad m => MonadIO m where

Monads in which IO computations may be embedded. Any monad built by applying a sequence of monad transformers to the IO monad will be an instance of this class.

Instances should satisfy the following laws, which state that liftIO is a transformer of monads:

Methods

liftIO :: IO a -> m a

Lift a computation from the IO monad.

Instances

MonadIO IO 
MonadIO m => MonadIO (IdentityT m) 
MonadIO m => MonadIO (ListT m) 
MonadIO m => MonadIO (MaybeT m) 
MonadIO m => MonadIO (OpaleyeT m) 
MonadIO m => MonadIO (ContT r m) 
MonadIO m => MonadIO (ReaderT r m) 
MonadIO m => MonadIO (StateT s m) 
MonadIO m => MonadIO (StateT s m) 
MonadIO m => MonadIO (ExceptT e m) 
(Error e, MonadIO m) => MonadIO (ErrorT e m) 
(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 
(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 

ask :: MonadReader r m => m r

Retrieves the monad environment.