Relax the dependency on "monad-control"

This commit is contained in:
Nikita Volkov 2014-12-29 15:42:53 +03:00
parent 6c2f78a122
commit 3f996b8b0a
4 changed files with 38 additions and 9 deletions

View File

@ -30,6 +30,7 @@ install:
then then
constraint_options=( constraint_options=(
"--constraint=transformers==0.3.*" "--constraint=transformers==0.3.*"
"--constraint=monad-control==0.3.*"
"--constraint=text==1.0.*" "--constraint=text==1.0.*"
"--constraint=attoparsec==0.10.*" "--constraint=attoparsec==0.10.*"
"--constraint=time==1.4.*" "--constraint=time==1.4.*"

View File

@ -1,3 +1,6 @@
# 0.7.1
* Relaxed the dependency on "monad-control"
# 0.7.0 - Refinements and minor updates # 0.7.0 - Refinements and minor updates
* Streaming now is parameterized by the size of a chunk * Streaming now is parameterized by the size of a chunk
* Introduced a new type `Ex` * Introduced a new type `Ex`

View File

@ -1,7 +1,7 @@
name: name:
hasql hasql
version: version:
0.7.0 0.7.1
synopsis: synopsis:
A minimalistic general high level API for relational databases A minimalistic general high level API for relational databases
description: description:
@ -109,7 +109,7 @@ library
list-t >= 0.3.1 && < 0.5, list-t >= 0.3.1 && < 0.5,
mmorph == 1.0.*, mmorph == 1.0.*,
mtl >= 2.1 && < 2.3, mtl >= 2.1 && < 2.3,
monad-control == 1.0.*, monad-control >= 0.3 && < 1.1,
transformers-base == 0.4.*, transformers-base == 0.4.*,
transformers >= 0.3 && < 0.5, transformers >= 0.3 && < 0.5,
base-prelude >= 0.1.3 && < 0.2, base-prelude >= 0.1.3 && < 0.2,

View File

@ -1,4 +1,4 @@
{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableInstances, CPP #-}
-- | -- |
-- This is the API of the \"hasql\" library. -- This is the API of the \"hasql\" library.
-- For an introduction to the package -- For an introduction to the package
@ -161,6 +161,16 @@ newtype Session c m r =
instance MonadTrans (Session c) where instance MonadTrans (Session c) where
lift = Session . lift . lift lift = Session . lift . lift
deriving instance MonadBase IO m => MonadBase IO (Session c m)
instance MFunctor (Session c) where
hoist f (Session m) =
Session $ ReaderT $ \e ->
EitherT $ f $ runEitherT $ flip runReaderT e $ m
#if MIN_VERSION_monad_control(1,0,0)
instance MonadTransControl (Session c) where instance MonadTransControl (Session c) where
type StT (Session c) a = Either (SessionError c) a type StT (Session c) a = Either (SessionError c) a
liftWith onUnlift = liftWith onUnlift =
@ -170,17 +180,32 @@ instance MonadTransControl (Session c) where
restoreT = restoreT =
Session . ReaderT . const . EitherT Session . ReaderT . const . EitherT
deriving instance MonadBase IO m => MonadBase IO (Session c m)
instance (MonadBaseControl IO m) => MonadBaseControl IO (Session c m) where instance (MonadBaseControl IO m) => MonadBaseControl IO (Session c m) where
type StM (Session c m) a = ComposeSt (Session c) m a type StM (Session c m) a = ComposeSt (Session c) m a
liftBaseWith = defaultLiftBaseWith liftBaseWith = defaultLiftBaseWith
restoreM = defaultRestoreM restoreM = defaultRestoreM
instance MFunctor (Session c) where #else
hoist f (Session m) =
Session $ ReaderT $ \e -> instance MonadTransControl (Session c) where
EitherT $ f $ runEitherT $ flip runReaderT e $ m newtype StT (Session c) a =
SessionStT (Either (SessionError c) a)
liftWith onUnlift =
Session $ ReaderT $ \e ->
lift $ onUnlift $ \(Session m) ->
liftM SessionStT $ runEitherT $ flip runReaderT e $ m
restoreT =
Session . ReaderT . const . EitherT . liftM (\(SessionStT a) -> a)
instance (MonadBaseControl IO m) => MonadBaseControl IO (Session c m) where
newtype StM (Session c m) a =
SessionStM (ComposeSt (Session c) m a)
liftBaseWith =
defaultLiftBaseWith SessionStM
restoreM =
defaultRestoreM $ \(SessionStM a) -> a
#endif
-- | -- |
-- Execute a session using an established connection pool. -- Execute a session using an established connection pool.