From cb6ad8cbcdcdd130d9776c6da841077199809d3c Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 27 Dec 2021 23:20:54 +0100 Subject: [PATCH 01/32] Enable tests for brittany and 9.0.2 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d52f515ea..8181377bab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -221,7 +221,7 @@ jobs: run: cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper" || cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper" || cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper" - - if: matrix.test && matrix.ghc != '9.0.1' + - if: matrix.test name: Test hls-brittany-plugin run: cabal test hls-brittany-plugin --test-options="$TEST_OPTS" || cabal test hls-brittany-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-brittany-plugin --test-options="$TEST_OPTS" From 4dc94ce73674e8c7e792f6427e604fa794f2cbb4 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 27 Dec 2021 23:32:33 +0100 Subject: [PATCH 02/32] Enable tests for floskell plugin --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8181377bab..ef99e84819 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -225,6 +225,10 @@ jobs: name: Test hls-brittany-plugin run: cabal test hls-brittany-plugin --test-options="$TEST_OPTS" || cabal test hls-brittany-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-brittany-plugin --test-options="$TEST_OPTS" + - if: matrix.test + name: Test hls-floskell-plugin + run: cabal test hls-floskell-plugin --test-options="$TEST_OPTS" || cabal test hls-floskell-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-floskell-plugin --test-options="$TEST_OPTS" + - if: matrix.test name: Test hls-class-plugin run: cabal test hls-class-plugin --test-options="$TEST_OPTS" || cabal test hls-class-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-class-plugin --test-options="$TEST_OPTS" From e2822c22c940a65da5edf88212561a62e1223686 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Sun, 12 Dec 2021 15:07:17 +0200 Subject: [PATCH 03/32] cabal-ghc901.project: naively enable brittany --- cabal-ghc901.project | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index f813020ae7..7b531a0114 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -41,19 +41,12 @@ index-state: 2021-12-29T12:30:08Z constraints: -- These plugins don't work on GHC9 yet - haskell-language-server +ignore-plugins-ghc-bounds -brittany -stylishhaskell -tactic, + haskell-language-server +ignore-plugins-ghc-bounds -class -stylishhaskell -tactic, ghc-lib-parser ^>= 9.0 -- 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 allow-newer: - brittany:base, - brittany:ghc, - brittany:ghc-boot-th, - -- for brittany - butcher:base, - multistate:base, - data-tree-print:base, stylish-haskell:Cabal, stylish-haskell:ghc-lib-parser, From 3b46968ea9a1721c727d38f1682e63a5a514e11a Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Sun, 12 Dec 2021 15:33:44 +0200 Subject: [PATCH 04/32] haskell-language-server.cabal: bump brittany flag <(9.0.1->9.2.1) --- haskell-language-server.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index c35e8c0a37..468e1065d6 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -303,7 +303,7 @@ common stylishHaskell cpp-options: -DstylishHaskell common brittany - if flag(brittany) && (impl(ghc < 9.0.1) || flag(ignore-plugins-ghc-bounds)) + if flag(brittany) && (impl(ghc < 9.2.1) || flag(ignore-plugins-ghc-bounds)) build-depends: hls-brittany-plugin ^>=1.0.0.1 cpp-options: -Dbrittany From 40b48da754695837a05a796dd970a0733fcd0333 Mon Sep 17 00:00:00 2001 From: jneira Date: Sun, 12 Dec 2021 23:35:36 +0100 Subject: [PATCH 05/32] Trying to add support for brittany --- cabal-ghc901.project | 3 +++ ghcide/ghcide.cabal | 3 +-- plugins/hls-hlint-plugin/hls-hlint-plugin.cabal | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index 7b531a0114..b5d900e6aa 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -48,6 +48,9 @@ constraints: -- this way we track explicitly all transitive dependencies which need support for ghc-9 allow-newer: + -- brittany + multistate:base, + stylish-haskell:Cabal, stylish-haskell:ghc-lib-parser, diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index c10923c66f..acefcc407d 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -49,8 +49,7 @@ library dependent-sum, dlist, exceptions, - -- we can't use >= 1.7.10 while we have to use hlint == 3.2.* - extra >= 1.7.4 && < 1.7.10, + extra >= 1.7.4, fuzzy, filepath, fingertree, diff --git a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal index 2b21de18e2..994c50fa8b 100644 --- a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal +++ b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal @@ -92,6 +92,7 @@ library -- 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 + , extra < 1.7.10 if (!flag(ghc-lib) && impl(ghc >=8.10.1) && impl(ghc < 8.11.0)) build-depends: ghc >=8.10 && <9.0 else From 6d48732a4fed2d1cd74a7429f8c6c38cc87d192e Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 14 Dec 2021 22:32:47 +0100 Subject: [PATCH 06/32] Use last hackage floskell version --- cabal-ghc901.project | 1 + haskell-language-server.cabal | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index b5d900e6aa..6dcf077eb9 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -41,6 +41,7 @@ index-state: 2021-12-29T12:30:08Z constraints: -- These plugins don't work on GHC9 yet + -- Add a plugin needs remove the -flag but also update ghc bounds in hls.cabal haskell-language-server +ignore-plugins-ghc-bounds -class -stylishhaskell -tactic, ghc-lib-parser ^>= 9.0 diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 468e1065d6..0b93c123fb 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -283,7 +283,7 @@ common qualifyImportedNames -- formatters common floskell - if flag(floskell) && (impl(ghc < 9.0.1) || flag(ignore-plugins-ghc-bounds)) + if flag(floskell) && (impl(ghc < 9.2.1) || flag(ignore-plugins-ghc-bounds)) build-depends: hls-floskell-plugin ^>=1.0.0.0 cpp-options: -Dfloskell From 159d5075869fe8967cd3c84ceafbdb5fc1d74c72 Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 21 Dec 2021 18:21:29 +0100 Subject: [PATCH 07/32] Activate floskell in func-test suite --- haskell-language-server.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 0b93c123fb..fefb834cfa 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -472,7 +472,7 @@ test-suite func-test if flag(eval) cpp-options: -Deval -- formatters - if flag(floskell) && (impl(ghc < 9.0.1) || flag(ignore-plugins-ghc-bounds)) + if flag(floskell) && (impl(ghc < 9.2.1) || flag(ignore-plugins-ghc-bounds)) cpp-options: -Dfloskell if flag(fourmolu) && (impl(ghc < 9.2.1) || flag(ignore-plugins-ghc-bounds)) cpp-options: -Dfourmolu From 0cd1c525a0938c9a89c9edbeb11f1651b2fd8225 Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 21 Dec 2021 19:32:36 +0100 Subject: [PATCH 08/32] Restrict brittany in hackage for ghc<9.0.1 --- cabal-ghc901.project | 7 ++++++- haskell-language-server.cabal | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index 6dcf077eb9..9747d5d155 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -49,8 +49,13 @@ constraints: -- this way we track explicitly all transitive dependencies which need support for ghc-9 allow-newer: - -- brittany + -- brittany: update ghc bounds in hls.cabal when those are removed + -- https://github.com/lspitzner/multistate/pull/8 multistate:base, + -- https://github.com/lspitzner/data-tree-print/pull/3 + data-tree-print:base, + -- https://github.com/lspitzner/butcher/issues/7 + butcher:base, stylish-haskell:Cabal, stylish-haskell:ghc-lib-parser, diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index fefb834cfa..8cddd65ffe 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -303,7 +303,7 @@ common stylishHaskell cpp-options: -DstylishHaskell common brittany - if flag(brittany) && (impl(ghc < 9.2.1) || flag(ignore-plugins-ghc-bounds)) + if flag(brittany) && (impl(ghc < 9.0.1) || flag(ignore-plugins-ghc-bounds)) build-depends: hls-brittany-plugin ^>=1.0.0.1 cpp-options: -Dbrittany From 7eb59aeb9979cefa050c5c5333062ef0ad8d08ba Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 21 Dec 2021 20:31:34 +0100 Subject: [PATCH 09/32] Adapt to Aeson.Key --- hls-plugin-api/src/Ide/Plugin/Properties.hs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hls-plugin-api/src/Ide/Plugin/Properties.hs b/hls-plugin-api/src/Ide/Plugin/Properties.hs index 2201cf2a53..dc2557461f 100644 --- a/hls-plugin-api/src/Ide/Plugin/Properties.hs +++ b/hls-plugin-api/src/Ide/Plugin/Properties.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} @@ -41,6 +42,9 @@ module Ide.Plugin.Properties where import qualified Data.Aeson as A +#if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.Key as A.Key +#endif import qualified Data.Aeson.Types as A import Data.Either (fromRight) import Data.Function ((&)) @@ -162,6 +166,15 @@ type HasProperty s k t r = (k ~ 'PropertyKey s t, Elem s r, FindByKeyName s r ~ -- "Description of exampleNumber" -- 233 -- @ + +#if MIN_VERSION_aeson(2,0,0) +toKey :: String -> A.Key +toKey = A.Key.fromString +#else +toKey :: String -> T.Text +toKey = pack +#endif + emptyProperties :: Properties '[] emptyProperties = Properties Map.empty @@ -247,7 +260,7 @@ parseProperty kn k x = case k of ) x where - keyName = T.pack $ symbolVal kn + keyName = toKey $ symbolVal kn parseEither :: forall a. A.FromJSON a => Either String a parseEither = A.parseEither (A..: keyName) x @@ -352,7 +365,7 @@ toDefaultJSON :: Properties r -> [A.Pair] toDefaultJSON (Properties p) = [toEntry s v | (s, v) <- Map.toList p] where toEntry :: String -> SomePropertyKeyWithMetaData -> A.Pair - toEntry (T.pack -> s) = \case + toEntry (toKey -> s) = \case (SomePropertyKeyWithMetaData SNumber MetaData {..}) -> s A..= defaultValue (SomePropertyKeyWithMetaData SInteger MetaData {..}) -> @@ -371,7 +384,7 @@ toDefaultJSON (Properties p) = [toEntry s v | (s, v) <- Map.toList p] -- | Converts a properties definition into kv pairs as vscode schema toVSCodeExtensionSchema :: T.Text -> Properties r -> [A.Pair] toVSCodeExtensionSchema prefix (Properties p) = - [(prefix <> T.pack k) A..= toEntry v | (k, v) <- Map.toList p] + [(toKey $ T.unpack prefix <> k) A..= toEntry v | (k, v) <- Map.toList p] where toEntry :: SomePropertyKeyWithMetaData -> A.Value toEntry = \case From aa29a92f1f373dd1abc78eec4f7dcc26da2bde3c Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 21 Dec 2021 20:40:17 +0100 Subject: [PATCH 10/32] Update lsp source repo package --- cabal-ghc901.project | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index 9747d5d155..73e174a517 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -27,6 +27,15 @@ packages: ./plugins/hls-call-hierarchy-plugin ./plugins/hls-alternate-number-format-plugin +-- lsp needs a release with support for aeson >= 2.0 +-- see https://github.com/haskell/lsp/issues/373 + +source-repository-package + type: git + location: https://github.com/haskell/lsp + tag: b48cf78d52152e13bd402d530dd4ceb7ad91b750 + subdir: lsp lsp-types lsp-test + with-compiler: ghc-9.0.1 tests: true From 0a709644752d8ae29c7b23890638c7e15d9a226d Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 21 Dec 2021 21:04:13 +0100 Subject: [PATCH 11/32] Refer pr for butcher --- cabal-ghc901.project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index 73e174a517..e789766e39 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -63,7 +63,7 @@ allow-newer: multistate:base, -- https://github.com/lspitzner/data-tree-print/pull/3 data-tree-print:base, - -- https://github.com/lspitzner/butcher/issues/7 + -- https://github.com/lspitzner/butcher/pull/8 butcher:base, stylish-haskell:Cabal, From ab79e36458407690c87600ed45507274b7c328a7 Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 21 Dec 2021 22:20:53 +0100 Subject: [PATCH 12/32] Add missing prefix --- hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 11 ++++++++--- hls-plugin-api/src/Ide/Plugin/Properties.hs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index 411311106d..38e32d285b 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} @@ -10,7 +11,11 @@ import qualified Data.Aeson.Types as A import Data.Default (def) import qualified Data.Dependent.Map as DMap import qualified Data.Dependent.Sum as DSum -import qualified Data.HashMap.Lazy as HMap +#if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.KeyMap as Map +#else +import qualified Data.HasMap.Lazy as Map +#endif import Data.List (nub) import Ide.Plugin.Config import Ide.Plugin.Properties (toDefaultJSON, toVSCodeExtensionSchema) @@ -26,9 +31,9 @@ import Language.LSP.Types pluginsToDefaultConfig :: IdePlugins a -> A.Value pluginsToDefaultConfig IdePlugins {..} = A.Object $ - HMap.adjust + Map.alter ( \(unsafeValueToObject -> o) -> - A.Object $ HMap.insert "plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged + Just $ A.Object $ Map.insert "plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged ) "haskell" (unsafeValueToObject (A.toJSON defaultConfig)) diff --git a/hls-plugin-api/src/Ide/Plugin/Properties.hs b/hls-plugin-api/src/Ide/Plugin/Properties.hs index dc2557461f..2aa4772ca6 100644 --- a/hls-plugin-api/src/Ide/Plugin/Properties.hs +++ b/hls-plugin-api/src/Ide/Plugin/Properties.hs @@ -172,7 +172,7 @@ toKey :: String -> A.Key toKey = A.Key.fromString #else toKey :: String -> T.Text -toKey = pack +toKey = T.pack #endif emptyProperties :: Properties '[] From 08c5d94080d0e4838b7e4e74a09ab5fef6c9106c Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 21 Dec 2021 23:11:00 +0100 Subject: [PATCH 13/32] Adapt to aeson-2 (incomplete) --- hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 26 ++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index 38e32d285b..c5144daa4a 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -12,16 +12,28 @@ import Data.Default (def) import qualified Data.Dependent.Map as DMap import qualified Data.Dependent.Sum as DSum #if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.Key as A.Key import qualified Data.Aeson.KeyMap as Map #else -import qualified Data.HasMap.Lazy as Map +import qualified Data.HashMap.Lazy as Map #endif +import Data.Functor.Identity import Data.List (nub) +import Data.Maybe (fromJust) +import Data.Text (Text) import Ide.Plugin.Config import Ide.Plugin.Properties (toDefaultJSON, toVSCodeExtensionSchema) import Ide.Types import Language.LSP.Types +#if MIN_VERSION_aeson(2,0,0) +toKey :: Text -> A.Key +toKey = A.Key.fromText +#else +toKey :: Text -> Text +toKey = id +#endif + -- Attention: -- 'diagnosticsOn' will never be added into the default config or the schema, -- since diagnostics emit in arbitrary shake rules -- we don't know @@ -30,10 +42,10 @@ import Language.LSP.Types -- | Generates a default 'Config', but remains only effective items pluginsToDefaultConfig :: IdePlugins a -> A.Value pluginsToDefaultConfig IdePlugins {..} = - A.Object $ - Map.alter - ( \(unsafeValueToObject -> o) -> - Just $ A.Object $ Map.insert "plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged + A.Object $ runIdentity $ + Map.alterF + ( \(unsafeValueToObject . fromJust -> o) -> + Identity $ Just $ A.Object $ Map.insert "plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged ) "haskell" (unsafeValueToObject (A.toJSON defaultConfig)) @@ -57,7 +69,7 @@ pluginsToDefaultConfig IdePlugins {..} = -- } singlePlugin PluginDescriptor {pluginConfigDescriptor = ConfigDescriptor {..}, ..} = let x = genericDefaultConfig <> dedicatedDefaultConfig - in [pId A..= A.object x | not $ null x] + in [(toKey pId) A..= A.object x | not $ null x] where (PluginHandlers (DMap.toList -> handlers)) = pluginHandlers customConfigToDedicatedDefaultConfig (CustomConfig p) = toDefaultJSON p @@ -136,4 +148,4 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug "default" A..= True, "description" A..= A.String ("Enables " <> pId <> " " <> desc) ] - withIdPrefix x = "haskell.plugin." <> pId <> "." <> x + withIdPrefix x = toKey $ "haskell.plugin." <> pId <> "." <> x From dfe6e376cd7a80cf56a12b05a0afe4adc6d40e29 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 22 Dec 2021 23:40:13 +0100 Subject: [PATCH 14/32] Use compat module --- ghcide/src/Control/Concurrent/Strict.hs | 10 +++--- ghcide/src/Development/IDE/GHC/Orphans.hs | 11 +++--- hls-plugin-api/hls-plugin-api.cabal | 1 + hls-plugin-api/src/Ide/Compat.hs | 27 ++++++++++++++ hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 38 +++++++------------- hls-plugin-api/src/Ide/Plugin/Properties.hs | 21 +++-------- 6 files changed, 56 insertions(+), 52 deletions(-) create mode 100644 hls-plugin-api/src/Ide/Compat.hs diff --git a/ghcide/src/Control/Concurrent/Strict.hs b/ghcide/src/Control/Concurrent/Strict.hs index 2a33e5284b..3cbfd31a20 100644 --- a/ghcide/src/Control/Concurrent/Strict.hs +++ b/ghcide/src/Control/Concurrent/Strict.hs @@ -1,28 +1,26 @@ module Control.Concurrent.Strict (modifyVar', modifyVarIO' ,modifyVar, modifyVar_ - ,module Control.Concurrent.Extra ) where -import Control.Concurrent.Extra hiding (modifyVar, modifyVar_) import qualified Control.Concurrent.Extra as Extra import Control.Exception (evaluate) import Control.Monad (void) import Data.Tuple.Extra (dupe) -- | Strict modification that returns the new value -modifyVar' :: Var a -> (a -> a) -> IO a +modifyVar' :: Extra.Var a -> (a -> a) -> IO a modifyVar' var upd = modifyVarIO' var (pure . upd) -- | Strict modification that returns the new value -modifyVarIO' :: Var a -> (a -> IO a) -> IO a +modifyVarIO' :: Extra.Var a -> (a -> IO a) -> IO a modifyVarIO' var upd = do res <- Extra.modifyVar var $ \v -> do v' <- upd v pure $ dupe v' evaluate res -modifyVar :: Var a -> (a -> IO (a, b)) -> IO b +modifyVar :: Extra.Var a -> (a -> IO (a, b)) -> IO b modifyVar var upd = do (new, res) <- Extra.modifyVar var $ \old -> do (new,res) <- upd old @@ -30,5 +28,5 @@ modifyVar var upd = do void $ evaluate new return res -modifyVar_ :: Var a -> (a -> IO a) -> IO () +modifyVar_ :: Extra.Var a -> (a -> IO a) -> IO () modifyVar_ var upd = void $ modifyVarIO' var upd diff --git a/ghcide/src/Development/IDE/GHC/Orphans.hs b/ghcide/src/Development/IDE/GHC/Orphans.hs index a04fd1e86d..1891033247 100644 --- a/ghcide/src/Development/IDE/GHC/Orphans.hs +++ b/ghcide/src/Development/IDE/GHC/Orphans.hs @@ -31,6 +31,7 @@ import Retrie.ExactPrint (Annotated) import Development.IDE.GHC.Compat import Development.IDE.GHC.Util +import Ide.Compat (toJsonKey) import Control.DeepSeq import Data.Aeson @@ -132,11 +133,11 @@ srcSpanEndColTag = "srcSpanEndCol" instance ToJSON RealSrcSpan where toJSON spn = object - [ srcSpanFileTag .= unpackFS (srcSpanFile spn) - , srcSpanStartLineTag .= srcSpanStartLine spn - , srcSpanStartColTag .= srcSpanStartCol spn - , srcSpanEndLineTag .= srcSpanEndLine spn - , srcSpanEndColTag .= srcSpanEndCol spn + [ toJsonKey srcSpanFileTag .= unpackFS (srcSpanFile spn) + , toJsonKey srcSpanStartLineTag .= srcSpanStartLine spn + , toJsonKey srcSpanStartColTag .= srcSpanStartCol spn + , toJsonKey srcSpanEndLineTag .= srcSpanEndLine spn + , toJsonKey srcSpanEndColTag .= srcSpanEndCol spn ] instance FromJSON RealSrcSpan where diff --git a/hls-plugin-api/hls-plugin-api.cabal b/hls-plugin-api/hls-plugin-api.cabal index 12c66bc3cd..4ce1b65f16 100644 --- a/hls-plugin-api/hls-plugin-api.cabal +++ b/hls-plugin-api/hls-plugin-api.cabal @@ -26,6 +26,7 @@ source-repository head library exposed-modules: + Ide.Compat Ide.Logger Ide.Plugin.Config Ide.Plugin.ConfigUtils diff --git a/hls-plugin-api/src/Ide/Compat.hs b/hls-plugin-api/src/Ide/Compat.hs new file mode 100644 index 0000000000..6a110ed401 --- /dev/null +++ b/hls-plugin-api/src/Ide/Compat.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE CPP #-} +module Ide.Compat where + +#if MIN_VERSION_aeson(2,0,0) +import Data.Aeson.Key as A (Key) +import qualified Data.Aeson.Key as A.Key +import qualified Data.Aeson.KeyMap as Map +#else +import qualified Data.HashMap.Lazy as Map +#endif +import Data.Text as T + +#if MIN_VERSION_aeson(2,0,0) +toJsonKey :: T.Text -> A.Key +toJsonKey = A.Key.fromText +#else +toJsonKey :: T.Text -> T.Text +toJsonKey = id +#endif + +#if MIN_VERSION_aeson(2,0,0) +toJsonKey :: T.Text -> A.Key +toJsonKey = A.Key.fromText +#else +toJsonKey :: T.Text -> T.Text +toJsonKey = id +#endif diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index c5144daa4a..a5752dacd6 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} @@ -11,29 +10,17 @@ import qualified Data.Aeson.Types as A import Data.Default (def) import qualified Data.Dependent.Map as DMap import qualified Data.Dependent.Sum as DSum -#if MIN_VERSION_aeson(2,0,0) -import qualified Data.Aeson.Key as A.Key -import qualified Data.Aeson.KeyMap as Map -#else -import qualified Data.HashMap.Lazy as Map -#endif import Data.Functor.Identity +import qualified Data.HashMap.Lazy as Map import Data.List (nub) import Data.Maybe (fromJust) import Data.Text (Text) +import Ide.Compat (toKey) import Ide.Plugin.Config import Ide.Plugin.Properties (toDefaultJSON, toVSCodeExtensionSchema) import Ide.Types import Language.LSP.Types -#if MIN_VERSION_aeson(2,0,0) -toKey :: Text -> A.Key -toKey = A.Key.fromText -#else -toKey :: Text -> Text -toKey = id -#endif - -- Attention: -- 'diagnosticsOn' will never be added into the default config or the schema, -- since diagnostics emit in arbitrary shake rules -- we don't know @@ -124,22 +111,22 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug (PluginId pId) = pluginId genericSchema = let x = - [withIdPrefix "diagnosticsOn" A..= schemaEntry "diagnostics" | configHasDiagnostics] + [toKey' "diagnosticsOn" A..= schemaEntry "diagnostics" | configHasDiagnostics] <> nub (mconcat (handlersToGenericSchema <$> handlers)) in case x of -- If the plugin has only one capability, we produce globalOn instead of the specific one; -- otherwise we don't produce globalOn at all - [_] -> [withIdPrefix "globalOn" A..= schemaEntry "plugin"] + [_] -> [toKey' "globalOn" A..= schemaEntry "plugin"] _ -> x dedicatedSchema = customConfigToDedicatedSchema configCustomConfig handlersToGenericSchema (IdeMethod m DSum.:=> _) = case m of - STextDocumentCodeAction -> [withIdPrefix "codeActionsOn" A..= schemaEntry "code actions"] - STextDocumentCodeLens -> [withIdPrefix "codeLensOn" A..= schemaEntry "code lenses"] - STextDocumentRename -> [withIdPrefix "renameOn" A..= schemaEntry "rename"] - STextDocumentHover -> [withIdPrefix "hoverOn" A..= schemaEntry "hover"] - STextDocumentDocumentSymbol -> [withIdPrefix "symbolsOn" A..= schemaEntry "symbols"] - STextDocumentCompletion -> [withIdPrefix "completionOn" A..= schemaEntry "completions"] - STextDocumentPrepareCallHierarchy -> [withIdPrefix "callHierarchyOn" A..= schemaEntry "call hierarchy"] + STextDocumentCodeAction -> [toKey' "codeActionsOn" A..= schemaEntry "code actions"] + STextDocumentCodeLens -> [toKey' "codeLensOn" A..= schemaEntry "code lenses"] + STextDocumentRename -> [toKey' "renameOn" A..= schemaEntry "rename"] + STextDocumentHover -> [toKey' "hoverOn" A..= schemaEntry "hover"] + STextDocumentDocumentSymbol -> [toKey' "symbolsOn" A..= schemaEntry "symbols"] + STextDocumentCompletion -> [toKey' "completionOn" A..= schemaEntry "completions"] + STextDocumentPrepareCallHierarchy -> [toKey' "callHierarchyOn" A..= schemaEntry "call hierarchy"] _ -> [] schemaEntry desc = A.object @@ -148,4 +135,5 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug "default" A..= True, "description" A..= A.String ("Enables " <> pId <> " " <> desc) ] - withIdPrefix x = toKey $ "haskell.plugin." <> pId <> "." <> x + withIdPrefix x = "haskell.plugin." <> pId <> "." <> x + toKey' = toJsonKey . withIdPrefix diff --git a/hls-plugin-api/src/Ide/Plugin/Properties.hs b/hls-plugin-api/src/Ide/Plugin/Properties.hs index 2aa4772ca6..6fc594ce2b 100644 --- a/hls-plugin-api/src/Ide/Plugin/Properties.hs +++ b/hls-plugin-api/src/Ide/Plugin/Properties.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} @@ -42,9 +41,6 @@ module Ide.Plugin.Properties where import qualified Data.Aeson as A -#if MIN_VERSION_aeson(2,0,0) -import qualified Data.Aeson.Key as A.Key -#endif import qualified Data.Aeson.Types as A import Data.Either (fromRight) import Data.Function ((&)) @@ -54,6 +50,7 @@ import Data.Proxy (Proxy (..)) import qualified Data.Text as T import GHC.OverloadedLabels (IsLabel (..)) import GHC.TypeLits +import Ide.Types (toJsonKey) import Unsafe.Coerce (unsafeCoerce) -- | Types properties may have @@ -167,14 +164,6 @@ type HasProperty s k t r = (k ~ 'PropertyKey s t, Elem s r, FindByKeyName s r ~ -- 233 -- @ -#if MIN_VERSION_aeson(2,0,0) -toKey :: String -> A.Key -toKey = A.Key.fromString -#else -toKey :: String -> T.Text -toKey = T.pack -#endif - emptyProperties :: Properties '[] emptyProperties = Properties Map.empty @@ -248,7 +237,7 @@ parseProperty kn k x = case k of (SEnum _, EnumMetaData {..}) -> A.parseEither ( \o -> do - txt <- o A..: keyName + txt <- o A..: key if txt `elem` enumValues then pure txt else @@ -260,7 +249,7 @@ parseProperty kn k x = case k of ) x where - keyName = toKey $ symbolVal kn + key = toJsonKey . pack $ symbolVal kn parseEither :: forall a. A.FromJSON a => Either String a parseEither = A.parseEither (A..: keyName) x @@ -365,7 +354,7 @@ toDefaultJSON :: Properties r -> [A.Pair] toDefaultJSON (Properties p) = [toEntry s v | (s, v) <- Map.toList p] where toEntry :: String -> SomePropertyKeyWithMetaData -> A.Pair - toEntry (toKey -> s) = \case + toEntry (toJsonKey . pack -> s) = \case (SomePropertyKeyWithMetaData SNumber MetaData {..}) -> s A..= defaultValue (SomePropertyKeyWithMetaData SInteger MetaData {..}) -> @@ -384,7 +373,7 @@ toDefaultJSON (Properties p) = [toEntry s v | (s, v) <- Map.toList p] -- | Converts a properties definition into kv pairs as vscode schema toVSCodeExtensionSchema :: T.Text -> Properties r -> [A.Pair] toVSCodeExtensionSchema prefix (Properties p) = - [(toKey $ T.unpack prefix <> k) A..= toEntry v | (k, v) <- Map.toList p] + [(toJsonKey prefix <> k) A..= toEntry v | (k, v) <- Map.toList p] where toEntry :: SomePropertyKeyWithMetaData -> A.Value toEntry = \case From dc06c41f408e6f71a6054788df179feb260cad20 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 27 Dec 2021 22:47:19 +0100 Subject: [PATCH 15/32] Support for aeson-2 and extra-1.7.10 --- ghcide/src/Control/Concurrent/Strict.hs | 3 ++ ghcide/src/Development/IDE/GHC/Orphans.hs | 10 +++--- hls-plugin-api/src/Ide/Compat.hs | 31 +++++++++++++------ hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 16 ++++------ hls-plugin-api/src/Ide/Plugin/Properties.hs | 10 +++--- hls-plugin-api/src/Ide/Types.hs | 1 - .../hls-hlint-plugin/hls-hlint-plugin.cabal | 1 - stack-8.10.6.yaml | 2 ++ stack-8.10.7.yaml | 2 ++ stack-8.6.5.yaml | 4 +-- stack-8.8.4.yaml | 3 +- stack-9.0.1.yaml | 12 ++++--- stack.yaml | 2 ++ 13 files changed, 58 insertions(+), 39 deletions(-) diff --git a/ghcide/src/Control/Concurrent/Strict.hs b/ghcide/src/Control/Concurrent/Strict.hs index 3cbfd31a20..842252d51c 100644 --- a/ghcide/src/Control/Concurrent/Strict.hs +++ b/ghcide/src/Control/Concurrent/Strict.hs @@ -1,8 +1,11 @@ module Control.Concurrent.Strict (modifyVar', modifyVarIO' ,modifyVar, modifyVar_ + ,module Control.Concurrent.Extra ) where +import Control.Concurrent.Extra hiding (modifyVar, modifyVar', + modifyVar_) import qualified Control.Concurrent.Extra as Extra import Control.Exception (evaluate) import Control.Monad (void) diff --git a/ghcide/src/Development/IDE/GHC/Orphans.hs b/ghcide/src/Development/IDE/GHC/Orphans.hs index 1891033247..b2352d0718 100644 --- a/ghcide/src/Development/IDE/GHC/Orphans.hs +++ b/ghcide/src/Development/IDE/GHC/Orphans.hs @@ -142,15 +142,15 @@ instance ToJSON RealSrcSpan where instance FromJSON RealSrcSpan where parseJSON = withObject "object" $ \obj -> do - file <- fromString <$> (obj .: srcSpanFileTag) + file <- fromString <$> (obj .: toJsonKey srcSpanFileTag) mkRealSrcSpan <$> (mkRealSrcLoc file - <$> obj .: srcSpanStartLineTag - <*> obj .: srcSpanStartColTag + <$> obj .: toJsonKey srcSpanStartLineTag + <*> obj .: toJsonKey srcSpanStartColTag ) <*> (mkRealSrcLoc file - <$> obj .: srcSpanEndLineTag - <*> obj .: srcSpanEndColTag + <$> obj .: toJsonKey srcSpanEndLineTag + <*> obj .: toJsonKey srcSpanEndColTag ) instance NFData Type where diff --git a/hls-plugin-api/src/Ide/Compat.hs b/hls-plugin-api/src/Ide/Compat.hs index 6a110ed401..026d2e1de6 100644 --- a/hls-plugin-api/src/Ide/Compat.hs +++ b/hls-plugin-api/src/Ide/Compat.hs @@ -1,14 +1,16 @@ -{-# LANGUAGE CPP #-} +{-# LANGUAGE CPP #-} module Ide.Compat where #if MIN_VERSION_aeson(2,0,0) -import Data.Aeson.Key as A (Key) -import qualified Data.Aeson.Key as A.Key -import qualified Data.Aeson.KeyMap as Map +import Data.Aeson.Key as A (Key) +import qualified Data.Aeson.Key as A.Key +import qualified Data.Aeson.KeyMap as A +import Data.Functor.Identity (Identity (..), runIdentity) #else -import qualified Data.HashMap.Lazy as Map +import qualified Data.HashMap.Lazy as Map #endif -import Data.Text as T +import Data.Aeson as A (Value) +import Data.Text as T #if MIN_VERSION_aeson(2,0,0) toJsonKey :: T.Text -> A.Key @@ -19,9 +21,18 @@ toJsonKey = id #endif #if MIN_VERSION_aeson(2,0,0) -toJsonKey :: T.Text -> A.Key -toJsonKey = A.Key.fromText +insertJson :: A.Key -> A.Value -> A.KeyMap A.Value -> A.KeyMap A.Value +insertJson = A.insert #else -toJsonKey :: T.Text -> T.Text -toJsonKey = id +insertJson :: T.Text -> A.Value -> Map.HashMap T.Text A.Value -> Map.HashMap T.Text A.Value +insertJson = Map.insert +#endif + + +#if MIN_VERSION_aeson(2,0,0) +adjustJson :: (A.Value -> A.Value) -> A.Key -> A.KeyMap A.Value -> A.KeyMap A.Value +adjustJson f k = runIdentity . A.alterF (Identity . fmap f) k +#else +adjustJson :: (A.Value -> A.Value) -> T.Text -> Map.HashMap T.Text A.Value -> Map.HashMap T.Text A.Value +adjustJson = Map.adjust #endif diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index a5752dacd6..6f80077c26 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -10,12 +10,8 @@ import qualified Data.Aeson.Types as A import Data.Default (def) import qualified Data.Dependent.Map as DMap import qualified Data.Dependent.Sum as DSum -import Data.Functor.Identity -import qualified Data.HashMap.Lazy as Map import Data.List (nub) -import Data.Maybe (fromJust) -import Data.Text (Text) -import Ide.Compat (toKey) +import Ide.Compat (adjustJson, insertJson, toJsonKey) import Ide.Plugin.Config import Ide.Plugin.Properties (toDefaultJSON, toVSCodeExtensionSchema) import Ide.Types @@ -29,10 +25,10 @@ import Language.LSP.Types -- | Generates a default 'Config', but remains only effective items pluginsToDefaultConfig :: IdePlugins a -> A.Value pluginsToDefaultConfig IdePlugins {..} = - A.Object $ runIdentity $ - Map.alterF - ( \(unsafeValueToObject . fromJust -> o) -> - Identity $ Just $ A.Object $ Map.insert "plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged + A.Object $ + adjustJson + ( \(unsafeValueToObject -> o) -> + A.Object $ insertJson "plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged ) "haskell" (unsafeValueToObject (A.toJSON defaultConfig)) @@ -56,7 +52,7 @@ pluginsToDefaultConfig IdePlugins {..} = -- } singlePlugin PluginDescriptor {pluginConfigDescriptor = ConfigDescriptor {..}, ..} = let x = genericDefaultConfig <> dedicatedDefaultConfig - in [(toKey pId) A..= A.object x | not $ null x] + in [toJsonKey pId A..= A.object x | not $ null x] where (PluginHandlers (DMap.toList -> handlers)) = pluginHandlers customConfigToDedicatedDefaultConfig (CustomConfig p) = toDefaultJSON p diff --git a/hls-plugin-api/src/Ide/Plugin/Properties.hs b/hls-plugin-api/src/Ide/Plugin/Properties.hs index 6fc594ce2b..a007c58b6b 100644 --- a/hls-plugin-api/src/Ide/Plugin/Properties.hs +++ b/hls-plugin-api/src/Ide/Plugin/Properties.hs @@ -50,7 +50,7 @@ import Data.Proxy (Proxy (..)) import qualified Data.Text as T import GHC.OverloadedLabels (IsLabel (..)) import GHC.TypeLits -import Ide.Types (toJsonKey) +import Ide.Compat (toJsonKey) import Unsafe.Coerce (unsafeCoerce) -- | Types properties may have @@ -249,9 +249,9 @@ parseProperty kn k x = case k of ) x where - key = toJsonKey . pack $ symbolVal kn + key = toJsonKey . T.pack $ symbolVal kn parseEither :: forall a. A.FromJSON a => Either String a - parseEither = A.parseEither (A..: keyName) x + parseEither = A.parseEither (A..: key) x -- --------------------------------------------------------------------- @@ -354,7 +354,7 @@ toDefaultJSON :: Properties r -> [A.Pair] toDefaultJSON (Properties p) = [toEntry s v | (s, v) <- Map.toList p] where toEntry :: String -> SomePropertyKeyWithMetaData -> A.Pair - toEntry (toJsonKey . pack -> s) = \case + toEntry (toJsonKey . T.pack -> s) = \case (SomePropertyKeyWithMetaData SNumber MetaData {..}) -> s A..= defaultValue (SomePropertyKeyWithMetaData SInteger MetaData {..}) -> @@ -373,7 +373,7 @@ toDefaultJSON (Properties p) = [toEntry s v | (s, v) <- Map.toList p] -- | Converts a properties definition into kv pairs as vscode schema toVSCodeExtensionSchema :: T.Text -> Properties r -> [A.Pair] toVSCodeExtensionSchema prefix (Properties p) = - [(toJsonKey prefix <> k) A..= toEntry v | (k, v) <- Map.toList p] + [toJsonKey (prefix <> T.pack k) A..= toEntry v | (k, v) <- Map.toList p] where toEntry :: SomePropertyKeyWithMetaData -> A.Value toEntry = \case diff --git a/hls-plugin-api/src/Ide/Types.hs b/hls-plugin-api/src/Ide/Types.hs index 4d655cee0c..5c74b05534 100644 --- a/hls-plugin-api/src/Ide/Types.hs +++ b/hls-plugin-api/src/Ide/Types.hs @@ -28,7 +28,6 @@ import qualified System.Posix.Process as P (getProcessID) import System.Posix.Signals #endif import Control.Lens ((^.)) -import Control.Monad import Data.Aeson hiding (defaultOptions) import qualified Data.DList as DList import qualified Data.Default diff --git a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal index 994c50fa8b..2b21de18e2 100644 --- a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal +++ b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal @@ -92,7 +92,6 @@ library -- 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 - , extra < 1.7.10 if (!flag(ghc-lib) && impl(ghc >=8.10.1) && impl(ghc < 8.11.0)) build-depends: ghc >=8.10 && <9.0 else diff --git a/stack-8.10.6.yaml b/stack-8.10.6.yaml index 6680b2d2bb..6863e2a43c 100644 --- a/stack-8.10.6.yaml +++ b/stack-8.10.6.yaml @@ -38,10 +38,12 @@ extra-deps: - brittany-0.13.1.2@sha256:9922614f1df18c63755a37c144033988788e0769fd9c2630b64ed0dfb49462bd,8197 - bytestring-encoding-0.1.1.0@sha256:1c3b97eb6345fd7153006211c8272215cd78bb0cf440c41185290822f1e3f2c2,1738 - data-tree-print-0.1.0.2@sha256:d845e99f322df70e0c06d6743bf80336f5918d5423498528beb0593a2afc1703,1620 + - extra-1.7.10 - floskell-0.10.5@sha256:77f0bc1569573d9666b10975a5357fef631d32266c071733739393ccae521dab,3803 - heapsize-0.3.0.1@sha256:0b69aa97a46d819b700ac7b145f3b5493c3565cf2c5b8298682238d405d0326e,1417 - hie-bios-0.8.0 - hiedb-0.4.1.0 + - hlint-3.2.8 - implicit-hie-0.1.2.6@sha256:f50a908979a574a881f753c0f9a5224f023f438b30fdefc5b7fa01803b07a280,2998 - implicit-hie-cradle-0.3.0.5@sha256:5f5e575f549b2a9db664be7650b5c3c9226e313bddc46c79e2e83eb349f8e692,2610 - lsp-1.4.0.0 diff --git a/stack-8.10.7.yaml b/stack-8.10.7.yaml index 7a0683c453..804a9ad284 100644 --- a/stack-8.10.7.yaml +++ b/stack-8.10.7.yaml @@ -39,10 +39,12 @@ extra-deps: - brittany-0.13.1.2@sha256:9922614f1df18c63755a37c144033988788e0769fd9c2630b64ed0dfb49462bd,8197 - bytestring-encoding-0.1.1.0@sha256:1c3b97eb6345fd7153006211c8272215cd78bb0cf440c41185290822f1e3f2c2,1738 - data-tree-print-0.1.0.2@sha256:d845e99f322df70e0c06d6743bf80336f5918d5423498528beb0593a2afc1703,1620 + - extra-1.7.10 - floskell-0.10.5@sha256:77f0bc1569573d9666b10975a5357fef631d32266c071733739393ccae521dab,3803 - heapsize-0.3.0.1@sha256:0b69aa97a46d819b700ac7b145f3b5493c3565cf2c5b8298682238d405d0326e,1417 - hie-bios-0.8.0 - hiedb-0.4.1.0 + - hlint-3.2.8 - implicit-hie-0.1.2.6@sha256:f50a908979a574a881f753c0f9a5224f023f438b30fdefc5b7fa01803b07a280,2998 - implicit-hie-cradle-0.3.0.5@sha256:5f5e575f549b2a9db664be7650b5c3c9226e313bddc46c79e2e83eb349f8e692,2610 - lsp-1.4.0.0 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 4635ba7fb4..911a0cedba 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -45,6 +45,7 @@ extra-deps: - cabal-plan-0.6.2.0 - clock-0.7.2 - Diff-0.4.0 + - extra-1.7.10 - floskell-0.10.4 - fourmolu-0.3.0.0 - fuzzy-0.1.0.1 @@ -61,7 +62,7 @@ extra-deps: - hashable-1.3.0.0 - heapsize-0.3.0 - hie-bios-0.8.0 - - hlint-3.2.3 + - hlint-3.2.8 - HsYAML-0.2.1.0@rev:1 - HsYAML-aeson-0.2.0.0@rev:2 - implicit-hie-cradle-0.3.0.5 @@ -95,7 +96,6 @@ extra-deps: - th-compat-0.1.2@sha256:3d55de1adc542c1a870c9ada90da2fbbe5f4e8bcd3eed545a55c3df9311b32a8,2854 - bytestring-encoding-0.1.0.0@sha256:460b49779fbf0112e8e2f1753c1ed9131eb18827600c298f4d6bb51c4e8c1c0d,1727 - hiedb-0.4.1.0 - - extra-1.7.9@sha256:f1dec740f0f2025790c540732bfd52c556ec55bde4f5dfd7cf18e22bd44ff3d0,2683 - dependent-map-0.4.0.0@sha256:ca2b131046f4340a1c35d138c5a003fe4a5be96b14efc26291ed35fd08c62221,1657 - dependent-sum-0.7.1.0@sha256:5599aa89637db434431b1dd3fa7c34bc3d565ee44f0519bfbc877be1927c2531,2068 - dependent-sum-template-0.1.0.3@sha256:0bbbacdfbd3abf2a15aaf0cf2c27e5bdd159b519441fec39e1e6f2f54424adde,1682 diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index 6cb159ed00..5e63618afe 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -40,6 +40,7 @@ extra-deps: - cabal-plan-0.6.2.0 - clock-0.7.2 - constrained-dynamic-0.1.0.0 + - extra-1.7.10 - floskell-0.10.4 - fourmolu-0.3.0.0 - ghc-check-0.5.0.4 @@ -51,7 +52,7 @@ extra-deps: - haskell-src-exts-1.21.1 - heapsize-0.3.0 - hie-bios-0.8.0 - - hlint-3.2.3 + - hlint-3.2.8 - HsYAML-aeson-0.2.0.0@rev:2 - hoogle-5.0.17.11 - hsimport-0.11.0 diff --git a/stack-9.0.1.yaml b/stack-9.0.1.yaml index 5a744f6128..ab054c81dc 100644 --- a/stack-9.0.1.yaml +++ b/stack-9.0.1.yaml @@ -1,4 +1,4 @@ -resolver: nightly-2021-12-14 +resolver: nightly-2021-12-26 packages: - . @@ -20,7 +20,7 @@ packages: - ./plugins/hls-retrie-plugin - ./plugins/hls-splice-plugin # - ./plugins/hls-tactics-plugin -# - ./plugins/hls-brittany-plugin +- ./plugins/hls-brittany-plugin # - ./plugins/hls-stylish-haskell-plugin - ./plugins/hls-floskell-plugin - ./plugins/hls-fourmolu-plugin @@ -30,10 +30,14 @@ packages: - ./plugins/hls-alternate-number-format-plugin extra-deps: +- aeson-2.0.2.0 +- brittany-0.14.0.0 +- butcher-1.3.3.2 - bytestring-encoding-0.1.1.0 +- data-tree-print-0.1.0.2 - dependent-map-0.4.0.0 - dependent-sum-0.7.1.0 -- extra-1.7.9 # for ghcide, https://github.com/haskell/haskell-language-server/pull/2131 +- extra-1.7.10 - hspec-2.7.10 # for hls-test-utils - hspec-core-2.7.10 # for hls-test-utils - some-1.0.2 # for dependent-sum, https://github.com/obsidiansystems/dependent-sum/issues/66 @@ -44,6 +48,7 @@ extra-deps: - implicit-hie-0.1.2.6 - implicit-hie-cradle-0.3.0.5 - monad-dijkstra-0.1.1.3 +- multistate-0.8.0.3 - retrie-1.1.0.0 - lsp-1.4.0.0 - lsp-test-0.14.0.2 @@ -79,7 +84,6 @@ flags: class: false tactic: false # Dependencies fail stylishHaskell: false - brittany: false retrie: BuildExecutable: false diff --git a/stack.yaml b/stack.yaml index 7a0683c453..804a9ad284 100644 --- a/stack.yaml +++ b/stack.yaml @@ -39,10 +39,12 @@ extra-deps: - brittany-0.13.1.2@sha256:9922614f1df18c63755a37c144033988788e0769fd9c2630b64ed0dfb49462bd,8197 - bytestring-encoding-0.1.1.0@sha256:1c3b97eb6345fd7153006211c8272215cd78bb0cf440c41185290822f1e3f2c2,1738 - data-tree-print-0.1.0.2@sha256:d845e99f322df70e0c06d6743bf80336f5918d5423498528beb0593a2afc1703,1620 + - extra-1.7.10 - floskell-0.10.5@sha256:77f0bc1569573d9666b10975a5357fef631d32266c071733739393ccae521dab,3803 - heapsize-0.3.0.1@sha256:0b69aa97a46d819b700ac7b145f3b5493c3565cf2c5b8298682238d405d0326e,1417 - hie-bios-0.8.0 - hiedb-0.4.1.0 + - hlint-3.2.8 - implicit-hie-0.1.2.6@sha256:f50a908979a574a881f753c0f9a5224f023f438b30fdefc5b7fa01803b07a280,2998 - implicit-hie-cradle-0.3.0.5@sha256:5f5e575f549b2a9db664be7650b5c3c9226e313bddc46c79e2e83eb349f8e692,2610 - lsp-1.4.0.0 From e419f6b377af2c20e5de9273dd92e2106884c3a8 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 29 Dec 2021 15:38:19 +0100 Subject: [PATCH 16/32] Remove lsp --- cabal-ghc901.project | 9 --------- 1 file changed, 9 deletions(-) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index e789766e39..20e40668b5 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -27,15 +27,6 @@ packages: ./plugins/hls-call-hierarchy-plugin ./plugins/hls-alternate-number-format-plugin --- lsp needs a release with support for aeson >= 2.0 --- see https://github.com/haskell/lsp/issues/373 - -source-repository-package - type: git - location: https://github.com/haskell/lsp - tag: b48cf78d52152e13bd402d530dd4ceb7ad91b750 - subdir: lsp lsp-types lsp-test - with-compiler: ghc-9.0.1 tests: true From 5ea7bef1c537aafd58c11c254f44b9efe3965924 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 29 Dec 2021 21:15:39 +0100 Subject: [PATCH 17/32] Allow newer aeson for stylish-haskell --- cabal-ghc901.project | 1 + 1 file changed, 1 insertion(+) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index 20e40668b5..f7279b65d4 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -59,6 +59,7 @@ allow-newer: stylish-haskell:Cabal, stylish-haskell:ghc-lib-parser, + stylish-haskell:aeson, floskell:base, floskell:ghc-prim, From 1dbbc526c921bb2053a7f6578e37363856bc074e Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 29 Dec 2021 22:42:11 +0100 Subject: [PATCH 18/32] Add needed import for non windows --- hls-plugin-api/src/Ide/Types.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/hls-plugin-api/src/Ide/Types.hs b/hls-plugin-api/src/Ide/Types.hs index 5c74b05534..b20eb890d6 100644 --- a/hls-plugin-api/src/Ide/Types.hs +++ b/hls-plugin-api/src/Ide/Types.hs @@ -24,6 +24,7 @@ module Ide.Types #ifdef mingw32_HOST_OS import qualified System.Win32.Process as P (getCurrentProcessId) #else +import Control.Monad (void) import qualified System.Posix.Process as P (getProcessID) import System.Posix.Signals #endif From b528bcd97dea37b5bc1a2b350d0a3628a64c7971 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 30 Dec 2021 00:07:03 +0100 Subject: [PATCH 19/32] Remove insertJson and toJsonKey --- ghcide/src/Development/IDE/GHC/Orphans.hs | 24 +++++++++----------- hls-plugin-api/src/Ide/Compat.hs | 19 ---------------- hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 12 ++++++---- hls-plugin-api/src/Ide/Plugin/Properties.hs | 23 +++++++++---------- 4 files changed, 29 insertions(+), 49 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Orphans.hs b/ghcide/src/Development/IDE/GHC/Orphans.hs index b2352d0718..50aaa544ac 100644 --- a/ghcide/src/Development/IDE/GHC/Orphans.hs +++ b/ghcide/src/Development/IDE/GHC/Orphans.hs @@ -31,13 +31,11 @@ import Retrie.ExactPrint (Annotated) import Development.IDE.GHC.Compat import Development.IDE.GHC.Util -import Ide.Compat (toJsonKey) import Control.DeepSeq import Data.Aeson import Data.Hashable import Data.String (IsString (fromString)) -import Data.Text (Text) -- Orphan instances for types from the GHC API. instance Show CoreModule where show = prettyPrint @@ -123,7 +121,7 @@ instance NFData RealSrcSpan where rnf = rwhnf srcSpanFileTag, srcSpanStartLineTag, srcSpanStartColTag, - srcSpanEndLineTag, srcSpanEndColTag :: Text + srcSpanEndLineTag, srcSpanEndColTag :: String srcSpanFileTag = "srcSpanFile" srcSpanStartLineTag = "srcSpanStartLine" srcSpanStartColTag = "srcSpanStartCol" @@ -133,24 +131,24 @@ srcSpanEndColTag = "srcSpanEndCol" instance ToJSON RealSrcSpan where toJSON spn = object - [ toJsonKey srcSpanFileTag .= unpackFS (srcSpanFile spn) - , toJsonKey srcSpanStartLineTag .= srcSpanStartLine spn - , toJsonKey srcSpanStartColTag .= srcSpanStartCol spn - , toJsonKey srcSpanEndLineTag .= srcSpanEndLine spn - , toJsonKey srcSpanEndColTag .= srcSpanEndCol spn + [ fromString srcSpanFileTag .= unpackFS (srcSpanFile spn) + , fromString srcSpanStartLineTag .= srcSpanStartLine spn + , fromString srcSpanStartColTag .= srcSpanStartCol spn + , fromString srcSpanEndLineTag .= srcSpanEndLine spn + , fromString srcSpanEndColTag .= srcSpanEndCol spn ] instance FromJSON RealSrcSpan where parseJSON = withObject "object" $ \obj -> do - file <- fromString <$> (obj .: toJsonKey srcSpanFileTag) + file <- fromString <$> (obj .: fromString srcSpanFileTag) mkRealSrcSpan <$> (mkRealSrcLoc file - <$> obj .: toJsonKey srcSpanStartLineTag - <*> obj .: toJsonKey srcSpanStartColTag + <$> obj .: fromString srcSpanStartLineTag + <*> obj .: fromString srcSpanStartColTag ) <*> (mkRealSrcLoc file - <$> obj .: toJsonKey srcSpanEndLineTag - <*> obj .: toJsonKey srcSpanEndColTag + <$> obj .: fromString srcSpanEndLineTag + <*> obj .: fromString srcSpanEndColTag ) instance NFData Type where diff --git a/hls-plugin-api/src/Ide/Compat.hs b/hls-plugin-api/src/Ide/Compat.hs index 026d2e1de6..51e562c870 100644 --- a/hls-plugin-api/src/Ide/Compat.hs +++ b/hls-plugin-api/src/Ide/Compat.hs @@ -2,8 +2,6 @@ module Ide.Compat where #if MIN_VERSION_aeson(2,0,0) -import Data.Aeson.Key as A (Key) -import qualified Data.Aeson.Key as A.Key import qualified Data.Aeson.KeyMap as A import Data.Functor.Identity (Identity (..), runIdentity) #else @@ -12,23 +10,6 @@ import qualified Data.HashMap.Lazy as Map import Data.Aeson as A (Value) import Data.Text as T -#if MIN_VERSION_aeson(2,0,0) -toJsonKey :: T.Text -> A.Key -toJsonKey = A.Key.fromText -#else -toJsonKey :: T.Text -> T.Text -toJsonKey = id -#endif - -#if MIN_VERSION_aeson(2,0,0) -insertJson :: A.Key -> A.Value -> A.KeyMap A.Value -> A.KeyMap A.Value -insertJson = A.insert -#else -insertJson :: T.Text -> A.Value -> Map.HashMap T.Text A.Value -> Map.HashMap T.Text A.Value -insertJson = Map.insert -#endif - - #if MIN_VERSION_aeson(2,0,0) adjustJson :: (A.Value -> A.Value) -> A.Key -> A.KeyMap A.Value -> A.KeyMap A.Value adjustJson f k = runIdentity . A.alterF (Identity . fmap f) k diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index 6f80077c26..8922bc31b2 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -11,7 +11,9 @@ import Data.Default (def) import qualified Data.Dependent.Map as DMap import qualified Data.Dependent.Sum as DSum import Data.List (nub) -import Ide.Compat (adjustJson, insertJson, toJsonKey) +import Data.String (IsString (fromString)) +import qualified Data.Text as T +import Ide.Compat (adjustJson) import Ide.Plugin.Config import Ide.Plugin.Properties (toDefaultJSON, toVSCodeExtensionSchema) import Ide.Types @@ -27,8 +29,8 @@ pluginsToDefaultConfig :: IdePlugins a -> A.Value pluginsToDefaultConfig IdePlugins {..} = A.Object $ adjustJson - ( \(unsafeValueToObject -> o) -> - A.Object $ insertJson "plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged + ( \ (unsafeValueToObject -> obj) -> + A.Object $ obj <> unsafeValueToObject (A.object ["plugin" A..= elems]) -- inplace the "plugin" section with our 'elems', leaving others unchanged ) "haskell" (unsafeValueToObject (A.toJSON defaultConfig)) @@ -52,7 +54,7 @@ pluginsToDefaultConfig IdePlugins {..} = -- } singlePlugin PluginDescriptor {pluginConfigDescriptor = ConfigDescriptor {..}, ..} = let x = genericDefaultConfig <> dedicatedDefaultConfig - in [toJsonKey pId A..= A.object x | not $ null x] + in [fromString (T.unpack pId) A..= A.object x | not $ null x] where (PluginHandlers (DMap.toList -> handlers)) = pluginHandlers customConfigToDedicatedDefaultConfig (CustomConfig p) = toDefaultJSON p @@ -132,4 +134,4 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug "description" A..= A.String ("Enables " <> pId <> " " <> desc) ] withIdPrefix x = "haskell.plugin." <> pId <> "." <> x - toKey' = toJsonKey . withIdPrefix + toKey' = fromString . T.unpack . withIdPrefix diff --git a/hls-plugin-api/src/Ide/Plugin/Properties.hs b/hls-plugin-api/src/Ide/Plugin/Properties.hs index a007c58b6b..9baaf26833 100644 --- a/hls-plugin-api/src/Ide/Plugin/Properties.hs +++ b/hls-plugin-api/src/Ide/Plugin/Properties.hs @@ -11,7 +11,6 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -{-# LANGUAGE ViewPatterns #-} -- See Note [Constraints] {-# OPTIONS_GHC -Wno-redundant-constraints #-} @@ -47,10 +46,10 @@ import Data.Function ((&)) import Data.Kind (Constraint, Type) import qualified Data.Map.Strict as Map import Data.Proxy (Proxy (..)) +import Data.String (IsString (fromString)) import qualified Data.Text as T import GHC.OverloadedLabels (IsLabel (..)) import GHC.TypeLits -import Ide.Compat (toJsonKey) import Unsafe.Coerce (unsafeCoerce) -- | Types properties may have @@ -249,7 +248,7 @@ parseProperty kn k x = case k of ) x where - key = toJsonKey . T.pack $ symbolVal kn + key = fromString $ symbolVal kn parseEither :: forall a. A.FromJSON a => Either String a parseEither = A.parseEither (A..: key) x @@ -354,26 +353,26 @@ toDefaultJSON :: Properties r -> [A.Pair] toDefaultJSON (Properties p) = [toEntry s v | (s, v) <- Map.toList p] where toEntry :: String -> SomePropertyKeyWithMetaData -> A.Pair - toEntry (toJsonKey . T.pack -> s) = \case + toEntry s = \case (SomePropertyKeyWithMetaData SNumber MetaData {..}) -> - s A..= defaultValue + fromString s A..= defaultValue (SomePropertyKeyWithMetaData SInteger MetaData {..}) -> - s A..= defaultValue + fromString s A..= defaultValue (SomePropertyKeyWithMetaData SString MetaData {..}) -> - s A..= defaultValue + fromString s A..= defaultValue (SomePropertyKeyWithMetaData SBoolean MetaData {..}) -> - s A..= defaultValue + fromString s A..= defaultValue (SomePropertyKeyWithMetaData (SObject _) MetaData {..}) -> - s A..= defaultValue + fromString s A..= defaultValue (SomePropertyKeyWithMetaData (SArray _) MetaData {..}) -> - s A..= defaultValue + fromString s A..= defaultValue (SomePropertyKeyWithMetaData (SEnum _) EnumMetaData {..}) -> - s A..= defaultValue + fromString s A..= defaultValue -- | Converts a properties definition into kv pairs as vscode schema toVSCodeExtensionSchema :: T.Text -> Properties r -> [A.Pair] toVSCodeExtensionSchema prefix (Properties p) = - [toJsonKey (prefix <> T.pack k) A..= toEntry v | (k, v) <- Map.toList p] + [fromString (T.unpack prefix <> k) A..= toEntry v | (k, v) <- Map.toList p] where toEntry :: SomePropertyKeyWithMetaData -> A.Value toEntry = \case From 1a7c60baa49c23037702b1dfc9746784c304ac3e Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Thu, 30 Dec 2021 22:27:08 +0100 Subject: [PATCH 20/32] Update cabal-ghc901.project --- cabal-ghc901.project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index f7279b65d4..4505a1ce55 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -42,7 +42,7 @@ index-state: 2021-12-29T12:30:08Z constraints: -- These plugins don't work on GHC9 yet -- Add a plugin needs remove the -flag but also update ghc bounds in hls.cabal - haskell-language-server +ignore-plugins-ghc-bounds -class -stylishhaskell -tactic, + haskell-language-server +ignore-plugins-ghc-bounds -stylishhaskell -tactic, ghc-lib-parser ^>= 9.0 -- although we are not building all plugins cabal solver phase is run for all packages From 223e6ee7f23f2b8f71c149f94b9412c802f4ceb3 Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Thu, 30 Dec 2021 22:57:51 +0100 Subject: [PATCH 21/32] Missing import --- hls-plugin-api/src/Ide/Compat.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/hls-plugin-api/src/Ide/Compat.hs b/hls-plugin-api/src/Ide/Compat.hs index 51e562c870..0c64985c8a 100644 --- a/hls-plugin-api/src/Ide/Compat.hs +++ b/hls-plugin-api/src/Ide/Compat.hs @@ -2,6 +2,7 @@ module Ide.Compat where #if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.Key as A import qualified Data.Aeson.KeyMap as A import Data.Functor.Identity (Identity (..), runIdentity) #else From eaef641aa6a0342b803267020d11d3da90935c78 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Wed, 5 Jan 2022 15:23:53 +0000 Subject: [PATCH 22/32] Avoid CPP by using lens-aeson --- hls-plugin-api/hls-plugin-api.cabal | 2 +- hls-plugin-api/src/Ide/Compat.hs | 20 -------------------- hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 16 ++++++---------- 3 files changed, 7 insertions(+), 31 deletions(-) delete mode 100644 hls-plugin-api/src/Ide/Compat.hs diff --git a/hls-plugin-api/hls-plugin-api.cabal b/hls-plugin-api/hls-plugin-api.cabal index 4ce1b65f16..1516d1b591 100644 --- a/hls-plugin-api/hls-plugin-api.cabal +++ b/hls-plugin-api/hls-plugin-api.cabal @@ -26,7 +26,6 @@ source-repository head library exposed-modules: - Ide.Compat Ide.Logger Ide.Plugin.Config Ide.Plugin.ConfigUtils @@ -50,6 +49,7 @@ library , hls-graph >=1.4 && < 1.6 , hslogger , lens + , lens-aeson , lsp ^>=1.4.0.0 , opentelemetry , optparse-applicative diff --git a/hls-plugin-api/src/Ide/Compat.hs b/hls-plugin-api/src/Ide/Compat.hs deleted file mode 100644 index 0c64985c8a..0000000000 --- a/hls-plugin-api/src/Ide/Compat.hs +++ /dev/null @@ -1,20 +0,0 @@ -{-# LANGUAGE CPP #-} -module Ide.Compat where - -#if MIN_VERSION_aeson(2,0,0) -import qualified Data.Aeson.Key as A -import qualified Data.Aeson.KeyMap as A -import Data.Functor.Identity (Identity (..), runIdentity) -#else -import qualified Data.HashMap.Lazy as Map -#endif -import Data.Aeson as A (Value) -import Data.Text as T - -#if MIN_VERSION_aeson(2,0,0) -adjustJson :: (A.Value -> A.Value) -> A.Key -> A.KeyMap A.Value -> A.KeyMap A.Value -adjustJson f k = runIdentity . A.alterF (Identity . fmap f) k -#else -adjustJson :: (A.Value -> A.Value) -> T.Text -> Map.HashMap T.Text A.Value -> Map.HashMap T.Text A.Value -adjustJson = Map.adjust -#endif diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index 8922bc31b2..e0523fe078 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -5,15 +5,16 @@ module Ide.Plugin.ConfigUtils where +import Control.Lens ((&), (?~), ix, at) import qualified Data.Aeson as A import qualified Data.Aeson.Types as A +import Data.Aeson.Lens (_Object) import Data.Default (def) import qualified Data.Dependent.Map as DMap import qualified Data.Dependent.Sum as DSum import Data.List (nub) import Data.String (IsString (fromString)) import qualified Data.Text as T -import Ide.Compat (adjustJson) import Ide.Plugin.Config import Ide.Plugin.Properties (toDefaultJSON, toVSCodeExtensionSchema) import Ide.Types @@ -27,17 +28,12 @@ import Language.LSP.Types -- | Generates a default 'Config', but remains only effective items pluginsToDefaultConfig :: IdePlugins a -> A.Value pluginsToDefaultConfig IdePlugins {..} = - A.Object $ - adjustJson - ( \ (unsafeValueToObject -> obj) -> - A.Object $ obj <> unsafeValueToObject (A.object ["plugin" A..= elems]) -- inplace the "plugin" section with our 'elems', leaving others unchanged - ) - "haskell" - (unsafeValueToObject (A.toJSON defaultConfig)) + -- Use 'ix' to look at all the "haskell" keys in the outer value (since we're not + -- setting it if missing), then we use '_Object' and 'at' to get at the "plugin" key + -- and actually set it. + A.toJSON defaultConfig & ix "haskell" . _Object . at "plugin" ?~ elems where defaultConfig@Config {} = def - unsafeValueToObject (A.Object o) = o - unsafeValueToObject _ = error "impossible" elems = A.object $ mconcat $ singlePlugin <$> map snd ipMap -- Splice genericDefaultConfig and dedicatedDefaultConfig -- Example: From 2d15a5ced28aaef165427a01351bdd86e91e5075 Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Wed, 5 Jan 2022 16:47:33 +0100 Subject: [PATCH 23/32] Update hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs --- hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index e0523fe078..414a9e0030 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -8,7 +8,7 @@ module Ide.Plugin.ConfigUtils where import Control.Lens ((&), (?~), ix, at) import qualified Data.Aeson as A import qualified Data.Aeson.Types as A -import Data.Aeson.Lens (_Object) +import Data.Aeson.Lens (_Object) import Data.Default (def) import qualified Data.Dependent.Map as DMap import qualified Data.Dependent.Sum as DSum From 34000bac396edb8fd3b7263add20a5f42b035f50 Mon Sep 17 00:00:00 2001 From: jneira Date: Sat, 8 Jan 2022 22:39:13 +0100 Subject: [PATCH 24/32] Use ghcide compat module --- .../hls-brittany-plugin.cabal | 1 - .../src/Ide/Plugin/Brittany.hs | 38 ++++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/plugins/hls-brittany-plugin/hls-brittany-plugin.cabal b/plugins/hls-brittany-plugin/hls-brittany-plugin.cabal index ba64f55660..ff7f302985 100644 --- a/plugins/hls-brittany-plugin/hls-brittany-plugin.cabal +++ b/plugins/hls-brittany-plugin/hls-brittany-plugin.cabal @@ -23,7 +23,6 @@ library , base >=4.12 && <5 , brittany >=0.13.1.0 , filepath - , ghc , ghc-boot-th , ghcide >=1.2 && <1.6 , hls-plugin-api >=1.1 && <1.3 diff --git a/plugins/hls-brittany-plugin/src/Ide/Plugin/Brittany.hs b/plugins/hls-brittany-plugin/src/Ide/Plugin/Brittany.hs index 692f83b67c..ab73873147 100644 --- a/plugins/hls-brittany-plugin/src/Ide/Plugin/Brittany.hs +++ b/plugins/hls-brittany-plugin/src/Ide/Plugin/Brittany.hs @@ -19,8 +19,7 @@ import Development.IDE hiding (pluginHandlers) import qualified Development.IDE.GHC.Compat as GHC hiding (Cpp) -import qualified DynFlags as D -import qualified EnumSet as S +import qualified Development.IDE.GHC.Compat.Util as GHC import GHC.LanguageExtensions.Type import Ide.PluginUtils import Ide.Types @@ -39,7 +38,6 @@ import Data.CZipWith import qualified Data.List as List import qualified Data.Text as Text import qualified Data.Text.Lazy as TextL -import qualified GHC import qualified GHC.LanguageExtensions.Type as GHC import Language.Haskell.Brittany.Internal import Language.Haskell.Brittany.Internal.Config @@ -79,7 +77,7 @@ provider ide typ contents nfp opts = liftIO $ do -- Errors may be presented to the user. formatText :: MonadIO m - => D.DynFlags + => GHC.DynFlags -> Maybe FilePath -- ^ Path to configs. If Nothing, default configs will be used. -> FormattingOptions -- ^ Options for the formatter such as indentation. -> Text -- ^ Text to format @@ -101,28 +99,32 @@ getConfFile = findLocalConfigPath . takeDirectory . fromNormalizedFilePath -- Returns either a list of Brittany Errors or the reformatted text. -- May not throw an exception. runBrittany :: Int -- ^ tab size - -> D.DynFlags + -> GHC.DynFlags -> Maybe FilePath -- ^ local config file -> Text -- ^ text to format -> IO (Either [BrittanyError] Text) runBrittany tabSize df confPath text = do - let cfg = mempty - { _conf_layout = - mempty { _lconfig_indentAmount = opt (Last tabSize) - } - , _conf_forward = - (mempty :: CForwardOptions Option) - { _options_ghc = opt (getExtensions df) - } - } - - config <- fromMaybeT (pure staticDefaultConfig) (readConfigsWithUserConfig cfg (maybeToList confPath)) + let cfg = userConfig tabSize df + config <- fromMaybeT (pure staticDefaultConfig) + (readConfigsWithUserConfig cfg (maybeToList confPath)) (errsAndWarnings, resultText) <- pPrintText config text if any isError errsAndWarnings then return $ Left errsAndWarnings else return $ Right resultText +userConfig :: Int -> GHC.DynFlags -> CConfig Option +userConfig tabSize df = + mempty + { _conf_layout = + mempty { _lconfig_indentAmount = opt (Last tabSize) + } + , _conf_forward = + (mempty :: CForwardOptions Option) + { _options_ghc = opt (getExtensions df) + } + } + fromMaybeT :: Monad m => m a -> MaybeT m a -> m a fromMaybeT def act = runMaybeT act >>= maybe def return @@ -145,8 +147,8 @@ showExtension DatatypeContexts = Nothing showExtension RecordPuns = Just "-XNamedFieldPuns" showExtension other = Just $ "-X" ++ show other -getExtensions :: D.DynFlags -> [String] -getExtensions = mapMaybe showExtension . S.toList . D.extensionFlags +getExtensions :: GHC.DynFlags -> [String] +getExtensions = mapMaybe showExtension . GHC.toList . GHC.extensionFlags -- | This is a temporary fix that allows us to format the text if brittany From 238f5531f51f0e087cccfce36761050440cb5950 Mon Sep 17 00:00:00 2001 From: jneira Date: Sat, 8 Jan 2022 23:32:46 +0100 Subject: [PATCH 25/32] Use type alias in cpp --- .../src/Ide/Plugin/Brittany.hs | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/plugins/hls-brittany-plugin/src/Ide/Plugin/Brittany.hs b/plugins/hls-brittany-plugin/src/Ide/Plugin/Brittany.hs index ab73873147..7a61bf9935 100644 --- a/plugins/hls-brittany-plugin/src/Ide/Plugin/Brittany.hs +++ b/plugins/hls-brittany-plugin/src/Ide/Plugin/Brittany.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE PolyKinds #-} @@ -104,7 +105,15 @@ runBrittany :: Int -- ^ tab size -> Text -- ^ text to format -> IO (Either [BrittanyError] Text) runBrittany tabSize df confPath text = do - let cfg = userConfig tabSize df + let cfg = mempty + { _conf_layout = + mempty { _lconfig_indentAmount = opt (Last tabSize) + } + , _conf_forward = + (mempty :: CForwardOptions CMaybe) + { _options_ghc = opt (getExtensions df) + } + } config <- fromMaybeT (pure staticDefaultConfig) (readConfigsWithUserConfig cfg (maybeToList confPath)) (errsAndWarnings, resultText) <- pPrintText config text @@ -113,24 +122,19 @@ runBrittany tabSize df confPath text = do else return $ Right resultText -userConfig :: Int -> GHC.DynFlags -> CConfig Option -userConfig tabSize df = - mempty - { _conf_layout = - mempty { _lconfig_indentAmount = opt (Last tabSize) - } - , _conf_forward = - (mempty :: CForwardOptions Option) - { _options_ghc = opt (getExtensions df) - } - } +#if MIN_VERSION_brittany(0,14,0) +type CMaybe = Maybe +opt :: a -> Maybe a +opt = Just +#else +type CMaybe = Option +opt :: a -> Option a +opt = Option . Just +#endif fromMaybeT :: Monad m => m a -> MaybeT m a -> m a fromMaybeT def act = runMaybeT act >>= maybe def return -opt :: a -> Option a -opt = Option . Just - showErr :: BrittanyError -> String showErr (ErrorInput s) = s showErr (ErrorMacroConfig err input) From 31c325876b2967da94e76414e469db9746fe4aaf Mon Sep 17 00:00:00 2001 From: jneira Date: Sun, 9 Jan 2022 00:10:38 +0100 Subject: [PATCH 26/32] Fix stack build for ghc-8.6.5 --- stack-8.6.5.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 911a0cedba..088f1d4149 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -69,6 +69,7 @@ extra-deps: - implicit-hie-0.1.2.6 - indexed-profunctors-0.1 - lens-4.18 + - lens-aeson-1.1 - megaparsec-9.0.1 - monad-dijkstra-0.1.1.2 - opentelemetry-0.6.1 From 8afbd7c7e70a1a939b410621060de3581a2441b1 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 10 Jan 2022 19:15:07 +0100 Subject: [PATCH 27/32] Use lens-aeson key --- hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index 414a9e0030..c6fdf72f77 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -5,10 +5,10 @@ module Ide.Plugin.ConfigUtils where -import Control.Lens ((&), (?~), ix, at) +import Control.Lens (at, (&), (?~)) import qualified Data.Aeson as A +import Data.Aeson.Lens (_Object, key) import qualified Data.Aeson.Types as A -import Data.Aeson.Lens (_Object) import Data.Default (def) import qualified Data.Dependent.Map as DMap import qualified Data.Dependent.Sum as DSum @@ -31,7 +31,7 @@ pluginsToDefaultConfig IdePlugins {..} = -- Use 'ix' to look at all the "haskell" keys in the outer value (since we're not -- setting it if missing), then we use '_Object' and 'at' to get at the "plugin" key -- and actually set it. - A.toJSON defaultConfig & ix "haskell" . _Object . at "plugin" ?~ elems + A.toJSON defaultConfig & key "haskell" . _Object . at "plugin" ?~ elems where defaultConfig@Config {} = def elems = A.object $ mconcat $ singlePlugin <$> map snd ipMap From c6d56f1fc6326d10a438f6577a161d43f408e5d5 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 10 Jan 2022 21:36:37 +0100 Subject: [PATCH 28/32] Use lens-aeson in func-test --- haskell-language-server.cabal | 1 + test/functional/FunctionalCodeAction.hs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 8cddd65ffe..e5898b8d1e 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -433,6 +433,7 @@ test-suite func-test , data-default , hspec-expectations , lens + , lens-aeson , ghcide , hls-test-utils ^>= 1.1.0.0 , lsp-types diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index cf368b0613..c67263c91f 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -4,17 +4,17 @@ module FunctionalCodeAction (tests) where -import Control.Lens hiding (List) +import Control.Lens hiding (List) import Control.Monad import Data.Aeson -import qualified Data.HashMap.Strict as HM +import Data.Aeson.Lens (_Object, key) import Data.List -import qualified Data.Map as M +import qualified Data.Map as M import Data.Maybe -import qualified Data.Text as T +import qualified Data.Text as T import Ide.Plugin.Config -import Language.LSP.Test as Test -import qualified Language.LSP.Types.Lens as L +import Language.LSP.Test as Test +import qualified Language.LSP.Types.Lens as L import Test.Hls import Test.Hspec.Expectations @@ -56,11 +56,11 @@ renameTests = testGroup "rename suggestions" [ cars <- getAllCodeActions doc cmd <- liftIO $ inspectCommand cars ["Replace with", "putStrLn"] - let Just (List [Object args]) = cmd ^. L.arguments - Object editParams = args HM.! "fallbackWorkspaceEdit" + let Just (List [args]) = cmd ^. L.arguments + editParams = args ^. key "fallbackWorkspaceEdit" . _Object liftIO $ do - "changes" `HM.member` editParams @? "Contains changes" - not ("documentChanges" `HM.member` editParams) @? "Doesn't contain documentChanges" + (editParams & has (ix "changes")) @? "Contains changes" + not (editParams & has (ix "documentChanges")) @? "Doesn't contain documentChanges" executeCommand cmd _ <- anyRequest From 478203ce0ad4f43e70e0b4f5c87446efc9c884e2 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 10 Jan 2022 22:14:39 +0000 Subject: [PATCH 29/32] Fixup shake-bench --- shake-bench/shake-bench.cabal | 2 ++ .../src/Development/Benchmark/Rules.hs | 31 +++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/shake-bench/shake-bench.cabal b/shake-bench/shake-bench.cabal index 250bc302c6..948b10dace 100644 --- a/shake-bench/shake-bench.cabal +++ b/shake-bench/shake-bench.cabal @@ -27,6 +27,8 @@ library directory, extra >= 1.7.2, filepath, + lens, + lens-aeson, shake, text default-language: Haskell2010 diff --git a/shake-bench/src/Development/Benchmark/Rules.hs b/shake-bench/src/Development/Benchmark/Rules.hs index 29e36fe71d..024b32d3f6 100644 --- a/shake-bench/src/Development/Benchmark/Rules.hs +++ b/shake-bench/src/Development/Benchmark/Rules.hs @@ -68,16 +68,19 @@ module Development.Benchmark.Rules import Control.Applicative import Control.Monad +import Control.Lens ((^.)) import Data.Aeson (FromJSON (..), ToJSON (..), - Value (..), (.!=), - (.:?)) + Value (..), object, (.!=), + (.:?), (.=)) +import Data.Aeson.Lens (_Object) import Data.Char (isDigit) import Data.List (find, isInfixOf, stripPrefix, transpose) import Data.List.Extra (lower) import Data.Maybe (fromMaybe) +import Data.String (fromString) import Data.Text (Text) import qualified Data.Text as T import Development.Shake @@ -88,7 +91,6 @@ import GHC.Exts (IsList (toList), import GHC.Generics (Generic) import GHC.Stack (HasCallStack) import qualified Graphics.Rendering.Chart.Backend.Diagrams as E -import Graphics.Rendering.Chart.Easy ((.=)) import qualified Graphics.Rendering.Chart.Easy as E import System.Directory (createDirectoryIfMissing, findExecutable, @@ -498,21 +500,24 @@ data GitCommit = GitCommit instance FromJSON GitCommit where parseJSON (String s) = pure $ GitCommit s Nothing Nothing True - parseJSON (Object (toList -> [(name, String gitName)])) = - pure $ GitCommit gitName (Just name) Nothing True - parseJSON (Object (toList -> [(name, Object props)])) = - GitCommit - <$> props .:? "git" .!= name - <*> pure (Just name) - <*> props .:? "parent" - <*> props .:? "include" .!= True + parseJSON o@(Object _) = do + let keymap = o ^. _Object + case toList keymap of + [(name, String gitName)] -> pure $ GitCommit gitName (Just (fromString $ show name)) Nothing True + [(name, Object props)] -> + GitCommit + <$> props .:? "git" .!= name + <*> pure (Just (fromString $ show name)) + <*> props .:? "parent" + <*> props .:? "include" .!= True + _ -> empty parseJSON _ = empty instance ToJSON GitCommit where toJSON GitCommit {..} = case name of Nothing -> String gitName - Just n -> Object $ fromList [(n, String gitName)] + Just n -> object [fromString (T.unpack n) .= String gitName] humanName :: GitCommit -> Text humanName GitCommit {..} = fromMaybe gitName name @@ -607,7 +612,7 @@ plotDiagram :: Bool -> Diagram -> FilePath -> Action () plotDiagram includeFailed t@Diagram {traceMetric, runLogs} out = do let extract = frameMetric traceMetric liftIO $ E.toFile E.def out $ do - E.layout_title .= title t + E.layout_title E..= title t E.setColors myColors forM_ runLogs $ \rl -> when (includeFailed || runSuccess rl) $ E.plot $ do From a545d9f0515c618ce6ef2b0cf416fd1f3edd2186 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 10 Jan 2022 23:22:42 +0100 Subject: [PATCH 30/32] Update docs --- hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index c6fdf72f77..6c31d11cac 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -28,7 +28,7 @@ import Language.LSP.Types -- | Generates a default 'Config', but remains only effective items pluginsToDefaultConfig :: IdePlugins a -> A.Value pluginsToDefaultConfig IdePlugins {..} = - -- Use 'ix' to look at all the "haskell" keys in the outer value (since we're not + -- Use 'key' to look at all the "haskell" keys in the outer value (since we're not -- setting it if missing), then we use '_Object' and 'at' to get at the "plugin" key -- and actually set it. A.toJSON defaultConfig & key "haskell" . _Object . at "plugin" ?~ elems From 0f1383f4c9c92a16f039be77961ad8e1e9d673b3 Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 11 Jan 2022 08:09:51 +0100 Subject: [PATCH 31/32] Switch to lens ix --- hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 8 ++++---- test/functional/FunctionalCodeAction.hs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index 6c31d11cac..cea719a995 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -5,9 +5,9 @@ module Ide.Plugin.ConfigUtils where -import Control.Lens (at, (&), (?~)) +import Control.Lens (at, ix, (&), (?~)) import qualified Data.Aeson as A -import Data.Aeson.Lens (_Object, key) +import Data.Aeson.Lens (_Object) import qualified Data.Aeson.Types as A import Data.Default (def) import qualified Data.Dependent.Map as DMap @@ -28,10 +28,10 @@ import Language.LSP.Types -- | Generates a default 'Config', but remains only effective items pluginsToDefaultConfig :: IdePlugins a -> A.Value pluginsToDefaultConfig IdePlugins {..} = - -- Use 'key' to look at all the "haskell" keys in the outer value (since we're not + -- Use 'ix' to look at all the "haskell" keys in the outer value (since we're not -- setting it if missing), then we use '_Object' and 'at' to get at the "plugin" key -- and actually set it. - A.toJSON defaultConfig & key "haskell" . _Object . at "plugin" ?~ elems + A.toJSON defaultConfig & ix "haskell" . _Object . at "plugin" ?~ elems where defaultConfig@Config {} = def elems = A.object $ mconcat $ singlePlugin <$> map snd ipMap diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index c67263c91f..3d160931b7 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -7,7 +7,7 @@ module FunctionalCodeAction (tests) where import Control.Lens hiding (List) import Control.Monad import Data.Aeson -import Data.Aeson.Lens (_Object, key) +import Data.Aeson.Lens (_Object) import Data.List import qualified Data.Map as M import Data.Maybe @@ -57,7 +57,7 @@ renameTests = testGroup "rename suggestions" [ cars <- getAllCodeActions doc cmd <- liftIO $ inspectCommand cars ["Replace with", "putStrLn"] let Just (List [args]) = cmd ^. L.arguments - editParams = args ^. key "fallbackWorkspaceEdit" . _Object + editParams = args ^. ix "fallbackWorkspaceEdit" . _Object liftIO $ do (editParams & has (ix "changes")) @? "Contains changes" not (editParams & has (ix "documentChanges")) @? "Doesn't contain documentChanges" From b81761d57e2596f2dfe0dadbfceaf9e1c9dd69d4 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Tue, 11 Jan 2022 22:04:31 +0000 Subject: [PATCH 32/32] Try this --- shake-bench/src/Development/Benchmark/Rules.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shake-bench/src/Development/Benchmark/Rules.hs b/shake-bench/src/Development/Benchmark/Rules.hs index 024b32d3f6..1732c02ddf 100644 --- a/shake-bench/src/Development/Benchmark/Rules.hs +++ b/shake-bench/src/Development/Benchmark/Rules.hs @@ -503,11 +503,11 @@ instance FromJSON GitCommit where parseJSON o@(Object _) = do let keymap = o ^. _Object case toList keymap of - [(name, String gitName)] -> pure $ GitCommit gitName (Just (fromString $ show name)) Nothing True + [(name, String gitName)] -> pure $ GitCommit gitName (Just name) Nothing True [(name, Object props)] -> GitCommit <$> props .:? "git" .!= name - <*> pure (Just (fromString $ show name)) + <*> pure (Just name) <*> props .:? "parent" <*> props .:? "include" .!= True _ -> empty