@@ -1,9 +1,20 @@
1+{-# LANGUAGE BangPatterns #-}
2+{-# LANGUAGE CPP #-}
13{-# LANGUAGE DataKinds #-}
4+{-# LANGUAGE DeriveDataTypeable #-}
5+{-# LANGUAGE DeriveGeneric #-}
6+{-# LANGUAGE DeriveLift #-}
7+{-# LANGUAGE FlexibleInstances #-}
8+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
29{-# LANGUAGE LambdaCase #-}
10+{-# LANGUAGE MultiParamTypeClasses #-}
311{-# LANGUAGE OverloadedStrings #-}
412{-# LANGUAGE QuasiQuotes #-}
13+{-# LANGUAGE RankNTypes #-}
514{-# LANGUAGE RecordWildCards #-}
615{-# LANGUAGE RoleAnnotations #-}
16+{-# LANGUAGE ScopedTypeVariables #-}
17+{-# LANGUAGE StandaloneDeriving #-}
718{-# LANGUAGE TemplateHaskellQuotes #-}
819{-# LANGUAGE TypeFamilies #-}
920{-# LANGUAGE UndecidableInstances #-}
@@ -144,13 +155,11 @@ module Network.HTTP.Req
144155 -- $query-parameters
145156 (=:),
146157 queryFlag,
147− formToQuery,
148158 QueryParam (..),
149159
150160 -- *** Headers
151161 header,
152162 attachHeader,
153− headerRedacted,
154163
155164 -- *** Cookies
156165 -- $cookies
@@ -197,78 +206,72 @@ module Network.HTTP.Req
197206
198207 -- * Other
199208 HttpException (..),
200− isStatusCodeException,
201209 CanHaveBody (..),
202210 Scheme (..),
203211 )
204212where
205213
206−import Blaze.ByteString.Builder qualified as BB
214+import qualified Blaze.ByteString.Builder as BB
207215import Control.Applicative
208216import Control.Arrow (first, second)
209217import Control.Exception hiding (Handler (..), TypeError)
210−import Control.Monad (guard, void, (>=>))
211218import Control.Monad.Base
212219import Control.Monad.Catch (Handler (..), MonadCatch, MonadMask, MonadThrow)
213220import Control.Monad.IO.Class
214221import Control.Monad.IO.Unlift
215−import Control.Monad.Reader (ReaderT (ReaderT), ask, lift, runReaderT)
222+import Control.Monad.Reader
216223import Control.Monad.Trans.Accum (AccumT)
217224import Control.Monad.Trans.Cont (ContT)
218225import Control.Monad.Trans.Control
219226import Control.Monad.Trans.Except (ExceptT)
220227import Control.Monad.Trans.Identity (IdentityT)
221228import Control.Monad.Trans.Maybe (MaybeT)
222−import Control.Monad.Trans.RWS.CPS qualified as RWS.CPS
223−import Control.Monad.Trans.RWS.Lazy qualified as RWS.Lazy
224−import Control.Monad.Trans.RWS.Strict qualified as RWS.Strict
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
225232import Control.Monad.Trans.Select (SelectT)
226−import Control.Monad.Trans.State.Lazy qualified as State.Lazy
227−import Control.Monad.Trans.State.Strict qualified as State.Strict
228−import Control.Monad.Trans.Writer.CPS qualified as Writer.CPS
229−import Control.Monad.Trans.Writer.Lazy qualified as Writer.Lazy
230−import Control.Monad.Trans.Writer.Strict qualified as Writer.Strict
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
231238import Control.Retry
232239import Data.Aeson (FromJSON (..), ToJSON (..))
233−import Data.Aeson qualified as A
240+import qualified Data.Aeson as A
234241import Data.ByteString (ByteString)
235−import Data.ByteString qualified as B
236−import Data.ByteString.Lazy qualified as BL
237−import Data.CaseInsensitive qualified as CI
242+import qualified Data.ByteString as B
243+import qualified Data.ByteString.Lazy as BL
244+import qualified Data.CaseInsensitive as CI
238245import Data.Data (Data)
239−import Data.Default.Class (def)
240246import Data.Function (on)
241247import Data.IORef
242248import Data.Kind (Constraint, Type)
243249import Data.List (foldl', nubBy)
244250import Data.List.NonEmpty (NonEmpty (..))
245−import Data.List.NonEmpty qualified as NE
251+import qualified Data.List.NonEmpty as NE
246252import Data.Maybe (fromMaybe)
247253import Data.Proxy
248254import Data.Semigroup (Endo (..))
249−import Data.Set qualified as S
250255import Data.Text (Text)
251−import Data.Text qualified as T
252−import Data.Text.Encoding qualified as T
256+import qualified Data.Text as T
257+import qualified Data.Text.Encoding as T
253258import Data.Typeable (Typeable, cast)
254259import GHC.Generics
255260import GHC.TypeLits
256−import Language.Haskell.TH qualified as TH
257−import Language.Haskell.TH.Quote qualified as TH
258−import Language.Haskell.TH.Syntax qualified as TH
259−import Network.Connection qualified as NC
260−import Network.HTTP.Client qualified as L
261−import Network.HTTP.Client.Internal qualified as LI
262−import Network.HTTP.Client.MultipartFormData qualified as LM
263−import Network.HTTP.Client.TLS qualified as L
264−import Network.HTTP.Types qualified as Y
261+import qualified Language.Haskell.TH as TH
262+import qualified Language.Haskell.TH.Quote as TH
263+import qualified Language.Haskell.TH.Syntax as TH
264+import qualified Network.Connection as NC
265+import qualified Network.HTTP.Client as L
266+import qualified Network.HTTP.Client.Internal as LI
267+import qualified Network.HTTP.Client.MultipartFormData as LM
268+import qualified Network.HTTP.Client.TLS as L
269+import qualified Network.HTTP.Types as Y
265270import System.IO.Unsafe (unsafePerformIO)
266271import Text.URI (URI)
267−import Text.URI qualified as URI
268−import Text.URI.QQ qualified as QQ
269−import Web.Authenticate.OAuth qualified as OAuth
270−import Web.FormUrlEncoded (FromForm (..), ToForm (..))
271−import Web.FormUrlEncoded qualified as Form
272+import qualified Text.URI as URI
273+import qualified Text.URI.QQ as QQ
274+import qualified Web.Authenticate.OAuth as OAuth
272275import Web.HttpApiData (ToHttpApiData (..))
273276
274277----------------------------------------------------------------------------
@@ -489,7 +492,7 @@ reqCb method url body responseProxy options adjustRequest =
489492--
490493-- @since 3.7.0
491494reqHandler ::
492− (MonadHttp m) =>
495+ MonadHttp m =>
493496 -- | How to get final result from a 'L.Response'
494497 (L.Response L.BodyReader -> IO b) ->
495498 -- | 'L.Request' to perform
@@ -585,10 +588,10 @@ req' method url body options m = do
585588 withReqManager (m request)
586589
587590-- | Perform an action using the global implicit 'L.Manager' that the rest
588−-- of the library uses. This allows us to reuse connections that the
591+-- of the library uses. This allows to reuse connections that the
589592-- 'L.Manager' controls.
590−withReqManager :: (MonadIO m) => (L.Manager -> m a) -> m a
591−withReqManager m = m globalManager
593+withReqManager :: MonadIO m => (L.Manager -> m a) -> m a
594+withReqManager m = liftIO (readIORef globalManager) >>= m
592595
593596-- | The global 'L.Manager' that 'req' uses. Here we just go with the
594597-- default settings, so users don't need to deal with this manager stuff at
@@ -601,16 +604,16 @@ withReqManager m = m globalManager
601604-- manager. From that moment on the 'IORef' will be just reused—exactly the
602605-- behavior we want here in order to maximize connection sharing. GHC could
603606-- spoil the plan by inlining the definition, hence the @NOINLINE@ pragma.
604−globalManager :: L.Manager
607+globalManager :: IORef L.Manager
605608globalManager = unsafePerformIO $ do
606609 context <- NC.initConnectionContext
607610 let settings =
608611 L.mkManagerSettingsContext
609612 (Just context)
610− def
613+ (NC.TLSSettingsSimple False False False)
611614 Nothing
612615 manager <- L.newManager settings
613− return manager
616+ newIORef manager
614617{-# NOINLINE globalManager #-}
615618
616619----------------------------------------------------------------------------
@@ -630,7 +633,7 @@ globalManager = unsafePerformIO $ do
630633-- | A type class for monads that support performing HTTP requests.
631634-- Typically, you only need to define the 'handleHttpException' method
632635-- unless you want to tweak 'HttpConfig'.
633−class (MonadIO m) => MonadHttp m where
636+class MonadIO m => MonadHttp m where
634637 -- | This method describes how to deal with 'HttpException' that was
635638 -- caught by the library. One option is to re-throw it if you are OK with
636639 -- exceptions, but if you prefer working with something like
@@ -714,8 +717,9 @@ data HttpConfig = HttpConfig
714717 -- | Max length of preview fragment of response body.
715718 --
716719 -- @since 3.6.0
717− httpConfigBodyPreviewLength :: forall a. (Num a) => a
720+ httpConfigBodyPreviewLength :: forall a. Num a => a
718721 }
722+ deriving (Typeable)
719723
720724-- | The default value of 'HttpConfig'.
721725--
@@ -803,27 +807,27 @@ instance (MonadHttp m, Monoid w) => MonadHttp (AccumT w m) where
803807 getHttpConfig = lift getHttpConfig
804808
805809-- | @since 3.10.0
806−instance (MonadHttp m) => MonadHttp (ContT r m) where
810+instance MonadHttp m => MonadHttp (ContT r m) where
807811 handleHttpException = lift . handleHttpException
808812 getHttpConfig = lift getHttpConfig
809813
810814-- | @since 3.10.0
811−instance (MonadHttp m) => MonadHttp (ExceptT e m) where
815+instance MonadHttp m => MonadHttp (ExceptT e m) where
812816 handleHttpException = lift . handleHttpException
813817 getHttpConfig = lift getHttpConfig
814818
815819-- | @since 3.10.0
816−instance (MonadHttp m) => MonadHttp (IdentityT m) where
820+instance MonadHttp m => MonadHttp (IdentityT m) where
817821 handleHttpException = lift . handleHttpException
818822 getHttpConfig = lift getHttpConfig
819823
820824-- | @since 3.10.0
821−instance (MonadHttp m) => MonadHttp (MaybeT m) where
825+instance MonadHttp m => MonadHttp (MaybeT m) where
822826 handleHttpException = lift . handleHttpException
823827 getHttpConfig = lift getHttpConfig
824828
825829-- | @since 3.10.0
826−instance (MonadHttp m) => MonadHttp (ReaderT r m) where
830+instance MonadHttp m => MonadHttp (ReaderT r m) where
827831 handleHttpException = lift . handleHttpException
828832 getHttpConfig = lift getHttpConfig
829833
@@ -843,17 +847,17 @@ instance (MonadHttp m, Monoid w) => MonadHttp (RWS.Strict.RWST r w s m) where
843847 getHttpConfig = lift getHttpConfig
844848
845849-- | @since 3.10.0
846−instance (MonadHttp m) => MonadHttp (SelectT r m) where
850+instance MonadHttp m => MonadHttp (SelectT r m) where
847851 handleHttpException = lift . handleHttpException
848852 getHttpConfig = lift getHttpConfig
849853
850854-- | @since 3.10.0
851−instance (MonadHttp m) => MonadHttp (State.Lazy.StateT s m) where
855+instance MonadHttp m => MonadHttp (State.Lazy.StateT s m) where
852856 handleHttpException = lift . handleHttpException
853857 getHttpConfig = lift getHttpConfig
854858
855859-- | @since 3.10.0
856−instance (MonadHttp m) => MonadHttp (State.Strict.StateT s m) where
860+instance MonadHttp m => MonadHttp (State.Strict.StateT s m) where
857861 handleHttpException = lift . handleHttpException
858862 getHttpConfig = lift getHttpConfig
859863
@@ -877,7 +881,7 @@ instance (MonadHttp m, Monoid w) => MonadHttp (Writer.Strict.WriterT w m) where
877881--
878882-- @since 0.4.0
879883runReq ::
880− (MonadIO m) =>
884+ MonadIO m =>
881885 -- | 'HttpConfig' to use
882886 HttpConfig ->
883887 -- | Computation to run
@@ -982,7 +986,7 @@ class HttpMethod a where
982986 -- | Return name of the method as a 'ByteString'.
983987 httpMethodName :: Proxy a -> ByteString
984988
985−instance (HttpMethod method) => RequestComponent (Tagged "method" method) where
989+instance HttpMethod method => RequestComponent (Tagged "method" method) where
986990 getRequestMod _ = Endo $ \x ->
987991 x {L.method = httpMethodName (Proxy :: Proxy method)}
988992
@@ -1024,20 +1028,25 @@ instance (HttpMethod method) => RequestComponent (Tagged "method" method) where
10241028-- > -- https://%D1%8E%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4.%D1%80%D1%84
10251029data Url (scheme :: Scheme) = Url Scheme (NonEmpty Text)
10261030 -- NOTE The second value is the path segments in reversed order.
1027− deriving (Eq, Ord, Show, Data, Generic)
1031+ deriving (Eq, Ord, Show, Data, Typeable, Generic)
10281032
10291033type role Url nominal
10301034
10311035-- With template-haskell >=2.15 and text >=1.2.4 Lift can be derived, however
10321036-- the derived lift forgets the type of the scheme.
1033−instance (Typeable scheme) => TH.Lift (Url scheme) where
1037+instance Typeable scheme => TH.Lift (Url scheme) where
10341038 lift url =
10351039 TH.dataToExpQ (fmap liftText . cast) url `TH.sigE` case url of
10361040 Url Http _ -> [t|Url 'Http|]
10371041 Url Https _ -> [t|Url 'Https|]
10381042 where
10391043 liftText t = TH.AppE (TH.VarE 'T.pack) <$> TH.lift (T.unpack t)
1044+
1045+#if MIN_VERSION_template_haskell(2,17,0)
10401046 liftTyped = TH.Code . TH.unsafeTExpCoerce . TH.lift
1047+#elif MIN_VERSION_template_haskell(2,16,0)
1048+ liftTyped = TH.unsafeTExpCoerce . TH.lift
1049+#endif
10411050
10421051-- | Given host name, produce a 'Url' which has “http” as its scheme and
10431052-- empty path. This also sets port to @80@.
@@ -1053,7 +1062,7 @@ https = Url Https . pure
10531062-- path segment can be of any type that is an instance of 'ToHttpApiData'.
10541063infixl 5 /~
10551064
1056−(/~) :: (ToHttpApiData a) => Url scheme -> a -> Url scheme
1065+(/~) :: ToHttpApiData a => Url scheme -> a -> Url scheme
10571066Url secure path /~ segment = Url secure (NE.cons (toUrlPiece segment) path)
10581067
10591068-- | A type-constrained version of @('/~')@ to remove ambiguity in the cases
@@ -1241,7 +1250,7 @@ instance HttpBody NoReqBody where
12411250-- charset=utf-8\"@ value.
12421251newtype ReqBodyJson a = ReqBodyJson a
12431252
1244−instance (ToJSON a) => HttpBody (ReqBodyJson a) where
1253+instance ToJSON a => HttpBody (ReqBodyJson a) where
12451254 getRequestBody (ReqBodyJson a) = L.RequestBodyLBS (A.encode a)
12461255 getRequestContentType _ = pure "application/json; charset=utf-8"
12471256
@@ -1294,13 +1303,6 @@ newtype FormUrlEncodedParam = FormUrlEncodedParam [(Text, Maybe Text)]
12941303instance QueryParam FormUrlEncodedParam where
12951304 queryParam name mvalue =
12961305 FormUrlEncodedParam [(name, toQueryParam <$> mvalue)]
1297− queryParamToList (FormUrlEncodedParam p) = p
1298−
1299−-- | Use 'formToQuery'.
1300−--
1301−-- @since 3.11.0
1302−instance FromForm FormUrlEncodedParam where
1303− fromForm = Right . formToQuery
13041306
13051307-- | Multipart form data. Please consult the
13061308-- "Network.HTTP.Client.MultipartFormData" module for how to construct
@@ -1340,7 +1342,7 @@ instance HttpBody ReqBodyMultipart where
13401342-- | Create 'ReqBodyMultipart' request body from a collection of 'LM.Part's.
13411343--
13421344-- @since 0.2.0
1343−reqBodyMultipart :: (MonadIO m) => [LM.Part] -> m ReqBodyMultipart
1345+reqBodyMultipart :: MonadIO m => [LM.Part] -> m ReqBodyMultipart
13441346reqBodyMultipart parts = liftIO $ do
13451347 boundary <- LM.webkitBoundary
13461348 body <- LM.renderParts boundary parts
@@ -1380,7 +1382,7 @@ type family
13801382 TypeError
13811383 ('Text "This HTTP method does not allow attaching a request body.")
13821384
1383−instance (HttpBody body) => RequestComponent (Tagged "body" body) where
1385+instance HttpBody body => RequestComponent (Tagged "body" body) where
13841386 getRequestMod (Tagged body) = Endo $ \x ->
13851387 x
13861388 { L.requestBody = getRequestBody body,
@@ -1426,12 +1428,6 @@ instance Monoid (Option scheme) where
14261428 mempty = Option mempty Nothing
14271429 mappend = (<>)
14281430
1429−-- | Use 'formToQuery'.
1430−--
1431−-- @since 3.11.0
1432−instance FromForm (Option scheme) where
1433− fromForm = Right . formToQuery
1434−
14351431-- | A helper to create an 'Option' that modifies only collection of query
14361432-- parameters. This helper is not a part of the public API.
14371433withQueryParams :: (Y.QueryText -> Y.QueryText) -> Option scheme
@@ -1450,7 +1446,7 @@ instance RequestComponent (Option scheme) where
14501446
14511447-- | Finalize given 'L.Request' by applying a finalizer from the given
14521448-- 'Option' (if it has any).
1453−finalizeRequest :: (MonadIO m) => Option scheme -> L.Request -> m L.Request
1449+finalizeRequest :: MonadIO m => Option scheme -> L.Request -> m L.Request
14541450finalizeRequest (Option _ mfinalizer) = liftIO . fromMaybe pure mfinalizer
14551451
14561452----------------------------------------------------------------------------
@@ -1483,27 +1479,9 @@ name =: value = queryParam name (pure value)
14831479-- This operator is defined in terms of 'queryParam':
14841480--
14851481-- > queryFlag name = queryParam name (Nothing :: Maybe ())
1486−queryFlag :: (QueryParam param) => Text -> param
1482+queryFlag :: QueryParam param => Text -> param
14871483queryFlag name = queryParam name (Nothing :: Maybe ())
14881484
1489−-- | Construct query parameters from a 'ToForm' instance. This function
1490−-- produces the same query params as 'Form.urlEncodeAsFormStable'.
1491−--
1492−-- Note that 'Form.Form' doesn't have the concept of parameters with the
1493−-- empty value (i.e. what you can get by @key =: ""@). If the value is
1494−-- empty, it will be encoded as a valueless parameter (i.e. what you can get
1495−-- by @queryFlag key@).
1496−--
1497−-- @since 3.11.0
1498−formToQuery :: (QueryParam param, Monoid param, ToForm f) => f -> param
1499−formToQuery f = mconcat . fmap toParam . Form.toListStable $ toForm f
1500− where
1501− toParam (key, val) =
1502− queryParam key $
1503− if val == ""
1504− then Nothing
1505− else Just val
1506−
15071485-- | A type class for query-parameter-like things. The reason to have an
15081486-- overloaded 'queryParam' is to be able to use it as an 'Option' and as a
15091487-- 'FormUrlEncodedParam' when constructing form URL encoded request bodies.
@@ -1513,17 +1491,11 @@ class QueryParam param where
15131491 -- 'Nothing', it won't be included at all (i.e. you create a flag this
15141492 -- way). It's recommended to use @('=:')@ and 'queryFlag' instead of this
15151493 -- method, because they are easier to read.
1516− queryParam :: (ToHttpApiData a) => Text -> Maybe a -> param
1517−
1518− -- | Get the query parameter names and values set by 'queryParam'.
1519− --
1520− -- @since 3.11.0
1521− queryParamToList :: param -> [(Text, Maybe Text)]
1494+ queryParam :: ToHttpApiData a => Text -> Maybe a -> param
15221495
15231496instance QueryParam (Option scheme) where
15241497 queryParam name mvalue =
15251498 withQueryParams ((:) (name, toQueryParam <$> mvalue))
1526− queryParamToList (Option f _) = fst $ appEndo f ([], L.defaultRequest)
15271499
15281500----------------------------------------------------------------------------
15291501-- Request—Optional parameters—Headers
@@ -1547,14 +1519,6 @@ attachHeader :: ByteString -> ByteString -> L.Request -> L.Request
15471519attachHeader name value x =
15481520 x {L.requestHeaders = (CI.mk name, value) : L.requestHeaders x}
15491521
1550−-- | Same as 'header', but with redacted values on print.
1551−--
1552−-- @since 3.13.0
1553−headerRedacted :: ByteString -> ByteString -> Option scheme
1554−headerRedacted name value = withRequest $ \x ->
1555− let y = attachHeader name value x
1556− in y {L.redactHeaders = CI.mk name `S.insert` L.redactHeaders y}
1557−
15581522----------------------------------------------------------------------------
15591523-- Request—Optional parameters—Cookies
15601524
@@ -1762,7 +1726,7 @@ ignoreResponse = Proxy
17621726newtype JsonResponse a = JsonResponse (L.Response a)
17631727 deriving (Show)
17641728
1765−instance (FromJSON a) => HttpResponse (JsonResponse a) where
1729+instance FromJSON a => HttpResponse (JsonResponse a) where
17661730 type HttpResponseBody (JsonResponse a) = a
17671731 toVanillaResponse (JsonResponse r) = r
17681732 getHttpResponse r = do
@@ -1878,14 +1842,14 @@ brReadN br n = go 0 id id
18781842
18791843-- | Get the response body.
18801844responseBody ::
1881− (HttpResponse response) =>
1845+ HttpResponse response =>
18821846 response ->
18831847 HttpResponseBody response
18841848responseBody = L.responseBody . toVanillaResponse
18851849
18861850-- | Get the response status code.
18871851responseStatusCode ::
1888− (HttpResponse response) =>
1852+ HttpResponse response =>
18891853 response ->
18901854 Int
18911855responseStatusCode =
@@ -1893,7 +1857,7 @@ responseStatusCode =
18931857
18941858-- | Get the response status message.
18951859responseStatusMessage ::
1896− (HttpResponse response) =>
1860+ HttpResponse response =>
18971861 response ->
18981862 ByteString
18991863responseStatusMessage =
@@ -1901,7 +1865,7 @@ responseStatusMessage =
19011865
19021866-- | Lookup a particular header from a response.
19031867responseHeader ::
1904− (HttpResponse response) =>
1868+ HttpResponse response =>
19051869 -- | Response interpretation
19061870 response ->
19071871 -- | Header to lookup
@@ -1913,7 +1877,7 @@ responseHeader r h =
19131877
19141878-- | Get the response 'L.CookieJar'.
19151879responseCookieJar ::
1916− (HttpResponse response) =>
1880+ HttpResponse response =>
19171881 response ->
19181882 L.CookieJar
19191883responseCookieJar = L.responseCookieJar . toVanillaResponse
@@ -1967,16 +1931,6 @@ class HttpResponse response where
19671931 acceptHeader :: Proxy response -> Maybe ByteString
19681932 acceptHeader Proxy = Nothing
19691933
1970−-- | This instance has been added to make it easier to inspect 'L.Response'
1971−-- using Req's functions like 'responseStatusCode', 'responseStatusMessage',
1972−-- etc.
1973−--
1974−-- @since 3.12.0
1975−instance HttpResponse (L.Response ()) where
1976− type HttpResponseBody (L.Response ()) = ()
1977− toVanillaResponse = id
1978− getHttpResponse = return . void
1979−
19801934----------------------------------------------------------------------------
19811935-- Other
19821936
@@ -2011,24 +1965,10 @@ data HttpException
20111965 | -- | A wrapper with Aeson-produced 'String' describing why decoding
20121966 -- failed
20131967 JsonHttpException String
2014− deriving (Show, Generic)
1968+ deriving (Show, Typeable, Generic)
20151969
20161970instance Exception HttpException
20171971
2018−-- | Return 'Just' if the given 'HttpException' is wrapping a http-client's
2019−-- 'L.StatusCodeException'. Otherwise, return 'Nothing'.
2020−--
2021−-- @since 3.12.0
2022−isStatusCodeException :: HttpException -> Maybe (L.Response ())
2023−isStatusCodeException
2024− ( VanillaHttpException
2025− ( L.HttpExceptionRequest
2026− _
2027− (L.StatusCodeException r _)
2028− )
2029− ) = Just r
2030−isStatusCodeException _ = Nothing
2031−
20321972-- | A simple type isomorphic to 'Bool' that we only have for better error
20331973-- messages. We use it as a kind and its data constructors as type-level
20341974-- tags.
@@ -2048,4 +1988,4 @@ data Scheme
20481988 Http
20491989 | -- | HTTPS
20501990 Https
2051− deriving (Eq, Ord, Show, Data, Generic, TH.Lift)
1991+ deriving (Eq, Ord, Show, Data, Typeable, Generic, TH.Lift)