Skip to content

Commit

Permalink
GHC 8.2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
bergmark committed Jul 27, 2017
1 parent 8a2563b commit ae0101f
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 26 deletions.
4 changes: 2 additions & 2 deletions rest-core/rest-core.cabal
Expand Up @@ -40,7 +40,7 @@ library
Rest.Schema
Rest.ShowUrl
build-depends:
base >= 4.5 && < 4.10
base >= 4.5 && < 4.11
, aeson >= 0.7 && < 1.3
, aeson-utils >= 0.2 && < 0.4
, base-compat >= 0.8 && < 0.10
Expand Down Expand Up @@ -73,7 +73,7 @@ test-suite rest-tests
main-is: Runner.hs
type: exitcode-stdio-1.0
build-depends:
base >= 4.5 && < 4.10
base >= 4.5 && < 4.11
, aeson >= 0.7 && < 1.3
, HUnit >= 1.2 && < 1.7
, bytestring >= 0.9 && < 0.11
Expand Down
14 changes: 7 additions & 7 deletions rest-example/rest-example.cabal
Expand Up @@ -40,7 +40,7 @@ library
Type.UserPost
Type.UserSignupError
build-depends:
base >= 4.6 && < 4.10
base >= 4.6 && < 4.11
, aeson >= 0.7 && < 1.3
, base-compat >= 0.8 && < 0.10
, bytestring >= 0.9 && < 0.11
Expand All @@ -56,7 +56,7 @@ library
, transformers-compat >= 0.4 && < 0.6
, stm >= 2.1 && < 2.5
, text >= 0.11 && < 1.3
, time >= 1.1 && < 1.7
, time >= 1.1 && < 1.9
, unordered-containers == 0.2.*

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -90,9 +90,9 @@ executable rest-example-happstack
if flag(happstack)
buildable: True
build-depends:
base >= 4.6 && < 4.10
base >= 4.6 && < 4.11
, base-compat >= 0.8 && < 0.10
, happstack-server >= 7.1 && < 7.5
, happstack-server >= 7.1 && < 7.6
, mtl >= 2.0 && < 2.3
, rest-example
, rest-happstack >= 0.2 && < 0.4
Expand All @@ -108,7 +108,7 @@ executable rest-example-wai
if flag(wai)
buildable: True
build-depends:
base >= 4.6 && < 4.10
base >= 4.6 && < 4.11
, base-compat >= 0.8 && < 0.10
, rest-example
, rest-wai >= 0.1 && < 0.3
Expand All @@ -124,7 +124,7 @@ executable rest-example-snap
if flag(snap)
buildable: True
build-depends:
base >= 4.6 && < 4.10
base >= 4.6 && < 4.11
, base-compat >= 0.8 && < 0.10
, mtl >= 2.0 && < 2.3
, rest-core >= 0.39 && < 0.40
Expand All @@ -144,7 +144,7 @@ executable rest-example-gen
if flag(gen)
buildable: True
build-depends:
base >= 4.6 && < 4.10
base >= 4.6 && < 4.11
, base-compat >= 0.8 && < 0.10
, rest-example
, rest-gen == 0.20.*
Expand Down
8 changes: 4 additions & 4 deletions rest-gen/rest-gen.cabal
Expand Up @@ -49,8 +49,8 @@ library
Rest.Gen.NoAnnotation
Rest.Gen.Utils
build-depends:
base >= 4.5 && < 4.10
, Cabal >= 1.16 && < 1.26
base >= 4.5 && < 4.11
, Cabal >= 1.16 && < 2.2
, HStringTemplate >= 0.6 && < 0.9
, aeson >= 0.7 && < 1.3
, base-compat >= 0.8 && < 0.10
Expand All @@ -64,7 +64,7 @@ library
, hxt >= 9.2 && < 9.4
, json-schema >= 0.6 && < 0.8
, pretty >= 1.0 && < 1.2
, process >= 1.0 && < 1.5
, process >= 1.0 && < 1.7
, rest-core >= 0.38 && < 0.40
, safe >= 0.2 && < 0.4
, semigroups >= 0.5 && < 0.19
Expand All @@ -83,7 +83,7 @@ test-suite rest-gen-tests
type: exitcode-stdio-1.0
ghc-options: -Wall
build-depends:
base >= 4.5 && < 4.10
base >= 4.5 && < 4.11
, HUnit >= 1.2 && < 1.7
, fclabels >= 1.0.4 && < 2.1
, haskell-src-exts >= 1.15.0 && < 1.20
Expand Down
38 changes: 32 additions & 6 deletions rest-gen/src/Rest/Gen/Haskell.hs
Expand Up @@ -86,31 +86,57 @@ updateExposedModules :: [Cabal.ModuleName] -> Cabal.GenericPackageDescription ->
updateExposedModules modules = modify _condLibrary (Just . maybe (mkCondLibrary modules) (set (_exposedModules . _condTreeData) modules))

