diff --git a/.travis.yml b/.travis.yml index 76c22bd..f7149aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,10 @@ cache: matrix: include: - - ghc: 8.8.1 - - ghc: 8.6.5 - - ghc: 8.4.4 - - ghc: 8.2.2 + - ghc: 9.8.2 + - ghc: 9.6.6 + - ghc: 9.4.8 + - ghc: 9.2.8 install: - | diff --git a/cabal.project b/cabal.project index 5174797..b5444dd 100644 --- a/cabal.project +++ b/cabal.project @@ -1,5 +1,4 @@ packages: - ./ - hreq-client/ - hreq-core/ - hreq-conduit/ + ./hreq-client/ + ./hreq-core/ + ./hreq-conduit/ diff --git a/hreq-client/hreq-client.cabal b/hreq-client/hreq-client.cabal index a3eb0f5..993eb83 100644 --- a/hreq-client/hreq-client.cabal +++ b/hreq-client/hreq-client.cabal @@ -13,10 +13,10 @@ license: MIT license-file: LICENSE.md extra-doc-files: CHANGELOG.md, README.md tested-with: - GHC ==8.2.2 - || ==8.4.4 - || ==8.6.5 - || ==8.8.1 + GHC ==9.2.8 + || ==9.4.8 + || ==9.6.6 + || ==9.8.2 build-type: Custom source-repository head @@ -38,23 +38,23 @@ library default-extensions: LambdaCase DeriveGeneric FlexibleInstances FlexibleContexts ScopedTypeVariables TypeApplications TypeOperators MultiParamTypeClasses RecordWildCards TypeApplications TypeFamilies OverloadedStrings GADTs GeneralizedNewtypeDeriving FunctionalDependencies ConstraintKinds RankNTypes PolyKinds DataKinds KindSignatures ViewPatterns UndecidableInstances StrictData build-depends: - base >= 4.10.1 && < 5, - base-compat >= 0.10.5 && < 0.13, - bytestring >= 0.10.8 && < 0.11, - containers >= 0.5.7.1 && < 0.7, - exceptions >= 0.10.0 && < 0.11, - http-client >= 0.6.4 && < 0.7, - http-client-tls >= 0.3.5 && < 0.4, - hreq-core >= 0.1.1, - http-media >= 0.8.0 && < 0.9, - http-types >= 0.12.3 && < 0.13, - mtl >= 2.2.2 && < 3.0, - retry >= 0.8 && < 0.9, - time >= 1.6.0.1 && < 2.0, - text >= 1.2.4 && < 1.3, - stm >= 2.4.5.1 && < 2.6, - unliftio-core >= 0.1.2 && < 0.2.0, - string-conversions >= 0.4.0 && < 0.5 + base >= 4.14 && < 5, + base-compat >= 0.10.5 && < 0.15, + bytestring >= 0.10.8 && < 0.13, + containers >= 0.5.7.1 && < 0.8, + exceptions >= 0.10.0 && < 0.11, + http-client >= 0.6.4 && < 0.8, + http-client-tls >= 0.3.5 && < 0.4, + hreq-core >= 0.1.1, + http-media >= 0.8.0 && < 0.9, + http-types >= 0.12.3 && < 0.13, + mtl >= 2.2.2 && < 3.0, + retry >= 0.8 && < 0.9, + time >= 1.6.0.1 && < 2.0, + text >= 1.2.4 && < 2.2, + stm >= 2.4.5.1 && < 2.6, + unliftio-core ^>= 0.2, + string-conversions >= 0.4.0 && < 0.5 ghc-options: -Wall @@ -78,16 +78,16 @@ executable example build-depends: base >= 4.10.1 && < 5 , hreq-client - , aeson >= 1.4.5 && < 1.5 - , text >= 1.2.4 && < 1.3 + , aeson >= 1.4.5 && < 1.6 || >= 2.2 && < 2.3 + , text >= 1.2.4 && < 1.3 || >= 2.0 && < 2.2 test-suite spec build-depends: - base >= 4.10.1 && < 5 - , aeson >= 1.4.5 && < 1.5 - , containers >= 0.5.7.1 && < 0.7 - , http-types >= 0.12.3 && < 0.13 - , hspec >= 2.6.0 && < 2.8 + base >= 4.10.1 && < 5 + , aeson >= 1.4.5 && < 1.6 || >= 2.2 && < 2.3 + , containers >= 0.5.7.1 && < 0.8 + , http-types >= 0.12.3 && < 0.13 + , hspec >= 2.6.0 && < 2.8 , hreq-client , hreq-core main-is: Spec.hs @@ -109,9 +109,9 @@ test-suite doctests type: exitcode-stdio-1.0 main-is: DocTests.hs build-depends: - base >= 4.10.1 && < 5 - , aeson >= 1.4.5 && < 1.5 - , doctest >=0.15 && < 0.17 + base >= 4.14 && < 5 + , aeson >= 1.4.5 && < 1.6 || >= 2.2 && < 2.3 + , doctest >= 0.15 && < 0.23 , hreq-client ghc-options: -Wall -threaded diff --git a/hreq-conduit/hreq-conduit.cabal b/hreq-conduit/hreq-conduit.cabal index f3fff98..10fc5e2 100644 --- a/hreq-conduit/hreq-conduit.cabal +++ b/hreq-conduit/hreq-conduit.cabal @@ -13,10 +13,10 @@ license: MIT license-file: LICENSE.md extra-doc-files: CHANGELOG.md, README.md tested-with: - GHC ==8.2.2 - || ==8.4.4 - || ==8.6.5 - || ==8.8.1 + GHC ==9.2.8 + || ==9.4.8 + || ==9.6.6 + || ==9.8.2 build-type: Custom custom-setup @@ -39,17 +39,17 @@ library default-extensions: LambdaCase DeriveGeneric FlexibleInstances FlexibleContexts ScopedTypeVariables TypeApplications TypeOperators MultiParamTypeClasses RecordWildCards TypeApplications TypeFamilies OverloadedStrings GADTs GeneralizedNewtypeDeriving FunctionalDependencies ConstraintKinds RankNTypes PolyKinds DataKinds KindSignatures ViewPatterns UndecidableInstances StrictData build-depends: - base >= 4.10.1 && < 5, - bytestring >= 0.10.8 && < 0.11, - exceptions >= 0.10.0 && < 0.11, - http-client >= 0.6.4 && < 0.7, - http-types >= 0.12.3 && < 0.13, - hreq-client >= 0.1.0, - hreq-core >= 0.1.0, - conduit >=1.3.1 && <1.4, - mtl >= 2.2.2 && < 3.0, - retry >= 0.8 && < 0.9, - unliftio-core >= 0.1.2 && < 0.2.0 + base >= 4.14 && < 5, + bytestring >= 0.10.8 && < 0.13, + exceptions >= 0.10.0 && < 0.11, + http-client >= 0.6.4 && < 0.8, + http-types >= 0.12.3 && < 0.13, + hreq-client >= 0.1.0, + hreq-core >= 0.1.0, + conduit >= 1.3.1 && < 1.4, + mtl >= 2.2.2 && < 3.0, + retry >= 0.8 && < 0.9, + unliftio-core ^>= 0.2.0 ghc-options: -Wall @@ -69,12 +69,12 @@ test-suite spec build-depends: base >= 4.10.1 && < 5 - , conduit >=1.3.1 && <1.4 + , conduit >= 1.3.1 && <1.4 , http-types >= 0.12.3 && < 0.13 , hspec >= 2.6.0 && < 2.8 , hreq-conduit , string-conversions >= 0.4.0 && < 0.5 - , text >= 1.2.4 && < 1.3 + , text >= 1.2.4 && < 1.3 || >= 2.0 && < 2.2 main-is: Spec.hs other-modules: Hreq.HttpBin.SuccessSpec hs-source-dirs: test @@ -87,9 +87,9 @@ test-suite spec test-suite readme build-depends: - base >= 4.10.1 && < 5 - , conduit >=1.3.1 && <1.4 - , bytestring >= 0.10.8 && < 0.11 + base >= 4.10.1 && < 5 + , conduit >= 1.3.1 && < 1.4 + , bytestring >= 0.10.8 && < 0.11 , hreq-conduit , string-conversions >= 0.4.0 && < 0.5 , text >= 1.2.4 && < 1.3 @@ -104,9 +104,9 @@ test-suite doctests type: exitcode-stdio-1.0 main-is: DocTests.hs build-depends: - base >= 4.10.1 && < 5 - , aeson >= 1.4.5 && < 1.5 - , doctest >=0.15 && < 0.17 + base >= 4.14 && < 5 + , aeson >= 1.4.5 && < 1.6 || >= 2.2 && < 2.3 + , doctest >= 0.15 && < 0.23 , hreq-conduit ghc-options: -Wall -threaded diff --git a/hreq-conduit/src/Hreq/Conduit/Internal/HTTP.hs b/hreq-conduit/src/Hreq/Conduit/Internal/HTTP.hs index ff74e4c..17e906e 100644 --- a/hreq-conduit/src/Hreq/Conduit/Internal/HTTP.hs +++ b/hreq-conduit/src/Hreq/Conduit/Internal/HTTP.hs @@ -75,12 +75,12 @@ runStreamingHttp runStreamingHttp req f = do config <- ask let manager = httpManager config - let baseUrl = httpBaseUrl config - let statusRange = httpStatuses config + baseUrl = httpBaseUrl config + statusRange = httpStatuses config - let httpRequest = requestToHTTPRequest baseUrl req + httpRequest = requestToHTTPRequest baseUrl req - let action = liftIO $ catchConnectionError $ HTTP.withResponse httpRequest manager $ \res -> do + action = liftIO $ catchConnectionError $ HTTP.withResponse httpRequest manager $ \res -> do checkStreamResponse res statusRange f (ResBodyStream $ bodyReaderSource (HTTP.responseBody res)) diff --git a/hreq-core/hreq-core.cabal b/hreq-core/hreq-core.cabal index bf5e968..e81e7bb 100644 --- a/hreq-core/hreq-core.cabal +++ b/hreq-core/hreq-core.cabal @@ -13,10 +13,10 @@ license: MIT license-file: LICENSE.md extra-doc-files: CHANGELOG.md, README.md tested-with: - GHC ==8.2.2 - || ==8.4.4 - || ==8.6.5 - || ==8.8.1 + GHC ==9.2.8 + || ==9.4.8 + || ==9.6.6 + || ==9.8.2 build-type: Custom source-repository head @@ -54,19 +54,20 @@ library default-extensions: LambdaCase DeriveGeneric FlexibleInstances FlexibleContexts ScopedTypeVariables TypeApplications TypeOperators MultiParamTypeClasses RecordWildCards TypeApplications TypeFamilies OverloadedStrings GADTs GeneralizedNewtypeDeriving FunctionalDependencies ConstraintKinds RankNTypes PolyKinds DataKinds KindSignatures ViewPatterns UndecidableInstances StrictData build-depends: - base >= 4.10.1 && < 5, - base-compat >= 0.10.5 && < 0.13, - aeson >= 1.4.5 && < 1.5, - attoparsec >= 0.13.2.2 && < 0.14, - bytestring >= 0.10.8 && < 0.11, - containers >= 0.5.7.1 && < 0.7, - exceptions >= 0.10.0 && < 0.11, - http-api-data >= 0.4.1 && < 0.5, - http-media >= 0.8.0 && < 0.9, - http-types >= 0.12.3 && < 0.13, - mtl >= 2.2.2 && < 3.0, - text >= 1.2.4 && < 1.3, - string-conversions >= 0.4.0 && < 0.5 + base >= 4.14 && < 5, + base-compat >= 0.10.5 && < 0.13, + aeson >= 1.4.5 && < 1.6 || >= 2.2 && < 2.3, + attoparsec >= 0.13.2.2 && < 0.15, + attoparsec-aeson >= 2.0, + bytestring >= 0.10.8 && < 0.13, + containers >= 0.5.7.1 && < 0.8, + exceptions >= 0.10.0 && < 0.11, + http-api-data >= 0.4.1 && < 0.7, + http-media >= 0.8.0 && < 0.9, + http-types >= 0.12.3 && < 0.13, + mtl >= 2.2.2 && < 3.0, + text >= 1.2.4 && < 2.2, + string-conversions >= 0.4.0 && < 0.5 ghc-options: -Wall -Wincomplete-uni-patterns @@ -85,8 +86,8 @@ test-suite doctests type: exitcode-stdio-1.0 main-is: DocTests.hs build-depends: - base >= 4.10.1 && < 5 - , doctest >=0.15 && < 0.17 + base >= 4.14 && < 5 + , doctest >= 0.15 && < 0.23 , hreq-core ghc-options: -Wall -threaded diff --git a/hreq-core/src/Data/Singletons.hs b/hreq-core/src/Data/Singletons.hs index 7b086df..e8d4c47 100644 --- a/hreq-core/src/Data/Singletons.hs +++ b/hreq-core/src/Data/Singletons.hs @@ -15,11 +15,18 @@ ===Attribution Some of the code in this module was directly borrowed from the Singletons library -} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} module Data.Singletons where import Data.Kind + +#if MIN_VERSION_base(4,18,0) +import GHC.TypeLits hiding (SNat, SSymbol) +#else import GHC.TypeLits +#endif import Data.Typeable -- * Sing Type family diff --git a/hreq-core/src/Hreq/Core/API/Request.hs b/hreq-core/src/Hreq/Core/API/Request.hs index f8a3b4c..e18803b 100644 --- a/hreq-core/src/Hreq/Core/API/Request.hs +++ b/hreq-core/src/Hreq/Core/API/Request.hs @@ -4,7 +4,7 @@ module Hreq.Core.API.Request where import Data.Kind (Type) -import Data.Singletons (Sing, SingI(..)) +import Data.Singletons (Sing, SingI (..)) import GHC.TypeLits (Symbol) -- * Request Type diff --git a/hreq-core/src/Hreq/Core/API/TypeLevel.hs b/hreq-core/src/Hreq/Core/API/TypeLevel.hs index c3e47b6..5fd124c 100644 --- a/hreq-core/src/Hreq/Core/API/TypeLevel.hs +++ b/hreq-core/src/Hreq/Core/API/TypeLevel.hs @@ -2,18 +2,18 @@ -- module Hreq.Core.API.TypeLevel where -import Data.Kind (Type, Constraint) -import GHC.TypeLits (Symbol, TypeError, ErrorMessage(..), KnownSymbol, KnownNat) +import Data.Kind (Constraint, Type) +import GHC.TypeLits (ErrorMessage (..), KnownNat, KnownSymbol, Symbol, TypeError) import Network.HTTP.Types (Header) import Web.HttpApiData (ToHttpApiData) -import Hreq.Core.Client.BasicAuth (BasicAuthData) -import Hreq.Core.API.Request (ReqContent(..)) -import Hreq.Core.API.Response (ResContent (..)) import Hreq.Core.API.Internal ((:>)) -import Hreq.Core.API.MediaType (MediaDecode, MediaEncode, HasMediaType) +import Hreq.Core.API.MediaType (HasMediaType, MediaDecode, MediaEncode) +import Hreq.Core.API.Request (ReqContent (..)) +import Hreq.Core.API.Response (ResContent (..)) import Hreq.Core.API.Streaming (HasStreamBody) import Hreq.Core.API.Verb (Verb) +import Hreq.Core.Client.BasicAuth (BasicAuthData) -- | 'ApiToReq' transforms an API type into a type level list of -- Request component content types. diff --git a/hreq-core/src/Hreq/Core/Client/HasRequest.hs b/hreq-core/src/Hreq/Core/Client/HasRequest.hs index b07ae41..982ff8d 100644 --- a/hreq-core/src/Hreq/Core/Client/HasRequest.hs +++ b/hreq-core/src/Hreq/Core/Client/HasRequest.hs @@ -1,25 +1,30 @@ -- | This module provides a 'HasRequest' class that Interprets -- a 'ReqContent' type level list into 'Request' data -- -{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE PatternSynonyms #-} module Hreq.Core.Client.HasRequest where import Prelude () import Prelude.Compat -import Data.Kind import Data.Hlist +import Data.Kind import Data.Proxy import Data.Singletons +#if MIN_VERSION_base(4,18,0) +import GHC.TypeLits hiding (withKnownNat, withKnownSymbol) +#else import GHC.TypeLits +#endif +import Data.List (intersperse) import Data.String (fromString) import Data.String.Conversions (cs) -import Data.List (intersperse) import qualified Data.Text as T (concat) import Hreq.Core.API -import Hreq.Core.Client.Request import Hreq.Core.Client.BasicAuth +import Hreq.Core.Client.Request import Network.HTTP.Types (QueryItem) pattern Empty :: Hlist '[] diff --git a/hreq-core/src/Hreq/Core/Client/HasResponse.hs b/hreq-core/src/Hreq/Core/Client/HasResponse.hs index 3818873..86eb192 100644 --- a/hreq-core/src/Hreq/Core/Client/HasResponse.hs +++ b/hreq-core/src/Hreq/Core/Client/HasResponse.hs @@ -3,15 +3,21 @@ -- -- For instance @Verb GET '[]@ gets interpreted as an empty response of type Unit i.e @()@ -- +{-# LANGUAGE CPP #-} module Hreq.Core.Client.HasResponse where +import Control.Monad (unless, when) import Control.Monad.Except -import Data.Kind import Data.Hlist +import Data.Kind +import qualified Data.List.NonEmpty as NE import Data.Proxy import Data.Singletons -import qualified Data.List.NonEmpty as NE +#if MIN_VERSION_base(4,18,0) +import GHC.TypeLits hiding (withKnownNat) +#else import GHC.TypeLits +#endif import Network.HTTP.Types (hContentType) import Hreq.Core.API @@ -141,8 +147,8 @@ decodeAsBody _ response = do . throwError $ UnsupportedContentType (NE.head accepts) response case mediaDecode ctypProxy (resBody response) of - Left err -> throwError $ DecodeFailure (unDecodeError err) response - Right val -> pure val + Left err -> throwError $ DecodeFailure (unDecodeError err) response + Right val -> pure val where ctypProxy :: Proxy ctyp ctypProxy = Proxy @@ -185,7 +191,7 @@ decodeAsHlist srs response = case srs of when (rcode /= expectedCode) $ throwError (InvalidStatusCode response) decodeAsHlist xs response - + -- Should never match because we have a class instance -- that triggers a type error when 'Raw' is in a non-singleton -- type level list diff --git a/hreq-core/src/Hreq/Core/Client/Internal.hs b/hreq-core/src/Hreq/Core/Client/Internal.hs index 6901f3a..2e48a9b 100644 --- a/hreq-core/src/Hreq/Core/Client/Internal.hs +++ b/hreq-core/src/Hreq/Core/Client/Internal.hs @@ -5,6 +5,7 @@ module Hreq.Core.Client.Internal where import Control.Monad.Except +import Control.Monad.IO.Class (liftIO) import Data.Proxy import Hreq.Core.API diff --git a/hreq-core/src/Hreq/Core/Client/RunClient.hs b/hreq-core/src/Hreq/Core/Client/RunClient.hs index 83ae267..33f61e4 100644 --- a/hreq-core/src/Hreq/Core/Client/RunClient.hs +++ b/hreq-core/src/Hreq/Core/Client/RunClient.hs @@ -35,16 +35,16 @@ instance Monad (ClientPure state) where m >>= f = case m of RunClient r x -> setHttpRequest r $ f x - Throw e -> Throw e + Throw e -> Throw e instance Applicative (ClientPure state) where pure = RunClient defaultRequest f <*> x = case x of - Throw e -> Throw e + Throw e -> Throw e RunClient r y -> setHttpRequest r $ fmap ( $ y) f setHttpRequest :: Request -> ClientPure state a -> ClientPure state a setHttpRequest r h = case h of RunClient _ rs -> RunClient r rs - Throw e -> Throw e + Throw e -> Throw e