opaleye-trans-0.5.2: A monad transformer for Opaleye
Safe HaskellNone
LanguageHaskell2010

Opaleye.Trans.Exception

Synopsis

Documentation

newtype OpaleyeT e m a Source #

Constructors

OpaleyeT 

Fields

Instances

Instances details
Monad m => MonadReader Connection (OpaleyeT e m) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

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 # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

throwError :: e -> OpaleyeT e m a #

catchError :: OpaleyeT e m a -> (e -> OpaleyeT e m a) -> OpaleyeT e m a #

MonadTrans (OpaleyeT e) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

lift :: Monad m => m a -> OpaleyeT e m a #

Monad m => Monad (OpaleyeT e m) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

(>>=) :: OpaleyeT e m a -> (a -> OpaleyeT e m b) -> OpaleyeT e m b #

(>>) :: OpaleyeT e m a -> OpaleyeT e m b -> OpaleyeT e m b #

return :: a -> OpaleyeT e m a #

Functor m => Functor (OpaleyeT e m) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

fmap :: (a -> b) -> OpaleyeT e m a -> OpaleyeT e m b #

(<$) :: a -> OpaleyeT e m b -> OpaleyeT e m a #

Monad m => Applicative (OpaleyeT e m) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

pure :: a -> OpaleyeT e m a #

(<*>) :: OpaleyeT e m (a -> b) -> OpaleyeT e m a -> OpaleyeT e m b #

liftA2 :: (a -> b -> c) -> OpaleyeT e m a -> OpaleyeT e m b -> OpaleyeT e m c #

(*>) :: OpaleyeT e m a -> OpaleyeT e m b -> OpaleyeT e m b #

(<*) :: OpaleyeT e m a -> OpaleyeT e m b -> OpaleyeT e m a #

MonadIO m => MonadIO (OpaleyeT e m) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

liftIO :: IO a -> OpaleyeT e m a #

MonadThrow m => MonadThrow (OpaleyeT e m) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

throwM :: Exception e0 => e0 -> OpaleyeT e m a #

MonadCatch m => MonadCatch (OpaleyeT e m) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

catch :: Exception e0 => OpaleyeT e m a -> (e0 -> OpaleyeT e m a) -> OpaleyeT e m a #

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

Instances details
MonadReader Connection (Transaction e) Source # 
Instance details

Defined in Opaleye.Trans.Exception

MonadError e (Transaction e) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

throwError :: e -> Transaction e a #

catchError :: Transaction e a -> (e -> Transaction e a) -> Transaction e a #

Monad (Transaction e) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

(>>=) :: Transaction e a -> (a -> Transaction e b) -> Transaction e b #

(>>) :: Transaction e a -> Transaction e b -> Transaction e b #

return :: a -> Transaction e a #

Functor (Transaction e) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

fmap :: (a -> b) -> Transaction e a -> Transaction e b #

(<$) :: a -> Transaction e b -> Transaction e a #

Applicative (Transaction e) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

pure :: a -> Transaction e a #

(<*>) :: Transaction e (a -> b) -> Transaction e a -> Transaction e b #

liftA2 :: (a -> b -> c) -> Transaction e a -> Transaction e b -> Transaction e c #

(*>) :: Transaction e a -> Transaction e b -> Transaction e b #

(<*) :: Transaction e a -> Transaction e b -> Transaction e a #

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 #

Execute a Query. See runQuery.

queryFirst :: Default QueryRunner a b => e -> Query a -> Transaction e b Source #

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

Inserts

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

Insert into a Table. See runInsert.

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

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

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

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

delete :: Table a b -> (b -> Column PGBool) -> Transaction e Int64 Source #

Delete items in a Table that satisfy some boolean predicate. See runDelete.

Exceptions

