on master help sign in
Derive ‘MonadThrow’, ‘MonadCatch’, and ‘MonadMask’ for ‘Req’
8c7a8a8Mark Karpov
CHANGELOG.md+2
@@ -3,6 +3,8 @@
3* Added `reqCb`, a function that allows you to modify the `Request` object
3* Added `reqCb`, a function that allows you to modify the `Request` object
4 but otherwise performs the requst for you.
4 but otherwise performs the requst for you.
5
5
6+* Derived `MonadThrow`, `MonadCatch`, and `MonadMask` for the `Req` monad.
7+
6## Req 3.6.0
8## Req 3.6.0
7
9
8* Added the `httpConfigBodyPreviewLength` configuration parameter to
10* Added the `httpConfigBodyPreviewLength` configuration parameter to
Network/HTTP/Req.hs+11−1
@@ -14,6 +14,7 @@
14{-# LANGUAGE RecordWildCards #-}
14{-# LANGUAGE RecordWildCards #-}
15{-# LANGUAGE RoleAnnotations #-}
15{-# LANGUAGE RoleAnnotations #-}
16{-# LANGUAGE ScopedTypeVariables #-}
16{-# LANGUAGE ScopedTypeVariables #-}
17+{-# LANGUAGE StandaloneDeriving #-}
17{-# LANGUAGE TemplateHaskellQuotes #-}
18{-# LANGUAGE TemplateHaskellQuotes #-}
18{-# LANGUAGE TypeFamilies #-}
19{-# LANGUAGE TypeFamilies #-}
19{-# LANGUAGE UndecidableInstances #-}
20{-# LANGUAGE UndecidableInstances #-}
@@ -236,7 +237,7 @@ import Control.Applicative
236import Control.Arrow (first, second)
237import Control.Arrow (first, second)
237import Control.Exception hiding (Handler (..), TypeError)
238import Control.Exception hiding (Handler (..), TypeError)
238import Control.Monad.Base
239import Control.Monad.Base
239−import Control.Monad.Catch (Handler (..))
240+import Control.Monad.Catch (Handler (..), MonadCatch, MonadMask, MonadThrow)
240import Control.Monad.IO.Class
241import Control.Monad.IO.Class
241import Control.Monad.IO.Unlift
242import Control.Monad.IO.Unlift
242import Control.Monad.Reader
243import Control.Monad.Reader
@@ -776,6 +777,15 @@ newtype Req a = Req (ReaderT HttpConfig IO a)
776 MonadUnliftIO
777 MonadUnliftIO
777 )
778 )
778
779
780+-- | @since 3.7.0
781+deriving instance MonadThrow Req
782+
783+-- | @since 3.7.0
784+deriving instance MonadCatch Req
785+
786+-- | @since 3.7.0
787+deriving instance MonadMask Req
788+
779instance MonadBase IO Req where
789instance MonadBase IO Req where
780 liftBase = liftIO
790 liftBase = liftIO
781
791