Remove MonadMask for PostgreSQLTransactionT

Remove the requirement for MonadMask from the MonadTransaction instance
of PostgreSQLTransactionT since it already has a MonadUnliftIO
constraint.
This commit is contained in:
Handré Stolp 2018-06-19 09:01:16 +02:00
parent 5f7a480296
commit 04efd5d7e4
3 changed files with 9 additions and 9 deletions

View File

@ -40,14 +40,13 @@ module Control.Monad.Rel8
) where
import Control.Exception (fromException)
import Control.Monad.Catch (MonadMask, mask, try, throwM)
import Control.Monad.Free.Church (F, liftF, iterM)
import Control.Monad.IO.Class (MonadIO(liftIO))
import Control.Monad.Trans (MonadTrans, lift)
import Control.Monad.Trans.Control (MonadBaseControl)
import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
import Control.Monad.Trans.Reader
import Control.Monad.Trans.Resource (MonadUnliftIO, runResourceT)
import UnliftIO.Exception (throwIO, try, mask)
import Data.Int (Int64)
import qualified Database.PostgreSQL.Simple as Pg
import qualified Database.PostgreSQL.Simple.Transaction as Pg
@ -173,7 +172,7 @@ newtype PostgreSQLTransactionT m a =
PostgreSQLTransactionT (ReaderT Pg.Connection m a)
deriving (Functor,Applicative,Monad)
instance (MonadIO m, MonadUnliftIO m, MonadMask m) =>
instance (MonadIO m, MonadUnliftIO m) =>
MonadTransaction (PostgreSQLTransactionT m) where
liftTransaction =
PostgreSQLTransactionT .
@ -227,7 +226,7 @@ runPostgreSQLTransactions
runPostgreSQLTransactions (PostgreSQLTransactionT r) = runReaderT r
--------------------------------------------------------------------------------
withTransactionModeRetry :: (MonadMask m,MonadIO m)
withTransactionModeRetry :: (MonadIO m, MonadUnliftIO m)
=> Pg.TransactionMode
-> (Pg.SqlError -> Bool)
-> Pg.Connection
@ -249,5 +248,5 @@ withTransactionModeRetry mode shouldRetry conn act =
do liftIO (Pg.rollback conn)
case fmap shouldRetry (fromException e) of
Just True -> retryLoop act'
_ -> throwM e
_ -> throwIO e
Right a -> return a

View File

@ -2,7 +2,7 @@
, exceptions, free, lens, monad-control, mtl, one-liner, opaleye
, postgresql-simple, profunctors, resourcet, scientific, stdenv
, streaming, streaming-postgresql-simple, tagged, text, time
, transformers, uuid, vector
, transformers, unliftio, uuid, vector
}:
mkDerivation {
pname = "rel8";
@ -12,10 +12,10 @@ mkDerivation {
adjunctions aeson base bytestring contravariant exceptions free
lens monad-control mtl one-liner opaleye postgresql-simple
profunctors resourcet scientific streaming
streaming-postgresql-simple tagged text time transformers uuid
vector
streaming-postgresql-simple tagged text time transformers unliftio
uuid vector
];
testHaskellDepends = [ base ];
description = "A type-safe, expressive and concise API for querying relational databases using Opaleye";
description = "A type-safe, expressive and concise API for querying relational databases";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -65,6 +65,7 @@ library
, text
, time
, transformers
, unliftio >= 0.2.7.0 && < 0.3
, uuid
, vector
, lens