withExceptOpaleye :: Functor m => (e -> e') -> OpaleyeT e m a -> OpaleyeT e' m a Source #

withExceptTrans :: (e -> e') -> Transaction e a -> Transaction e' a Source #

Utilities

withError :: Monad m => OpaleyeT m (Either e a) -> OpaleyeT e m a Source #

withoutError :: Monad m => OpaleyeT e m a -> OpaleyeT m (Either e a) Source #

liftError :: Monad m => (Transaction (Either e a) -> OpaleyeT m (Either r b)) -> Transaction e a -> OpaleyeT r m b Source #

Reexports

liftIO :: MonadIO m => IO a -> m a #

Lift a computation from the IO monad.

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:

Minimal complete definition

liftIO

Instances

Instances details
MonadIO IO

Since: base-4.9.0.0

Instance details

Defined in Control.Monad.IO.Class

Methods

liftIO :: IO a -> IO a #

MonadIO Q 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

liftIO :: IO a -> Q a #

MonadIO m => MonadIO (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftIO :: IO a -> MaybeT m a #

MonadIO m => MonadIO (ListT m) 
Instance details

Defined in Control.Monad.Trans.List

Methods

liftIO :: IO a -> ListT m a #

MonadIO m => MonadIO (OpaleyeT m) Source # 
Instance details

Defined in Opaleye.Trans

Methods

liftIO :: IO a -> OpaleyeT m a #

MonadIO m => MonadIO (IdentityT m) 
Instance details

Defined in Control.Monad.Trans.Identity

Methods

liftIO :: IO a -> IdentityT m a #

MonadIO m => MonadIO (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftIO :: IO a -> ExceptT e m a #

(Error e, MonadIO m) => MonadIO (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Error

Methods

liftIO :: IO a -> ErrorT e m a #

MonadIO m => MonadIO (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

liftIO :: IO a -> ReaderT r m a #

MonadIO m => MonadIO (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

liftIO :: IO a -> StateT s m a #

MonadIO m => MonadIO (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Strict

Methods

liftIO :: IO a -> StateT s m a #

(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Lazy

Methods

liftIO :: IO a -> WriterT w m a #

(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Strict

Methods

liftIO :: IO a -> WriterT w m a #

MonadIO m => MonadIO (OpaleyeT e m) Source # 
Instance details

Defined in Opaleye.Trans.Exception

Methods

liftIO :: IO a -> OpaleyeT e m a #

MonadIO m => MonadIO (ContT r m) 
Instance details

Defined in Control.Monad.Trans.Cont

Methods

liftIO :: IO a -> ContT r m a #

(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.RWS.Lazy

Methods

liftIO :: IO a -> RWST r w s m a #

(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.RWS.Strict

Methods

liftIO :: IO a -> RWST r w s m a #

ask :: MonadReader r m => m r #

Retrieves the monad environment.

data Int64 #

64-bit signed integer type

Instances

Instances details
Bounded Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Enum Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Eq Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Methods

(==) :: Int64 -> Int64 -> Bool #

(/=) :: Int64 -> Int64 -> Bool #

Integral Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Num Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Ord Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Methods

compare :: Int64 -> Int64 -> Ordering #

(<) :: Int64 -> Int64 -> Bool #

(<=) :: Int64 -> Int64 -> Bool #

(>) :: Int64 -> Int64 -> Bool #

(>=) :: Int64 -> Int64 -> Bool #

max :: Int64 -> Int64 -> Int64 #

min :: Int64 -> Int64 -> Int64 #

Read Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Real Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Methods

toRational :: Int64 -> Rational #

Show Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Methods

showsPrec :: Int -> Int64 -> ShowS #

show :: Int64 -> String #

showList :: [Int64] -> ShowS #

Ix Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Bits Int64

Since: base-2.1

Instance details

Defined in GHC.Int

FiniteBits Int64

Since: base-4.6.0.0

Instance details

Defined in GHC.Int

Lift Int64 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Int64 -> Q Exp #

liftTyped :: Int64 -> Q (TExp Int64) #

DefaultFromField SqlInt8 Int64 
Instance details

Defined in Opaleye.Internal.RunQuery

Default ToFields Int64 (Column SqlInt8) 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange Int64) (Column (SqlRange SqlInt8)) 
Instance details

Defined in Opaleye.Internal.Constant

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.