@@ -3,7 +3,9 @@
3 , FlexibleContexts
3 , FlexibleContexts
4 , FlexibleInstances
4 , FlexibleInstances
5 , MultiParamTypeClasses
5 , MultiParamTypeClasses
6 , ScopedTypeVariables
7 , ScopedTypeVariables
7 , UndecidableInstances
9 , UndecidableInstances
@@ -59,3 +61,18 @@ instance MonadBaseControl IO io => MonadPQ schema (PoolPQ schema io) where
59 (result, _ :: Connection schema) <- flip runPQ conn $
61 (result, _ :: Connection schema) <- flip runPQ conn $
61 return result
63 return result
65+-- | A snapshot of the state of a `PoolPQ` computation.
66+type PoolPQRun schema =
67+ forall m x. Monad m => PoolPQ schema m x -> m x
69+-- | Helper function in defining `MonadBaseControl` instance for `PoolPQ`.
70+poolpqliftWith :: Functor m => (PoolPQRun schema -> m a) -> PoolPQ schema m a
71+poolpqliftWith f = PoolPQ $ \ pool ->
72+ (f $ \ pq -> runPoolPQ pq pool)
74+instance MonadBaseControl b m => MonadBaseControl b (PoolPQ schema m) where
75+ type StM (PoolPQ schema m) x = StM m x
77+ poolpqliftWith $ \ run -> liftBaseWith $ \ runInBase -> f $ runInBase . run
78+ restoreM = PoolPQ . const . restoreM