Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype OpaleyeT e m a = OpaleyeT {
- unOpaleyeT :: ExceptT e (OpaleyeT m) a
- runOpaleyeT :: Connection -> OpaleyeT e m a -> m (Either e a)
- data Transaction e a
- transaction :: MonadIO m => Transaction e a -> OpaleyeT e m a
- run :: MonadIO m => Transaction e a -> OpaleyeT e m a
- query :: Default QueryRunner a b => Query a -> Transaction e [b]
- queryFirst :: Default QueryRunner a b => e -> Query a -> Transaction e b
- insert :: Table w r -> w -> Transaction e Int64
- insertMany :: Table w r -> [w] -> Transaction e Int64
- insertReturning :: Default QueryRunner a b => Table w r -> (r -> a) -> w -> Transaction e [b]
- insertReturningFirst :: Default QueryRunner a b => e -> Table w r -> (r -> a) -> w -> Transaction e b
- insertManyReturning :: Default QueryRunner a b => Table w r -> [w] -> (r -> a) -> Transaction e [b]
- update :: Table w r -> (r -> w) -> (r -> Column PGBool) -> Transaction e Int64
- updateReturning :: Default QueryRunner a b => Table w r -> (r -> w) -> (r -> Column PGBool) -> (r -> a) -> Transaction e [b]
- updateReturningFirst :: Default QueryRunner a b => e -> Table w r -> (r -> w) -> (r -> Column PGBool) -> (r -> a) -> Transaction e b
- delete :: Table a b -> (b -> Column PGBool) -> Transaction e Int64
- withExceptOpaleye :: Functor m => (e -> e') -> OpaleyeT e m a -> OpaleyeT e' m a
- withExceptTrans :: (e -> e') -> Transaction e a -> Transaction e' a
- withError :: Monad m => OpaleyeT m (Either e a) -> OpaleyeT e m a
- withoutError :: Monad m => OpaleyeT e m a -> OpaleyeT m (Either e a)
- liftError :: Monad m => (Transaction (Either e a) -> OpaleyeT m (Either r b)) -> Transaction e a -> OpaleyeT r m b
- withTrans :: Transaction a -> Transaction e a
- maybeError :: Transaction (Maybe b) -> e -> Transaction e b
- liftIO :: MonadIO m => IO a -> m a
- class Monad m => MonadIO (m :: Type -> Type)
- ask :: MonadReader r m => m r
- data Int64
- throwError :: MonadError e m => e -> m a
- catchError :: MonadError e m => m a -> (e -> m a) -> m a
Documentation
newtype OpaleyeT e m a Source #
OpaleyeT | |
|
Instances
Monad m => MonadReader Connection (OpaleyeT e m) Source # | |
Defined in Opaleye.Trans.Exception ask :: OpaleyeT e m Connection # local :: (Connection -> Connection) -> OpaleyeT e m a -> OpaleyeT e m a # reader :: (Connection -> a) -> OpaleyeT e m a # | |
Monad m => MonadError e (OpaleyeT e m) Source # | |
Defined in Opaleye.Trans.Exception throwError :: e -> OpaleyeT e m a # catchError :: OpaleyeT e m a -> (e -> OpaleyeT e m a) -> OpaleyeT e m a # | |
MonadTrans (OpaleyeT e) Source # | |
Defined in Opaleye.Trans.Exception | |
Monad m => Monad (OpaleyeT e m) Source # | |
Functor m => Functor (OpaleyeT e m) Source # | |
Monad m => Applicative (OpaleyeT e m) Source # | |
Defined in Opaleye.Trans.Exception | |
MonadIO m => MonadIO (OpaleyeT e m) Source # | |
Defined in Opaleye.Trans.Exception | |
MonadThrow m => MonadThrow (OpaleyeT e m) Source # | |
Defined in Opaleye.Trans.Exception | |
MonadCatch m => MonadCatch (OpaleyeT e m) Source # | |
runOpaleyeT :: Connection -> OpaleyeT e m a -> m (Either e a) Source #
Given a Connection
, run an OpaleyeT
Transactions
data Transaction e a Source #
Just like Transaction
only with exception handling
Instances
transaction :: MonadIO m => Transaction e a -> OpaleyeT e m a Source #
Run a postgresql transaction in the OpaleyeT
monad
run :: MonadIO m => Transaction e a -> OpaleyeT e m a Source #
Execute a query without a literal transaction
Queries
query :: Default QueryRunner a b => Query a -> Transaction e [b] Source #
queryFirst :: Default QueryRunner a b => e -> Query a -> Transaction e b Source #
Inserts
insertMany :: Table w r -> [w] -> Transaction e Int64 Source #
Insert many records into a Table
. See runInsertMany
.
insertReturning :: Default QueryRunner a b => Table w r -> (r -> a) -> w -> Transaction e [b] Source #
Insert a record into a Table
with a return value. See runInsertReturning
.
insertReturningFirst :: Default QueryRunner a b => e -> Table w r -> (r -> a) -> w -> Transaction e b Source #
Insert a record into a Table
with a return value. Retrieve only the first result.
Similar to listToMaybe
<$>
insertReturning
insertManyReturning :: Default QueryRunner a b => Table w r -> [w] -> (r -> a) -> Transaction e [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
updateReturning :: Default QueryRunner a b => Table w r -> (r -> w) -> (r -> Column PGBool) -> (r -> a) -> Transaction e [b] Source #
Update items in a Table
with a return value. See runUpdateReturning
.
updateReturningFirst :: Default QueryRunner a b => e -> Table w r -> (r -> w) -> (r -> Column PGBool) -> (r -> a) -> Transaction e b Source #
Update items in a Table
with a return value. Similar to
.listToMaybe
<$>
updateReturning
Deletes
Exceptions
withExceptTrans :: (e -> e') -> Transaction e a -> Transaction e' a Source #
Utilities
liftError :: Monad m => (Transaction (Either e a) -> OpaleyeT m (Either r b)) -> Transaction e a -> OpaleyeT r m b Source #
withTrans :: Transaction a -> Transaction e a Source #
maybeError :: Transaction (Maybe b) -> e -> Transaction e b Source #
Reexports
class Monad m => MonadIO (m :: Type -> Type) #
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:
Instances
ask :: MonadReader r m => m r #
Retrieves the monad environment.
64-bit signed integer type
Instances
throwError :: MonadError e m => e -> m a #
Is used within a monadic computation to begin exception processing.
catchError :: MonadError e m => m a -> (e -> m a) -> m a #
A handler function to handle previous errors and return to normal execution. A common idiom is:
do { action1; action2; action3 } `catchError` handler
where the action
functions can call throwError
.
Note that handler
and the do-block must have the same return type.