on master help sign in
Add `MonadHTTP` instances for `transformers`
e30728fGabriella Gonzalez
CHANGELOG.md+4
@@ -1,3 +1,7 @@
1+## Req 3.9.3
2+
3+* Add `MonadHttp` instances for `transformers` types.
4+
1## Req 3.9.2
5## Req 3.9.2
2
6
3* The test suite works with `aeson-2.x.x.x`.
7* The test suite works with `aeson-2.x.x.x`.
Network/HTTP/Req.hs+89
@@ -220,7 +220,21 @@ import Control.Monad.Catch (Handler (..), MonadCatch, MonadMask, MonadThrow)
220import Control.Monad.IO.Class
220import Control.Monad.IO.Class
221import Control.Monad.IO.Unlift
221import Control.Monad.IO.Unlift
222import Control.Monad.Reader
222import Control.Monad.Reader
223+import Control.Monad.Trans.Accum (AccumT)
224+import Control.Monad.Trans.Cont (ContT)
223import Control.Monad.Trans.Control
225import Control.Monad.Trans.Control
226+import Control.Monad.Trans.Except (ExceptT)
227+import Control.Monad.Trans.Identity (IdentityT)
228+import Control.Monad.Trans.Maybe (MaybeT)
229+import qualified Control.Monad.Trans.RWS.CPS as RWS.CPS
230+import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
231+import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
232+import Control.Monad.Trans.Select (SelectT)
233+import qualified Control.Monad.Trans.State.Lazy as State.Lazy
234+import qualified Control.Monad.Trans.State.Strict as State.Strict
235+import qualified Control.Monad.Trans.Writer.CPS as Writer.CPS
236+import qualified Control.Monad.Trans.Writer.Lazy as Writer.Lazy
237+import qualified Control.Monad.Trans.Writer.Strict as Writer.Strict
224import Control.Retry
238import Control.Retry
225import Data.Aeson (FromJSON (..), ToJSON (..))
239import Data.Aeson (FromJSON (..), ToJSON (..))
226import qualified Data.Aeson as A
240import qualified Data.Aeson as A
@@ -787,6 +801,81 @@ instance MonadHttp Req where
787 handleHttpException = Req . lift . throwIO
801 handleHttpException = Req . lift . throwIO
788 getHttpConfig = Req ask
802 getHttpConfig = Req ask
789
803
804+-- | @since 3.9.3
805+instance (MonadHttp m, Monoid w) => MonadHttp (AccumT w m) where
806+ handleHttpException = lift . handleHttpException
807+ getHttpConfig = lift getHttpConfig
808+
809+-- | @since 3.9.3
810+instance MonadHttp m => MonadHttp (ContT r m) where
811+ handleHttpException = lift . handleHttpException
812+ getHttpConfig = lift getHttpConfig
813+
814+-- | @since 3.9.3
815+instance MonadHttp m => MonadHttp (ExceptT e m) where
816+ handleHttpException = lift . handleHttpException
817+ getHttpConfig = lift getHttpConfig
818+
819+-- | @since 3.9.3
820+instance MonadHttp m => MonadHttp (IdentityT m) where
821+ handleHttpException = lift . handleHttpException
822+ getHttpConfig = lift getHttpConfig
823+
824+-- | @since 3.9.3
825+instance MonadHttp m => MonadHttp (MaybeT m) where
826+ handleHttpException = lift . handleHttpException
827+ getHttpConfig = lift getHttpConfig
828+
829+-- | @since 3.9.3
830+instance MonadHttp m => MonadHttp (ReaderT r m) where
831+ handleHttpException = lift . handleHttpException
832+ getHttpConfig = lift getHttpConfig
833+
834+-- | @since 3.9.3
835+instance (MonadHttp m, Monoid w) => MonadHttp (RWS.CPS.RWST r w s m) where
836+ handleHttpException = lift . handleHttpException
837+ getHttpConfig = lift getHttpConfig
838+
839+-- | @since 3.9.3
840+instance (MonadHttp m, Monoid w) => MonadHttp (RWS.Lazy.RWST r w s m) where
841+ handleHttpException = lift . handleHttpException
842+ getHttpConfig = lift getHttpConfig
843+
844+-- | @since 3.9.3
845+instance (MonadHttp m, Monoid w) => MonadHttp (RWS.Strict.RWST r w s m) where
846+ handleHttpException = lift . handleHttpException
847+ getHttpConfig = lift getHttpConfig
848+
849+-- | @since 3.9.3
850+instance MonadHttp m => MonadHttp (SelectT r m) where
851+ handleHttpException = lift . handleHttpException
852+ getHttpConfig = lift getHttpConfig
853+
854+-- | @since 3.9.3
855+instance MonadHttp m => MonadHttp (State.Lazy.StateT s m) where
856+ handleHttpException = lift . handleHttpException
857+ getHttpConfig = lift getHttpConfig
858+
859+-- | @since 3.9.3
860+instance MonadHttp m => MonadHttp (State.Strict.StateT s m) where
861+ handleHttpException = lift . handleHttpException
862+ getHttpConfig = lift getHttpConfig
863+
864+-- | @since 3.9.3
865+instance (MonadHttp m, Monoid w) => MonadHttp (Writer.CPS.WriterT w m) where
866+ handleHttpException = lift . handleHttpException
867+ getHttpConfig = lift getHttpConfig
868+
869+-- | @since 3.9.3
870+instance (MonadHttp m, Monoid w) => MonadHttp (Writer.Lazy.WriterT w m) where
871+ handleHttpException = lift . handleHttpException
872+ getHttpConfig = lift getHttpConfig
873+
874+-- | @since 3.9.3
875+instance (MonadHttp m, Monoid w) => MonadHttp (Writer.Strict.WriterT w m) where
876+ handleHttpException = lift . handleHttpException
877+ getHttpConfig = lift getHttpConfig
878+
790-- | Run a computation in the 'Req' monad with the given 'HttpConfig'. In
879-- | Run a computation in the 'Req' monad with the given 'HttpConfig'. In
791-- the case of an exceptional situation an 'HttpException' will be thrown.
880-- the case of an exceptional situation an 'HttpException' will be thrown.
792--
881--
req.cabal+1−1
@@ -52,7 +52,7 @@ library
52 template-haskell >=2.14 && <2.18,
52 template-haskell >=2.14 && <2.18,
53 text >=0.2 && <1.3,
53 text >=0.2 && <1.3,
54 time >=1.2 && <1.13,
54 time >=1.2 && <1.13,
55− transformers >=0.4 && <0.6,
55+ transformers >=0.5.3.0 && <0.6,
56 transformers-base,
56 transformers-base,
57 unliftio-core >=0.1.1 && <0.3
57 unliftio-core >=0.1.1 && <0.3
58
58