| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Opaleye.Trans.Exception
- 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 => forall a. IO a -> m a
- class Monad m => MonadIO m where
- ask :: MonadReader r m => m r
- data Int64 :: *
- throwError :: MonadError e m => forall a. e -> m a
- catchError :: MonadError e m => forall a. m a -> (e -> m a) -> m a
Documentation
newtype OpaleyeT e m a Source #
Constructors
| OpaleyeT | |
Fields
| |
Instances
| Monad m => MonadError e (OpaleyeT e m) Source # | |
| Monad m => MonadReader Connection (OpaleyeT e m) Source # | |
| MonadTrans (OpaleyeT e) Source # | |
| Monad m => Monad (OpaleyeT e m) Source # | |
| Functor m => Functor (OpaleyeT e m) Source # | |
| Monad m => Applicative (OpaleyeT e m) Source # | |
| MonadIO m => MonadIO (OpaleyeT e m) Source # | |
| MonadThrow m => MonadThrow (OpaleyeT e m) Source # | |
| 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
| MonadError e (Transaction e) Source # | |
| MonadReader Connection (Transaction e) Source # | |
| Monad (Transaction e) Source # | |
| Functor (Transaction e) Source # | |
| Applicative (Transaction e) Source # | |
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 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:
Minimal complete definition
Instances
| MonadIO IO | |
| MonadIO m => MonadIO (ListT m) | |
| MonadIO m => MonadIO (MaybeT m) | |
| MonadIO m => MonadIO (OpaleyeT m) # | |
| MonadIO m => MonadIO (IdentityT * m) | |
| (Error e, MonadIO m) => MonadIO (ErrorT e m) | |
| MonadIO m => MonadIO (ExceptT e m) | |
| MonadIO m => MonadIO (StateT s m) | |
| MonadIO m => MonadIO (StateT s m) | |
| (Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
| (Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
| MonadIO m => MonadIO (OpaleyeT e m) # | |
| MonadIO m => MonadIO (ContT * r m) | |
| MonadIO m => MonadIO (ReaderT * r 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.
64-bit signed integer type
throwError :: MonadError e m => forall a. e -> m a #
Is used within a monadic computation to begin exception processing.
catchError :: MonadError e m => forall a. 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` handlerwhere the action functions can call throwError.
Note that handler and the do-block must have the same return type.