Skip to content

Commit

Permalink
[#339] Support GHC-8.8 (#383)
Browse files Browse the repository at this point in the history
* [#339] Support GHC-8.8

Resolves #339

* Fix resolver name for different GHCs
  • Loading branch information
vrom911 authored and chshersh committed Dec 22, 2019
1 parent 0f85356 commit 95c7633
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 27 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,11 @@ Below you can see highlighted features in different categories.
-Wincomplete-record-updates
-Wcompat
-Widentities
-Wredundant-constraints (ghc >= 8.0)
-fhide-source-paths (ghc >= 8.2.2)
-Wmissing-export-lists (ghc >= 8.4.1)
-Wpartial-fields (ghc >= 8.4.1)
-Wredundant-constraints (GHC >= 8.0)
-fhide-source-paths (GHC >= 8.2.2)
-Wmissing-export-lists (GHC >= 8.4.1)
-Wpartial-fields (GHC >= 8.4.1)
-Wmissing-deriving-strategies (GHC >= 8.8.1)
```

Besides, the following GHC options are added to the executable, tests and benchmark stanzas:
Expand Down Expand Up @@ -348,7 +349,7 @@ Here is the list of the options that can be configured to suit your needs. If op
| `fullName` | Text | Full name. |
| `email` | Text | E-mail address. |
| `license` | License | One of: `MIT`, `BSD2`, `BSD3`, `GPL-2`, `GPL-3`, `LGPL-2.1`, `LGPL-3`, `AGPL-3`, `Apache-2.0`, `MPL-2.0`, `None`. |
| `ghcVersions` | [GHC] | `summoner` uses default `GHC-8.6.5`. However, additionally you can specify other versions. For each version `x.y.z` the `stack-x.y.z.yaml` will be created. |
| `ghcVersions` | [GHC] | `summoner` uses default `GHC-8.8.1`. However, additionally you can specify other versions. For each version `x.y.z` the `stack-x.y.z.yaml` will be created. |
| `github` | Bool | Turn on `GitHub` integration by default? |
| `gitignore` | [Text] | List of files you want added to the default `.gitignore`. (Ignored if `github = false`) |
| `noUpload` | Bool | Do not upload to GitHub, but create all GitHub related files if specified (Ignored if `github = false`) |
Expand Down Expand Up @@ -588,7 +589,7 @@ If you'd like to take part in the development processes, here are a few things t
* Summoner is a multi-package project which has two packages inside: `summoner-cli` and `summoner-tui`. We are supporting the same functionality in both of them, so, if it's possible, you should add/change the code in both of the packages.
* Summoner uses the custom prelude [`relude`](https://github.com/kowainik/relude).
* We are using the [Kowainik style guide](https://github.com/kowainik/org/blob/master/style-guide.md#haskell-style-guide).
* To sum up, [here is the Contributing guide](https://github.com/kowainik/org/blob/master/CONTRIBUTING.md#contributing-to-the-kowainik-repositories) we use across the repositories.
* To sum up, [here is the Contributing guide](https://github.com/kowainik/.github/blob/master/CONTRIBUTING.md#contributing-to-the-kowainik-repositories) we use across the repositories.
* This project is contributor-friendly, so be kind to other people working on the project.

### Dependencies [](#structure)
Expand Down
5 changes: 5 additions & 0 deletions summoner-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ The changelog is available [on GitHub][2].
Support GHC `8.6.5` in generated projects. Use GHC `8.6.5` in Summoner.
* Remove support of GHC `8.6.4`, `8.6.3`, `8.4.3`. Leave only the latest
versions of each major release.
* [#318](https://github.com/kowainik/summoner/issues/318):
Support GHC `8.8.1` in generated projects.
__Note:__ Stack projects will use `nightly` resolver as the stable one is not
out at the moment of this issue is implemented.
* Add `-Wmissing-deriving-strategies` option to GHC version `8.8.1` and upper.
* [#338](https://github.com/kowainik/summoner/issues/338):
Build Summoner with GHC-8.8.1.
* [#337](https://github.com/kowainik/summoner/issues/337):
Expand Down
16 changes: 10 additions & 6 deletions summoner-cli/src/Summoner/GhcVer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ data GhcVer
| Ghc822
| Ghc844
| Ghc865
| Ghc881
deriving stock (Eq, Ord, Show, Enum, Bounded)

-- | This function shows GHC along with corresponding base and lts versions
showGhcMeta :: GhcVer -> (Text, Text, Text)
showGhcMeta ghcVer =
( "ghc-" <> showGhcVer ghcVer
, "base-" <> baseVer ghcVer
, "lts-" <> latestLts ghcVer
, latestLts ghcVer
)

-- | Converts 'GhcVer' into dot-separated string.
Expand All @@ -51,6 +52,7 @@ showGhcVer = \case
Ghc822 -> "8.2.2"
Ghc844 -> "8.4.4"
Ghc865 -> "8.6.5"
Ghc881 -> "8.8.1"

-- | These are old GHC versions that are not working with default GHC versions when using Stack.
oldGhcs :: [GhcVer]
Expand All @@ -62,11 +64,12 @@ parseGhcVer = inverseMap showGhcVer
-- | Returns latest known LTS resolver for all GHC versions except default one.
latestLts :: GhcVer -> Text
latestLts = \case
Ghc7103 -> "6.35"
Ghc802 -> "9.21"
Ghc822 -> "11.22"
Ghc844 -> "12.26"
Ghc865 -> "13.27"
Ghc7103 -> "lts-6.35"
Ghc802 -> "lts-9.21"
Ghc822 -> "lts-11.22"
Ghc844 -> "lts-12.26"
Ghc865 -> "lts-14.17"
Ghc881 -> "nightly-2019-12-20"

-- | Represents PVP versioning (4 numbers).
data Pvp = Pvp
Expand All @@ -88,6 +91,7 @@ baseVerPvp = \case
Ghc822 -> Pvp 4 10 1 0
Ghc844 -> Pvp 4 11 1 0
Ghc865 -> Pvp 4 12 0 0
Ghc881 -> Pvp 4 13 0 0

-- | Returns corresponding @base@ version of the given GHC version.
baseVer :: GhcVer -> Text
Expand Down
2 changes: 2 additions & 0 deletions summoner-cli/src/Summoner/Template/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ cabalFile Settings{..} = File (toString settingsRepo ++ ".cabal") cabalFileConte
-Wmissing-export-lists
-Wpartial-fields
|]
<> memptyIfFalse (settingsTestedVersions `hasLeast` Ghc881)
"-Wmissing-deriving-strategies\n"
where
hasLeast :: [GhcVer] -> GhcVer -> Bool
hasLeast list el = all (>= el) list
2 changes: 1 addition & 1 deletion summoner-cli/src/Summoner/Template/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ scriptFile ghcVer = \case
[text|
#!/usr/bin/env stack
{- stack
--resolver lts-${ltsVersion}
--resolver ${ltsVersion}
script
--package base
-}
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/src/Summoner/Template/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ stackFiles Settings{..} = map createStackYaml settingsTestedVersions
-- create @stack.yaml@ file with LTS corresponding to specified ghc version
createStackYaml :: GhcVer -> TreeFs
createStackYaml ghcV = File (toString $ "stack" <> ver <> ".yaml")
$ "resolver: lts-" <> latestLts ghcV <> extraDeps
$ "resolver: " <> latestLts ghcV <> extraDeps
where
ver :: Text
ver = if ghcV == defaultGHC
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/src/Summoner/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ alignTable metas = map (formatTriple maxLengths) metas

formatTriple :: (Int, Int, Int) -> (Text, Text, Text) -> Text
formatTriple (lenA, lenB, lenC) (a, b, c) =
padRight lenA a <> " " <> padRight lenB b <> " " <> padRight lenC c
padRight lenA a <> " " <> padRight lenB b <> " " <> padRight lenC c

{- |
@padRight n t@ pads the text 't' with spaces on the right until it reaches length 'n'.
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/test/Test/Golden.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fullProject = Settings
, settingsIsExe = True
, settingsTest = True
, settingsBench = True
, settingsTestedVersions = [Ghc802, Ghc822, Ghc844, defaultGHC]
, settingsTestedVersions = [Ghc802 .. defaultGHC]
, settingsBaseType = "base-noprelude"
, settingsPrelude = Just $ CustomPrelude "relude" "Relude"
, settingsExtensions = ["ConstraintKinds", "LambdaCase", "OverloadedStrings"]
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/test/Test/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ stackScript :: Text
stackScript = [text|
#!/usr/bin/env stack
{- stack
--resolver lts-13.27
--resolver lts-14.17
script
--package base
-}
Expand Down
4 changes: 4 additions & 0 deletions summoner-cli/test/golden/fullProject/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ matrix:
- ghc: 8.2.2
- ghc: 8.4.4
- ghc: 8.6.5
- ghc: 8.8.1

- ghc: 8.2.2
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.2.2.yaml"
Expand All @@ -26,6 +27,9 @@ matrix:
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.4.4.yaml"

- ghc: 8.6.5
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.6.5.yaml"

- ghc: 8.8.1
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack.yaml"

install:
Expand Down
4 changes: 2 additions & 2 deletions summoner-cli/test/golden/fullProject/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ environment:
CABOPTS: --store-dir=C:\\SR

matrix:
- GHCVER: 8.6.5
- GHCVER: 8.8.1

install:
- choco source add -n mistuke -s https://www.myget.org/F/mistuke/api/v2
- choco install -y cabal --version 2.4.1.0
- choco install -y ghc --version 8.6.5
- choco install -y ghc --version 8.8.1
- refreshenv

before_build:
Expand Down
9 changes: 5 additions & 4 deletions summoner-cli/test/golden/fullProject/fullProject.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tested-with: GHC == 8.0.2
, GHC == 8.2.2
, GHC == 8.4.4
, GHC == 8.6.5
, GHC == 8.8.1

source-repository head
type: git
Expand All @@ -28,7 +29,7 @@ library
exposed-modules: FullProject
Prelude

build-depends: base-noprelude >= 4.9.1.0 && < 4.13
build-depends: base-noprelude >= 4.9.1.0 && < 4.14
, relude

ghc-options: -Wall
Expand All @@ -44,7 +45,7 @@ executable fullProject
hs-source-dirs: app
main-is: Main.hs

build-depends: base-noprelude >= 4.9.1.0 && < 4.13
build-depends: base-noprelude >= 4.9.1.0 && < 4.14
, fullProject
, relude

Expand All @@ -65,7 +66,7 @@ test-suite fullProject-test
hs-source-dirs: test
main-is: Spec.hs

build-depends: base-noprelude >= 4.9.1.0 && < 4.13
build-depends: base-noprelude >= 4.9.1.0 && < 4.14
, fullProject
, relude

Expand All @@ -86,7 +87,7 @@ benchmark fullProject-benchmark
hs-source-dirs: benchmark
main-is: Main.hs

build-depends: base-noprelude >= 4.9.1.0 && < 4.13
build-depends: base-noprelude >= 4.9.1.0 && < 4.14
, gauge
, fullProject
, relude
Expand Down
3 changes: 3 additions & 0 deletions summoner-cli/test/golden/fullProject/stack-8.6.5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resolver: lts-14.17

extra-deps: [base-noprelude-4.12.0.0]
4 changes: 2 additions & 2 deletions summoner-cli/test/golden/fullProject/stack.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
resolver: lts-13.27
resolver: nightly-2019-12-20

extra-deps: [base-noprelude-4.12.0.0]
extra-deps: [base-noprelude-4.13.0.0]
5 changes: 3 additions & 2 deletions summoner-cli/test/golden/smallProject/smallProject.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ copyright: 2018 Kowainik
build-type: Simple
extra-doc-files: README.md
, CHANGELOG.md
tested-with: GHC == 8.6.5
tested-with: GHC == 8.8.1

executable smallProject
hs-source-dirs: app
main-is: Main.hs

build-depends: base ^>= 4.12.0.0
build-depends: base ^>= 4.13.0.0



Expand All @@ -32,5 +32,6 @@ executable smallProject
-fhide-source-paths
-Wmissing-export-lists
-Wpartial-fields
-Wmissing-deriving-strategies

default-language: Haskell2010

0 comments on commit 95c7633

Please sign in to comment.