From c05e9156c11760d0b83a42cb1822c98c1459afa7 Mon Sep 17 00:00:00 2001 From: Janus Troelsen Date: Sat, 8 Apr 2023 16:19:10 -0500 Subject: [PATCH 1/2] Support ghc-9.6 --- .github/workflows/ci.yml | 6 +++--- src/Data/Swagger.hs | 7 +++---- src/Data/Swagger/Operation.hs | 9 +++++---- src/Data/Swagger/Optics.hs | 5 +++-- swagger2.cabal | 6 +++--- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2aa7c9..3b7c8c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - ghc: ["8.6.5", "8.8.4", "8.10.7", "9.0.2", "9.2.3"] - cabal: ["3.6.2.0"] + ghc: ["8.6.5", "8.8.4", "8.10.7", "9.0.2", "9.2.7", "9.4.4", "9.6.1"] + cabal: ["3.10.1.0"] os: [ubuntu-latest, macOS-latest] name: build and test (cabal) steps: @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v2 - uses: haskell/actions/setup@v1 with: - ghc-version: "9.2.3" + ghc-version: "9.2.7" enable-stack: true stack-version: "latest" - run: | diff --git a/src/Data/Swagger.hs b/src/Data/Swagger.hs index b2bb4ae..d4da584 100644 --- a/src/Data/Swagger.hs +++ b/src/Data/Swagger.hs @@ -124,12 +124,12 @@ import Data.Swagger.Internal -- $setup -- >>> import Control.Lens -- >>> import Data.Aeson +-- >>> import qualified Data.HashMap.Strict.InsOrd as IOHM -- >>> import Data.Monoid -- >>> import Data.Proxy -- >>> import GHC.Generics -- >>> :set -XDeriveGeneric -- >>> :set -XOverloadedStrings --- >>> :set -XOverloadedLists -- >>> :set -fno-warn-missing-methods -- $howto @@ -185,8 +185,8 @@ import Data.Swagger.Internal -- -- >>> :{ -- encode $ (mempty :: Swagger) --- & definitions .~ [ ("User", mempty & type_ ?~ SwaggerString) ] --- & paths .~ +-- & definitions .~ IOHM.fromList [ ("User", mempty & type_ ?~ SwaggerString) ] +-- & paths .~ IOHM.fromList -- [ ("/user", mempty & get ?~ (mempty -- & produces ?~ MimeList ["application/json"] -- & at 200 ?~ ("OK" & _Inline.schema ?~ Ref (Reference "User")) @@ -297,7 +297,6 @@ import Data.Swagger.Internal -- >>> data BadMixedType = ChoiceBool Bool | JustTag deriving Generic -- >>> instance ToSchema BadMixedType -- ... --- ... error: -- ... • Cannot derive Generic-based Swagger Schema for BadMixedType -- ... BadMixedType is a mixed sum type (has both unit and non-unit constructors). -- ... Swagger does not have a good representation for these types. diff --git a/src/Data/Swagger/Operation.hs b/src/Data/Swagger/Operation.hs index d3817d1..3724bbf 100644 --- a/src/Data/Swagger/Operation.hs +++ b/src/Data/Swagger/Operation.hs @@ -57,13 +57,14 @@ import qualified Data.HashSet.InsOrd as InsOrdHS -- $setup -- >>> import Data.Aeson +-- >>> import qualified Data.HashMap.Strict.InsOrd as IOHM -- >>> import Data.Proxy -- >>> import Data.Time -- | Prepend path piece to all operations of the spec. -- Leading and trailing slashes are trimmed/added automatically. -- --- >>> let api = (mempty :: Swagger) & paths .~ [("/info", mempty)] +-- >>> let api = (mempty :: Swagger) & paths .~ IOHM.fromList [("/info", mempty)] -- >>> encode $ prependPath "user/{user_id}" api ^. paths -- "{\"/user/{user_id}/info\":{}}" prependPath :: FilePath -> Swagger -> Swagger @@ -84,8 +85,8 @@ allOperations = paths.traverse.template -- by both path and method. -- -- >>> let ok = (mempty :: Operation) & at 200 ?~ "OK" --- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ ok & post ?~ ok)] --- >>> let sub = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)] +-- >>> let api = (mempty :: Swagger) & paths .~ IOHM.fromList [("/user", mempty & get ?~ ok & post ?~ ok)] +-- >>> let sub = (mempty :: Swagger) & paths .~ IOHM.fromList [("/user", mempty & get ?~ mempty)] -- >>> encode api -- "{\"swagger\":\"2.0\",\"info\":{\"title\":\"\",\"version\":\"\"},\"paths\":{\"/user\":{\"get\":{\"responses\":{\"200\":{\"description\":\"OK\"}}},\"post\":{\"responses\":{\"200\":{\"description\":\"OK\"}}}}}}" -- >>> encode $ api & operationsOf sub . at 404 ?~ "Not found" @@ -150,7 +151,7 @@ declareResponse proxy = do -- -- Example: -- --- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)] +-- >>> let api = (mempty :: Swagger) & paths .~ IOHM.fromList [("/user", mempty & get ?~ mempty)] -- >>> let res = declareResponse (Proxy :: Proxy Day) -- >>> encode $ api & setResponse 200 res -- "{\"swagger\":\"2.0\",\"info\":{\"title\":\"\",\"version\":\"\"},\"paths\":{\"/user\":{\"get\":{\"responses\":{\"200\":{\"description\":\"\",\"schema\":{\"$ref\":\"#/definitions/Day\"}}}}}},\"definitions\":{\"Day\":{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"}}}" diff --git a/src/Data/Swagger/Optics.hs b/src/Data/Swagger/Optics.hs index 9c22e05..211df96 100644 --- a/src/Data/Swagger/Optics.hs +++ b/src/Data/Swagger/Optics.hs @@ -15,6 +15,7 @@ -- library. -- -- >>> import Data.Aeson +-- >>> import qualified Data.HashMap.Strict.InsOrd as IOHM -- >>> import Optics.Core -- >>> :set -XOverloadedLabels -- @@ -22,8 +23,8 @@ -- -- >>> :{ -- encode $ (mempty :: Swagger) --- & #definitions .~ [ ("User", mempty & #type ?~ SwaggerString) ] --- & #paths .~ +-- & #definitions .~ IOHM.fromList [ ("User", mempty & #type ?~ SwaggerString) ] +-- & #paths .~ IOHM.fromList -- [ ("/user", mempty & #get ?~ (mempty -- & #produces ?~ MimeList ["application/json"] -- & at 200 ?~ ("OK" & #_Inline % #schema ?~ Ref (Reference "User")) diff --git a/swagger2.cabal b/swagger2.cabal index a7c49f8..fb0e220 100644 --- a/swagger2.cabal +++ b/swagger2.cabal @@ -60,10 +60,10 @@ library -- GHC boot libraries build-depends: - base >=4.9 && <4.18 + base >=4.9 && <4.19 , bytestring >=0.10.8.1 && <0.12 , containers >=0.5.7.1 && <0.7 - , template-haskell >=2.11.1.0 && <2.20 + , template-haskell >=2.11.1.0 && <2.21 , time >=1.6.0.1 && <1.14 , transformers >=0.5.2.0 && <0.7 @@ -73,7 +73,7 @@ library -- other dependencies build-depends: - base-compat-batteries >=0.11.1 && <0.13 + base-compat-batteries >=0.11.1 && <0.14 , aeson >=2.0.0.0 && <2.2 , aeson-pretty >=0.8.7 && <0.9 -- cookie 0.4.3 is needed by GHC 7.8 due to time>=1.4 constraint From 9f91db6922f22fd5ebb25db51f4b96d2e8523577 Mon Sep 17 00:00:00 2001 From: Janus Troelsen Date: Sat, 8 Apr 2023 16:28:20 -0500 Subject: [PATCH 2/2] allow-newers for GHC 9.6 --- cabal.project | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cabal.project b/cabal.project index b0a523c..9e928d2 100644 --- a/cabal.project +++ b/cabal.project @@ -1,2 +1,11 @@ packages: . tests: true + +if(impl(ghc >= 9.6.1) && impl(ghc < 9.7)) + allow-newer: insert-ordered-containers:base + allow-newer: insert-ordered-containers:transformers + allow-newer: insert-ordered-containers:semigroupoids + allow-newer: generics-sop:base + allow-newer: generics-sop:ghc-prim + allow-newer: generics-sop:template-haskell + allow-newer: sop-core:base