From 800aac9e65177bc45e298a2646cc4b17bb7ab06f Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Fri, 29 Apr 2022 11:58:20 +0100 Subject: [PATCH 01/11] simplify hlint plugin Cabal descriptor - the ghc-lib flag is unnecessary, we want to use ghc-lib always for maximum compatibility - the hlint34 flag is unnecessary, we can trust cabal to use the right version --- cabal-ghc90.project | 1 - cabal-ghc92.project | 5 +- .../hls-hlint-plugin/hls-hlint-plugin.cabal | 51 ++----------------- 3 files changed, 6 insertions(+), 51 deletions(-) diff --git a/cabal-ghc90.project b/cabal-ghc90.project index bdc720312d..06e0d35262 100644 --- a/cabal-ghc90.project +++ b/cabal-ghc90.project @@ -40,7 +40,6 @@ write-ghc-environment-files: never index-state: 2022-04-27T09:22:49Z constraints: - hls-hlint-plugin +ghc-lib -- although we are not building all plugins cabal solver phase is run for all packages -- this way we track explicitly all transitive dependencies which need support for ghc-9 diff --git a/cabal-ghc92.project b/cabal-ghc92.project index c3f074aba4..207b148d7d 100644 --- a/cabal-ghc92.project +++ b/cabal-ghc92.project @@ -34,7 +34,8 @@ with-compiler: ghc-9.2.2 tests: true package * - ghc-options: -haddock + -- ghc 8.10 cannot build ghc-lib 9.2 with --haddock + -- ghc-options: -haddock test-show-details: direct write-ghc-environment-files: never @@ -50,8 +51,6 @@ constraints: -retrie -splice -tactic, - hls-hlint-plugin +ghc-lib, - -- # Use ghc-lib force instead of ghc itself ghc-lib-parser-ex -auto, hlint +ghc-lib, stylish-haskell +ghc-lib diff --git a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal index 2edb560ad3..83bbf098f2 100644 --- a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal +++ b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal @@ -25,19 +25,6 @@ flag pedantic default: False manual: True -flag ghc-lib - default: False - manual: True - description: - Force dependency on ghc-lib-parser even if GHC API in the ghc package is supported - -flag hlint34 - default: True - manual: False - description: - Hlint-3.4 doesn't support versions ghc-lib < 9.0.1 nor ghc <= 8.6, so we can use hlint-3.2 for backwards compat - This flag can be removed when all dependencies support ghc-lib-9.0.* and we drop support for ghc-8.6 - library exposed-modules: Ide.Plugin.Hlint hs-source-dirs: src @@ -56,7 +43,7 @@ library , ghc-exactprint >=0.6.3.4 , ghcide ^>=1.7 , hashable - , hlint + , hlint < 3.5 , hls-plugin-api ^>=1.4 , hslogger , lens @@ -69,41 +56,11 @@ library , transformers , unordered-containers , apply-refact >=0.9.0.0 - -- can be removed if https://github.com/ndmitchell/hlint/pull/1325#issue-1077062712 is merged - -- and https://github.com/haskell/haskell-language-server/pull/2464#issue-1077133441 is updated - -- accordingly + , ghc-lib + , ghc-lib-parser , ghc-lib-parser-ex - if (flag(hlint34)) - -- This mirrors the logic in hlint.cabal for hlint-3.3 - -- https://github.com/ndmitchell/hlint/blob/d3576de4529d8df6cca5a345f5b7e04474ff7bff/hlint.cabal#L79-L88 - -- so we can make sure that we do the same thing as hlint - build-depends: hlint ^>=3.4 - - if (!flag(ghc-lib) && impl(ghc >=9.0.1) && impl(ghc <9.1.0)) - build-depends: ghc ==9.0.* - else - build-depends: - , ghc-lib ^>=9.2 - , ghc-lib-parser-ex ^>=9.2 - , ghc-lib-parser ^>=9.2 - - cpp-options: -DHLINT_ON_GHC_LIB - - else - -- This mirrors the logic in hlint.cabal for hlint-3.2 - -- https://github.com/ndmitchell/hlint/blob/c7354e473c7d09213c8adc3dc94bf50a6eb4a42d/hlint.cabal#L79-L88 - build-depends: hlint ^>=3.2 - if (!flag(ghc-lib) && impl(ghc >=8.10.1) && impl(ghc < 8.11.0)) - build-depends: ghc >=8.10 && <9.0 - else - build-depends: - , ghc - , ghc-lib ^>=8.10.7.20210828 - , ghc-lib-parser-ex ^>=8.10 - - cpp-options: -DHLINT_ON_GHC_LIB - + cpp-options: -DHLINT_ON_GHC_LIB ghc-options: -Wall -Wredundant-constraints -Wno-name-shadowing -Wno-unticked-promoted-constructors From 78785b41a6c09dde05768a2a7223490f9c8e9757 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Fri, 29 Apr 2022 12:53:43 +0100 Subject: [PATCH 02/11] update stack descriptors --- stack-lts16.yaml | 2 -- stack-lts19.yaml | 4 ---- stack.yaml | 3 --- 3 files changed, 9 deletions(-) diff --git a/stack-lts16.yaml b/stack-lts16.yaml index 58d81a652e..4bf838bc94 100644 --- a/stack-lts16.yaml +++ b/stack-lts16.yaml @@ -106,8 +106,6 @@ flags: BuildExecutable: false # Stack doesn't support automatic flags. # Until the formatters support ghc-lib-9, we need this flag disabled - hls-hlint-plugin: - hlint34: false hyphenation: embed: true diff --git a/stack-lts19.yaml b/stack-lts19.yaml index 1c7789869b..99046a8807 100644 --- a/stack-lts19.yaml +++ b/stack-lts19.yaml @@ -67,10 +67,6 @@ flags: retrie: BuildExecutable: false # Stack doesn't support automatic flags. - # Until the formatters support ghc-lib-9, we need this flag disabled - hls-hlint-plugin: - hlint34: true - ghc-lib: true hyphenation: embed: true diff --git a/stack.yaml b/stack.yaml index ef240e9e53..ffd0a81ac5 100644 --- a/stack.yaml +++ b/stack.yaml @@ -82,9 +82,6 @@ flags: retrie: BuildExecutable: false # Stack doesn't support automatic flags. - hls-hlint-plugin: - hlint34: true - ghc-lib: true # Use ghc-lib force instead of ghc itself ghc-lib-parser-ex: auto: false From 416ea9bdd5783be2db39c4ece25519df355644cf Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Fri, 29 Apr 2022 13:19:52 +0100 Subject: [PATCH 03/11] enable hlint:ghc-lib on all stack descriptors --- stack-lts16.yaml | 4 ++-- stack-lts19.yaml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/stack-lts16.yaml b/stack-lts16.yaml index 4bf838bc94..178966c1c4 100644 --- a/stack-lts16.yaml +++ b/stack-lts16.yaml @@ -104,10 +104,10 @@ flags: pedantic: true retrie: BuildExecutable: false - # Stack doesn't support automatic flags. - # Until the formatters support ghc-lib-9, we need this flag disabled hyphenation: embed: true + hlint: + ghc-lib: true nix: packages: [icu libcxx zlib] diff --git a/stack-lts19.yaml b/stack-lts19.yaml index 99046a8807..3ea5eee80a 100644 --- a/stack-lts19.yaml +++ b/stack-lts19.yaml @@ -69,6 +69,8 @@ flags: # Stack doesn't support automatic flags. hyphenation: embed: true + hlint: + ghc-lib: true nix: packages: [ icu libcxx zlib ] From bccca778d23128fb87c4348f96924677d36880c8 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Fri, 29 Apr 2022 17:57:58 +0100 Subject: [PATCH 04/11] undo -haddock change in cabal-ghc92.project --- cabal-ghc92.project | 3 +-- cabal.project | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cabal-ghc92.project b/cabal-ghc92.project index 207b148d7d..f6073c4338 100644 --- a/cabal-ghc92.project +++ b/cabal-ghc92.project @@ -34,8 +34,7 @@ with-compiler: ghc-9.2.2 tests: true package * - -- ghc 8.10 cannot build ghc-lib 9.2 with --haddock - -- ghc-options: -haddock + ghc-options: -haddock test-show-details: direct write-ghc-environment-files: never diff --git a/cabal.project b/cabal.project index 2057ab1ab4..69fad8a4ad 100644 --- a/cabal.project +++ b/cabal.project @@ -37,7 +37,8 @@ optional-packages: vendored/*/*.cabal tests: true package * - ghc-options: -haddock + -- ghc 8.10 cannot build ghc-lib 9.2 with --haddock + -- ghc-options: -haddock test-show-details: direct write-ghc-environment-files: never From 2f3005afb4e13e9ec7c8a4fc267af61212fb217e Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Fri, 29 Apr 2022 17:59:53 +0100 Subject: [PATCH 05/11] enable hlint+ghc-lib in cabal.project --- cabal.project | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index 69fad8a4ad..38b412e6b1 100644 --- a/cabal.project +++ b/cabal.project @@ -46,7 +46,8 @@ write-ghc-environment-files: never index-state: 2022-03-08T10:53:01Z constraints: - hyphenation +embed + hyphenation +embed, + hlint +ghc-lib allow-newer: -- for shake-bench From 2c95c45f1fc989921fb3ca0e5257f676eeacf5ea Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Fri, 29 Apr 2022 18:29:35 +0100 Subject: [PATCH 06/11] bump index-state to grab the latest hlint --- cabal.project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index 38b412e6b1..5324d11799 100644 --- a/cabal.project +++ b/cabal.project @@ -43,7 +43,7 @@ package * write-ghc-environment-files: never -index-state: 2022-03-08T10:53:01Z +index-state: 2022-04-27T09:22:49Z constraints: hyphenation +embed, From 45a437de71ee5a9cd213038a49466bd77feaf76c Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 6 Mar 2022 13:55:36 +0000 Subject: [PATCH 07/11] hie-compat does not build with ghc-lib-9.x --- hie-compat/hie-compat.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hie-compat/hie-compat.cabal b/hie-compat/hie-compat.cabal index 143df06d44..13b0cb3ef1 100644 --- a/hie-compat/hie-compat.cabal +++ b/hie-compat/hie-compat.cabal @@ -25,7 +25,7 @@ library build-depends: base < 4.17, array, bytestring, containers, directory, filepath, transformers if flag(ghc-lib) - build-depends: ghc-lib + build-depends: ghc-lib < 9.0 else build-depends: ghc, ghc-boot if (impl(ghc >= 9.0) && impl(ghc < 9.1)) From 5b7ddeed8846c87e3da838200f457a32990ede35 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Fri, 29 Apr 2022 19:58:25 +0100 Subject: [PATCH 08/11] Drop support for building hie-compat with ghc-lib --- .github/workflows/flags.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml index 387c5ea804..2283899d0c 100644 --- a/.github/workflows/flags.yml +++ b/.github/workflows/flags.yml @@ -64,10 +64,6 @@ jobs: - name: Build `hls-graph` with flags run: cabal v2-build hls-graph --flags="embed-files stm-stats" - - if: matrix.ghc != '8.6.5' && matrix.ghc != '8.8.4' - name: Build `hie-compat` with flags - run: cabal v2-build hie-compat --flags="ghc-lib" - - name: Build `ghcide` with flags run: cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" From f47f1b4e8fb511cb4031e75fee19d07b23fe02c9 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sat, 30 Apr 2022 01:27:32 +0100 Subject: [PATCH 09/11] fix hlint test --- plugins/hls-hlint-plugin/test/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-hlint-plugin/test/Main.hs b/plugins/hls-hlint-plugin/test/Main.hs index 6aa4966aad..ee1ab380d6 100644 --- a/plugins/hls-hlint-plugin/test/Main.hs +++ b/plugins/hls-hlint-plugin/test/Main.hs @@ -371,7 +371,7 @@ disableHlint = sendConfigurationChanged $ toJSON $ def { Plugin.plugins = Map.fr -- Although a given hlint version supports one direct ghc, we could use several versions of hlint -- each one supporting a different ghc version. It should be a temporary situation though. knownBrokenForHlintOnGhcLib :: String -> TestTree -> TestTree -knownBrokenForHlintOnGhcLib = knownBrokenForGhcVersions [GHC86, GHC88, GHC90, GHC92] +knownBrokenForHlintOnGhcLib = expectFailBecause -- 1's based data Point = Point { From 4e28e29adcd2dc07c5586af8b800fbc14db16f00 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 1 May 2022 15:49:50 +0100 Subject: [PATCH 10/11] add a comment on hlint +ghc-lib flag --- cabal.project | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cabal.project b/cabal.project index 5324d11799..ea1114f19a 100644 --- a/cabal.project +++ b/cabal.project @@ -47,6 +47,8 @@ index-state: 2022-04-27T09:22:49Z constraints: hyphenation +embed, + -- remove this when hlint sets ghc-lib to true by default + -- https://github.com/ndmitchell/hlint/issues/1376 hlint +ghc-lib allow-newer: From 06814ff230bbebcecd62fb326c1676f04e7cdeb9 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 1 May 2022 16:52:11 +0100 Subject: [PATCH 11/11] restore the ghc-lib flag now with a default True --- plugins/hls-hlint-plugin/hls-hlint-plugin.cabal | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal index 83bbf098f2..d17d788be9 100644 --- a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal +++ b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal @@ -25,6 +25,11 @@ flag pedantic default: False manual: True +flag ghc-lib + default: True + manual: True + description: Use ghc-lib types (requires hlint to be built with ghc-lib) + library exposed-modules: Ide.Plugin.Hlint hs-source-dirs: src