mkGenericPackageDescription :: String -> [Cabal.ModuleName] -> Cabal.GenericPackageDescription
mkGenericPackageDescription name modules = Cabal.GenericPackageDescription pkg [] (Just (mkCondLibrary modules)) [] [] []
mkGenericPackageDescription name modules =
#if MIN_VERSION_Cabal(2,0,0)
Cabal.GenericPackageDescription pkg [] (Just (mkCondLibrary modules)) [] [] [] [] []
#else
Cabal.GenericPackageDescription pkg [] (Just (mkCondLibrary modules)) [] [] []
#endif
where
pkg = Cabal.emptyPackageDescription
{ Cabal.package = Cabal.PackageIdentifier (Cabal.PackageName name) (Cabal.Version [0, 1] [])
{ Cabal.package = Cabal.PackageIdentifier (cabalPackageName name) (cabalVersion [0, 1])
, Cabal.buildType = Just Cabal.Simple
, Cabal.specVersionRaw = Right (Cabal.orLaterVersion (Cabal.Version [1, 8] []))
, Cabal.specVersionRaw = Right (Cabal.orLaterVersion (cabalVersion [1, 8]))
}

mkCondLibrary :: [Cabal.ModuleName] -> Cabal.CondTree Cabal.ConfVar [Cabal.Dependency] Cabal.Library
mkCondLibrary modules = Cabal.CondNode
{ Cabal.condTreeData = cabalLibrary modules
, Cabal.condTreeConstraints =
[ Cabal.Dependency (Cabal.PackageName "base") (Cabal.withinVersion $ Cabal.Version [4] [])
, Cabal.Dependency (Cabal.PackageName "rest-types") (Cabal.withinVersion $ Cabal.Version [1, 10] [])
, Cabal.Dependency (Cabal.PackageName "rest-client") (Cabal.withinVersion $ Cabal.Version [0, 5, 2] [])
[ Cabal.Dependency (cabalPackageName "base") (Cabal.withinVersion $ cabalVersion [4] )
, Cabal.Dependency (cabalPackageName "rest-types") (Cabal.withinVersion $ cabalVersion [1, 10] )
, Cabal.Dependency (cabalPackageName "rest-client") (Cabal.withinVersion $ cabalVersion [0, 5, 2])
]
, Cabal.condTreeComponents = []
}

cabalLibrary :: [Cabal.ModuleName] -> Cabal.Library
#if MIN_VERSION_Cabal(2,0,0)
cabalLibrary mods = Cabal.emptyLibrary
{ Cabal.exposedModules = mods
, Cabal.libBuildInfo = (Cabal.libBuildInfo Cabal.emptyLibrary) { Cabal.hsSourceDirs = ["src"] }
}
#else
#if MIN_VERSION_Cabal(1,22,0)
cabalLibrary mods = Cabal.Library mods [] [] [] True Cabal.emptyBuildInfo { Cabal.hsSourceDirs = ["src"] }
#else
cabalLibrary mods = Cabal.Library mods True Cabal.emptyBuildInfo { Cabal.hsSourceDirs = ["src"] }
#endif
#endif

cabalVersion :: [Int] -> Cabal.Version
#if MIN_VERSION_Cabal(2,0,0)
cabalVersion = Cabal.mkVersion
#else
cabalVersion v = Cabal.Version v []
#endif

cabalPackageName :: String -> Cabal.PackageName
#if MIN_VERSION_Cabal(2,0,0)
cabalPackageName = Cabal.mkPackageName
#else
cabalPackageName = Cabal.PackageName
#endif

writeRes :: HaskellContext -> ApiResource -> IO ()
writeRes ctx node =
Expand Down
2 changes: 1 addition & 1 deletion rest-happstack/rest-happstack.cabal
Expand Up @@ -26,7 +26,7 @@ library
build-depends:
base == 4.*
, containers >= 0.4 && < 0.6
, happstack-server >= 7.0.5 && < 7.5
, happstack-server >= 7.0.5 && < 7.6
, mtl >= 2.0 && < 2.3
, rest-core >= 0.34 && < 0.40
, rest-gen >= 0.14 && < 0.21
Expand Down
1 change: 1 addition & 0 deletions rest-stringmap/.gitignore
@@ -0,0 +1 @@
/dist
2 changes: 1 addition & 1 deletion rest-stringmap/rest-stringmap.cabal
Expand Up @@ -28,7 +28,7 @@ library
Rest.StringMap.Map.Strict
Rest.StringMap.Util
build-depends:
base >= 4.6 && < 4.10
base >= 4.6 && < 4.11
, aeson >= 0.7 && < 1.3
, containers == 0.5.*
, hashable == 1.2.*
Expand Down
2 changes: 1 addition & 1 deletion rest-types/rest-types.cabal
Expand Up @@ -30,7 +30,7 @@ library
Rest.Types.ShowUrl
Rest.Types.Void
build-depends:
base >= 4.6 && < 4.10
base >= 4.6 && < 4.11
, aeson >= 0.7 && < 1.3
, base-compat >= 0.8 && < 0.10
, case-insensitive >= 1.2 && < 1.3
Expand Down
1 change: 1 addition & 0 deletions rest-wai/.gitignore
@@ -0,0 +1 @@
/dist
5 changes: 1 addition & 4 deletions stack.yaml
@@ -1,13 +1,10 @@
resolver: nightly-2017-03-25
resolver: lts-9.0
flags:
rest-example:
snap: true
happstack: true
wai: true
gen: true
extra-deps:
- HUnit-1.6.0.0
- HStringTemplate-0.8.5
allow-newer: true
packages:
- code-builder/
Expand Down

0 comments on commit ae0101f

Please sign in to comment.