From 5b93df74d1f59c0c3a81f129595d4bccaa2d9fd9 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 3 Nov 2022 11:39:04 -0400 Subject: [PATCH 01/78] Set buildable on GHC 9.4 --- plugins/hls-refactor-plugin/hls-refactor-plugin.cabal | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plugins/hls-refactor-plugin/hls-refactor-plugin.cabal b/plugins/hls-refactor-plugin/hls-refactor-plugin.cabal index 80979f2f6e..b5af6f8e83 100644 --- a/plugins/hls-refactor-plugin/hls-refactor-plugin.cabal +++ b/plugins/hls-refactor-plugin/hls-refactor-plugin.cabal @@ -22,10 +22,6 @@ source-repository head location: https://github.com/haskell/haskell-language-server.git library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True exposed-modules: Development.IDE.GHC.ExactPrint Development.IDE.GHC.Compat.ExactPrint Development.IDE.Plugin.CodeAction @@ -89,10 +85,6 @@ library default-language: Haskell2010 test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test From 14693fd2b9341acffb2b81019685ef078646326f Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 3 Nov 2022 16:10:41 -0400 Subject: [PATCH 02/78] Start work on GHC 9.4 compat --- .../Development/IDE/GHC/Compat/ExactPrint.hs | 5 -- .../src/Development/IDE/GHC/Dump.hs | 9 +++- .../src/Development/IDE/GHC/ExactPrint.hs | 38 +++++++++++---- .../src/Development/IDE/Plugin/CodeAction.hs | 8 ---- .../IDE/Plugin/CodeAction/ExactPrint.hs | 46 ++++++++++++------- 5 files changed, 66 insertions(+), 40 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/Compat/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/Compat/ExactPrint.hs index 28e34ba379..a80f251998 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/Compat/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/Compat/ExactPrint.hs @@ -2,9 +2,6 @@ -- multiple ghc-exactprint versions, accepting that anything more ambitious is -- pretty much impossible with the GHC 9.2 redesign of ghc-exactprint module Development.IDE.GHC.Compat.ExactPrint -#if MIN_VERSION_ghc(9,3,0) - ( ) where -#else ( ExactPrint , exactPrint , makeDeltaAst @@ -34,5 +31,3 @@ pattern Annotated {astA, annsA} <- (Retrie.astA &&& Retrie.annsA -> (astA, annsA pattern Annotated :: ast -> ApiAnns -> Retrie.Annotated ast pattern Annotated {astA, annsA} <- ((,()) . Retrie.astA -> (astA, annsA)) #endif - -#endif diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/Dump.hs b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/Dump.hs index e7297e1db8..5b262612b1 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/Dump.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/Dump.hs @@ -8,10 +8,10 @@ import GHC.Hs.Dump import qualified Data.ByteString as B import Development.IDE.GHC.Compat.Util import Generics.SYB (ext1Q, ext2Q, extQ) -import GHC.Hs +import GHC.Hs hiding (AnnLet) #endif #if MIN_VERSION_ghc(9,0,1) -import GHC.Plugins +import GHC.Plugins hiding (AnnLet) #else import GhcPlugins #endif @@ -231,8 +231,13 @@ showAstDataHtml a0 = html $ annotationEpAnnHsCase :: EpAnn EpAnnHsCase -> SDoc annotationEpAnnHsCase = annotation' (text "EpAnn EpAnnHsCase") +#if MIN_VERSION_ghc(9,4,0) + annotationEpAnnHsLet :: EpAnn NoEpAnns -> SDoc + annotationEpAnnHsLet = annotation' (text "EpAnn NoEpAnns") +#else annotationEpAnnHsLet :: EpAnn AnnsLet -> SDoc annotationEpAnnHsLet = annotation' (text "EpAnn AnnsLet") +#endif annotationAnnList :: EpAnn AnnList -> SDoc annotationAnnList = annotation' (text "EpAnn AnnList") diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs index 4704afd9eb..11663ae0f7 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs @@ -3,9 +3,6 @@ -- | This module hosts various abstractions and utility functions to work with ghc-exactprint. module Development.IDE.GHC.ExactPrint -#if MIN_VERSION_ghc(9,3,0) - ( ) where -#else ( Graft(..), graftDecls, graftDeclsWithM, @@ -95,11 +92,14 @@ import Ide.PluginUtils import Language.Haskell.GHC.ExactPrint.Parsers import Language.LSP.Types import Language.LSP.Types.Capabilities (ClientCapabilities) -import Retrie.ExactPrint hiding (Annotated (..), - parseDecl, parseExpr, +import Retrie.ExactPrint hiding (parseDecl, + parseExpr, parsePattern, parseType) -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,9,0) +import GHC.Plugins (showSDoc) +import GHC.Utils.Outputable (Outputable (ppr)) +#elif MIN_VERSION_ghc(9,2,0) import GHC (EpAnn (..), NameAdornment (NameParens), NameAnn (..), @@ -696,7 +696,10 @@ annotate :: (ASTElement l ast, Outputable l) annotate dflags needs_space ast = do uniq <- show <$> uniqueSrcSpanT let rendered = render dflags ast -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,4,0) + expr' <- lift $ mapLeft (showSDoc dflags . ppr) $ parseAST dflags uniq rendered + pure expr' +#elif MIN_VERSION_ghc(9,2,0) expr' <- lift $ mapLeft show $ parseAST dflags uniq rendered pure $ setPrecedingLines expr' 0 (bool 0 1 needs_space) #else @@ -720,6 +723,21 @@ annotateDecl dflags let set_matches matches = ValD ext fb { fun_matches = mg { mg_alts = L alt_src matches }} +#if MIN_VERSION_ghc(9,2,0) + alts' <- for alts $ \alt -> do + uniq <- show <$> uniqueSrcSpanT + let rendered = render dflags $ set_matches [alt] +#if MIN_VERSION_ghc(9,4,0) + lift (mapLeft (showSDoc dflags . ppr) $ parseDecl dflags uniq rendered) >>= \case +#elif MIN_VERSION_ghc(9,2,0) + lift (mapLeft show $ parseDecl dflags uniq rendered) >>= \case +#endif + (L _ (ValD _ FunBind { fun_matches = MG { mg_alts = L _ [alt']}})) + -> pure alt' + _ -> lift $ Left "annotateDecl: didn't parse a single FunBind match" + + pure $ L src $ set_matches alts' +#else (anns', alts') <- fmap unzip $ for alts $ \alt -> do uniq <- show <$> uniqueSrcSpanT let rendered = render dflags $ set_matches [alt] @@ -737,6 +755,10 @@ annotateDecl dflags ast = do #if MIN_VERSION_ghc(9,2,0) expr' <- lift $ mapLeft show $ parseDecl dflags uniq rendered pure $ setPrecedingLines expr' 1 0 +#if MIN_VERSION_ghc(9,4,0) + lift $ mapLeft (showSDoc dflags . ppr) $ parseDecl dflags uniq rendered +#elif MIN_VERSION_ghc(9,2,0) + lift $ mapLeft show $ parseDecl dflags uniq rendered #else (anns, expr') <- lift $ mapLeft show $ parseDecl dflags uniq rendered let anns' = setPrecedingLines expr' 1 0 anns @@ -819,5 +841,3 @@ isCommaAnn :: TrailingAnn -> Bool isCommaAnn AddCommaAnn{} = True isCommaAnn _ = False #endif - -#endif diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index 69047c0aac..f4c76212e2 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -157,12 +157,10 @@ iePluginDescriptor recorder plId = wrap suggestExportUnusedTopBinding , wrap suggestModuleTypo , wrap suggestFixConstructorImport -#if !MIN_VERSION_ghc(9,3,0) , wrap suggestExtendImport , wrap suggestImportDisambiguation , wrap suggestNewOrExtendImportForClassMethod , wrap suggestHideShadow -#endif , wrap suggestNewImport ] plId @@ -174,10 +172,8 @@ typeSigsPluginDescriptor recorder plId = mkExactprintPluginDescriptor recorder $ wrap $ suggestSignature True , wrap suggestFillTypeWildcard , wrap suggestAddTypeAnnotationToSatisfyConstraints -#if !MIN_VERSION_ghc(9,3,0) , wrap removeRedundantConstraints , wrap suggestConstraint -#endif ] plId @@ -185,9 +181,7 @@ bindingsPluginDescriptor :: Recorder (WithPriority E.Log) -> PluginId -> Plugin bindingsPluginDescriptor recorder plId = mkExactprintPluginDescriptor recorder $ mkGhcideCAsPlugin [ wrap suggestReplaceIdentifier -#if !MIN_VERSION_ghc(9,3,0) , wrap suggestImplicitParameter -#endif , wrap suggestNewDefinition #if MIN_VERSION_ghc(9,2,1) , wrap suggestAddArgument @@ -1198,7 +1192,6 @@ getIndentedGroupsBy pred inp = case dropWhile (not.pred) inp of indentation :: T.Text -> Int indentation = T.length . T.takeWhile isSpace -#if !MIN_VERSION_ghc(9,3,0) suggestExtendImport :: ExportsMap -> ParsedSource -> Diagnostic -> [(T.Text, CodeActionKind, Rewrite)] suggestExtendImport exportsMap (L _ HsModule {hsmodImports}) Diagnostic{_range=_range,..} | Just [binding, mod, srcspan] <- @@ -1246,7 +1239,6 @@ suggestExtendImport exportsMap (L _ HsModule {hsmodImports}) Diagnostic{_range=_ , parent = Nothing , isDatacon = False , moduleNameText = mod} -#endif data HidingMode = HideOthers [ModuleTarget] diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs index 4a64486c90..234745d55a 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs @@ -196,26 +196,30 @@ removeConstraint :: removeConstraint toRemove = go . traceAst "REMOVE_CONSTRAINT_input" where go :: LHsType GhcPs -> Rewrite -#if !MIN_VERSION_ghc(9,2,0) - go (L l it@HsQualTy{hst_ctxt = L l' ctxt, hst_body}) = Rewrite (locA l) $ \_ -> do -#else +#if MIN_VERSION_ghc(9,2,0) && !MIN_VERSION_ghc(9,4,0) go (L l it@HsQualTy{hst_ctxt = Just (L l' ctxt), hst_body}) = Rewrite (locA l) $ \_ -> do +#else + go (L l it@HsQualTy{hst_ctxt = L l' ctxt, hst_body}) = Rewrite (locA l) $ \_ -> do #endif let ctxt' = filter (not . toRemove) ctxt removeStuff = (toRemove <$> headMaybe ctxt) == Just True -#if !MIN_VERSION_ghc(9,2,0) - when removeStuff $ - setEntryDPT hst_body (DP (0, 0)) - return $ L l $ it{hst_ctxt = L l' ctxt'} -#else +#if MIN_VERSION_ghc(9,2,0) let hst_body' = if removeStuff then resetEntryDP hst_body else hst_body return $ case ctxt' of [] -> hst_body' _ -> do let ctxt'' = over _last (first removeComma) ctxt' +#if MIN_VERSION_ghc(9,4,0) + L l $ it{ hst_ctxt = L l' ctxt'' +#else L l $ it{ hst_ctxt = Just $ L l' ctxt'' +#endif , hst_body = hst_body' } +#else + when removeStuff $ + setEntryDPT hst_body (DP (0, 0)) + return $ L l $ it{hst_ctxt = L l' ctxt'} #endif go (L _ (HsParTy _ ty)) = go ty go (L _ HsForAllTy{hst_body}) = go hst_body @@ -231,10 +235,12 @@ appendConstraint :: Rewrite appendConstraint constraintT = go . traceAst "appendConstraint" where -#if !MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,4,0) go (L l it@HsQualTy{hst_ctxt = L l' ctxt}) = Rewrite (locA l) $ \df -> do -#else +#elif MIN_VERSION_ghc(9,2,0) go (L l it@HsQualTy{hst_ctxt = Just (L l' ctxt)}) = Rewrite (locA l) $ \df -> do +#else + go (L l it@HsQualTy{hst_ctxt = L l' ctxt}) = Rewrite (locA l) $ \df -> do #endif constraint <- liftParseAST df constraintT #if !MIN_VERSION_ghc(9,2,0) @@ -258,7 +264,11 @@ appendConstraint constraintT = go . traceAst "appendConstraint" [L _ (HsParTy EpAnn{anns=AnnParen{ap_close}} _)] -> Just ap_close _ -> Nothing ctxt' = over _last (first addComma) $ map dropHsParTy ctxt +#if MIN_VERSION_ghc(9,4,0) + return $ L l $ it{hst_ctxt = L l'' $ ctxt' ++ [constraint]} +#else return $ L l $ it{hst_ctxt = Just $ L l'' $ ctxt' ++ [constraint]} +#endif #endif go (L _ HsForAllTy{hst_body}) = go hst_body go (L _ (HsParTy _ ty)) = go ty @@ -267,7 +277,16 @@ appendConstraint constraintT = go . traceAst "appendConstraint" constraint <- liftParseAST df constraintT lContext <- uniqueSrcSpanT lTop <- uniqueSrcSpanT -#if !MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,4,0) + let context = reAnnL annCtxt emptyComments $ L lContext [resetEntryDP constraint] +#else + let context = Just $ reAnnL annCtxt emptyComments $ L lContext [resetEntryDP constraint] +#endif + annCtxt = AnnContext (Just (NormalSyntax, epl 1)) [epl 0 | needsParens] [epl 0 | needsParens] + needsParens = hsTypeNeedsParens sigPrec $ unLoc constraint + ast <- pure $ setEntryDP ast (SameLine 1) +#else let context = L lContext [constraint] addSimpleAnnT context dp00 $ (G AnnDarrow, DP (0, 1)) : @@ -277,11 +296,6 @@ appendConstraint constraintT = go . traceAst "appendConstraint" ] | hsTypeNeedsParens sigPrec $ unLoc constraint ] -#else - let context = Just $ reAnnL annCtxt emptyComments $ L lContext [resetEntryDP constraint] - annCtxt = AnnContext (Just (NormalSyntax, epl 1)) [epl 0 | needsParens] [epl 0 | needsParens] - needsParens = hsTypeNeedsParens sigPrec $ unLoc constraint - ast <- pure $ setEntryDP ast (SameLine 1) #endif return $ reLocA $ L lTop $ HsQualTy noExtField context ast From 1c9498d81d6f0d9a4f796b5c58f1b5b0cdb3b8f5 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 3 Nov 2022 16:57:49 -0400 Subject: [PATCH 03/78] Use patched `retrie` --- flake.lock | 16 ++++++++-------- flake.nix | 5 ++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index 0f74f76d26..5d057147c5 100644 --- a/flake.lock +++ b/flake.lock @@ -294,11 +294,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1663112159, - "narHash": "sha256-31rjPhB6Hj1QoqLvFSULFf9Z/6z05vR0KrLGYvr9w0M=", + "lastModified": 1667292599, + "narHash": "sha256-7ISOUI1aj6UKMPIL+wwthENL22L3+A9V+jS8Is3QsRo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "78bce1608960b994405f3696ba086ba1d63654e9", + "rev": "ef2f213d9659a274985778bff4ca322f3ef3ac68", "type": "github" }, "original": { @@ -323,13 +323,13 @@ "retrie": { "flake": false, "locked": { - "narHash": "sha256-SrUyFea9Qr2SYeNVDJfWZfCguJV2rHK2mO/FO4xLFaY=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/retrie-1.2.0.1/retrie-1.2.0.1.tar.gz" + "narHash": "sha256-ibfeHXCf+YSZ1E8KPSiAtiqoUH+0s466SkSvpk37qfY=", + "type": "file", + "url": "https://github.com/MercuryTechnologies/retrie/tarball/cc8f9b2d424831618c1d686f46a5816bc95e2386" }, "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/retrie-1.2.0.1/retrie-1.2.0.1.tar.gz" + "type": "file", + "url": "https://github.com/MercuryTechnologies/retrie/tarball/cc8f9b2d424831618c1d686f46a5816bc95e2386" } }, "root": { diff --git a/flake.nix b/flake.nix index b7f1cb6b06..198dbec2fa 100644 --- a/flake.nix +++ b/flake.nix @@ -60,7 +60,7 @@ flake = false; }; retrie = { - url = "https://hackage.haskell.org/package/retrie-1.2.0.1/retrie-1.2.0.1.tar.gz"; + url = "https://github.com/MercuryTechnologies/retrie/tarball/cc8f9b2d424831618c1d686f46a5816bc95e2386"; flake = false; }; fourmolu = { @@ -187,6 +187,7 @@ entropy = hsuper.callCabal2nix "entropy" inputs.entropy {}; hiedb = hsuper.callCabal2nix "hiedb" inputs.hiedb {}; hw-prim = hsuper.callCabal2nix "hw-prim" inputs.hw-prim {}; + retrie = hsuper.callCabal2nix "retrie" inputs.retrie {}; implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" inputs.implicit-hie-cradle {}; ghc-check = hself.callCabal2nix "ghc-check" inputs.ghc-check {}; @@ -310,8 +311,6 @@ gmp zlib ncurses # Changelog tooling (gen-hls-changelogs pkgs.haskellPackages) - # For the documentation - pythonWithPackages # @guibou: I'm not sure this is needed. hlint pkgs.haskellPackages.opentelemetry-extra From 8b87ce69b4ece746f38f33a3ff83be081ed0eae1 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 4 Nov 2022 09:29:57 -0700 Subject: [PATCH 04/78] update retrie with github address. circumvent nix-prefetch-url. --- flake.lock | 15 ++++++++++----- flake.nix | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 5d057147c5..68dc199e7c 100644 --- a/flake.lock +++ b/flake.lock @@ -323,13 +323,18 @@ "retrie": { "flake": false, "locked": { - "narHash": "sha256-ibfeHXCf+YSZ1E8KPSiAtiqoUH+0s466SkSvpk37qfY=", - "type": "file", - "url": "https://github.com/MercuryTechnologies/retrie/tarball/cc8f9b2d424831618c1d686f46a5816bc95e2386" + "lastModified": 1667519855, + "narHash": "sha256-6xr3fsqy28VGQo+by3sKIB5F5lSAg2HwJMzfiQ0uuNw=", + "owner": "MercuryTechnologies", + "repo": "retrie", + "rev": "415e5e6c01acac6ef77255834edc90fe80f37396", + "type": "github" }, "original": { - "type": "file", - "url": "https://github.com/MercuryTechnologies/retrie/tarball/cc8f9b2d424831618c1d686f46a5816bc95e2386" + "owner": "MercuryTechnologies", + "ref": "mercury/ghc94", + "repo": "retrie", + "type": "github" } }, "root": { diff --git a/flake.nix b/flake.nix index 198dbec2fa..3ff82834b8 100644 --- a/flake.nix +++ b/flake.nix @@ -60,7 +60,7 @@ flake = false; }; retrie = { - url = "https://github.com/MercuryTechnologies/retrie/tarball/cc8f9b2d424831618c1d686f46a5816bc95e2386"; + url = "github:MercuryTechnologies/retrie/mercury/ghc94"; flake = false; }; fourmolu = { From 5eca01a3383b859b81c85917388e775d4bbb7102 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 4 Nov 2022 09:46:18 -0700 Subject: [PATCH 05/78] handle ExactPrint --- .../src/Development/IDE/GHC/ExactPrint.hs | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs index 11663ae0f7..832bc2e372 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs @@ -723,21 +723,6 @@ annotateDecl dflags let set_matches matches = ValD ext fb { fun_matches = mg { mg_alts = L alt_src matches }} -#if MIN_VERSION_ghc(9,2,0) - alts' <- for alts $ \alt -> do - uniq <- show <$> uniqueSrcSpanT - let rendered = render dflags $ set_matches [alt] -#if MIN_VERSION_ghc(9,4,0) - lift (mapLeft (showSDoc dflags . ppr) $ parseDecl dflags uniq rendered) >>= \case -#elif MIN_VERSION_ghc(9,2,0) - lift (mapLeft show $ parseDecl dflags uniq rendered) >>= \case -#endif - (L _ (ValD _ FunBind { fun_matches = MG { mg_alts = L _ [alt']}})) - -> pure alt' - _ -> lift $ Left "annotateDecl: didn't parse a single FunBind match" - - pure $ L src $ set_matches alts' -#else (anns', alts') <- fmap unzip $ for alts $ \alt -> do uniq <- show <$> uniqueSrcSpanT let rendered = render dflags $ set_matches [alt] @@ -752,13 +737,12 @@ annotateDecl dflags annotateDecl dflags ast = do uniq <- show <$> uniqueSrcSpanT let rendered = render dflags ast -#if MIN_VERSION_ghc(9,2,0) - expr' <- lift $ mapLeft show $ parseDecl dflags uniq rendered - pure $ setPrecedingLines expr' 1 0 #if MIN_VERSION_ghc(9,4,0) - lift $ mapLeft (showSDoc dflags . ppr) $ parseDecl dflags uniq rendered + expr' <- lift $ mapLeft (showSDoc dflags . ppr) $ parseDecl dflags uniq rendered + pure $ setPrecedingLines expr' 1 0 #elif MIN_VERSION_ghc(9,2,0) - lift $ mapLeft show $ parseDecl dflags uniq rendered + expr' <- lift $ mapLeft show $ parseDecl dflags uniq rendered + pure $ setPrecedingLines expr' 1 0 #else (anns, expr') <- lift $ mapLeft show $ parseDecl dflags uniq rendered let anns' = setPrecedingLines expr' 1 0 anns From 0ac379993f3c6e8e00a375d4781995f807e3e727 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 4 Nov 2022 11:54:39 -0700 Subject: [PATCH 06/78] fix ghc 9.0 env. --- configuration-ghc-90.nix | 5 ++++- configuration-ghc-92.nix | 4 ++++ configuration-ghc-94.nix | 3 +++ flake.lock | 13 +++++++++++++ flake.nix | 6 ++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/configuration-ghc-90.nix b/configuration-ghc-90.nix index f82e03ce03..34f1e42bb7 100644 --- a/configuration-ghc-90.nix +++ b/configuration-ghc-90.nix @@ -24,7 +24,7 @@ let Cabal = hself.Cabal_3_6_3_0; ormolu = hself.ormolu_0_5_0_1; - fourmolu = hself.fourmolu_0_6_0_0; + fourmolu = hself.fourmolu_0_8_2_0; # Hlint is still broken hlint = doJailbreak (hself.callCabal2nix "hlint" inputs.hlint-34 { }); @@ -37,6 +37,9 @@ let hself.callCabal2nixWithOptions "haskell-language-server" ./. (pkgs.lib.concatStringsSep " " [ "-f-brittany" "-f-stylishhaskell" ]) { }; + + retrie = hself.retrie_1_1_0_0; + }); in { inherit disabledPlugins; diff --git a/configuration-ghc-92.nix b/configuration-ghc-92.nix index 3790e182a7..cead3f5193 100644 --- a/configuration-ghc-92.nix +++ b/configuration-ghc-92.nix @@ -35,6 +35,10 @@ let haskell-language-server = hself.callCabal2nixWithOptions "haskell-language-server" ./. (pkgs.lib.concatStringsSep " " [ "-fpedantic" "-f-hlint" ]) { }; + + # + retrie = hself.retrieHEAD; + }); in { inherit disabledPlugins; diff --git a/configuration-ghc-94.nix b/configuration-ghc-94.nix index 3568f65a51..772152be45 100644 --- a/configuration-ghc-94.nix +++ b/configuration-ghc-94.nix @@ -48,6 +48,9 @@ let haskell-language-server = hself.callCabal2nixWithOptions "haskell-language-server" ./. (pkgs.lib.concatStringsSep " " [ "-fpedantic" "-f-hlint" ]) { }; + + # + retrie = hself.retrieHEAD; }); in { inherit disabledPlugins; diff --git a/flake.lock b/flake.lock index 68dc199e7c..039b979e24 100644 --- a/flake.lock +++ b/flake.lock @@ -337,6 +337,18 @@ "type": "github" } }, + "retrie_1100": { + "flake": false, + "locked": { + "narHash": "sha256-yn8gguMdBtrB3fCa+4Rq6GHtPSyxYlriENPTgOvjeHE=", + "type": "tarball", + "url": "https://hackage.haskell.org/package/retrie-1.1.0.0/retrie-1.1.0.0.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://hackage.haskell.org/package/retrie-1.1.0.0/retrie-1.1.0.0.tar.gz" + } + }, "root": { "inputs": { "aeson-1520": "aeson-1520", @@ -365,6 +377,7 @@ "nixpkgs": "nixpkgs", "ptr-poker": "ptr-poker", "retrie": "retrie", + "retrie_1100": "retrie_1100", "stylish-haskell": "stylish-haskell" } }, diff --git a/flake.nix b/flake.nix index 3ff82834b8..53d683e073 100644 --- a/flake.nix +++ b/flake.nix @@ -59,6 +59,10 @@ url = "https://hackage.haskell.org/package/constraints-extras-0.3.2.1/constraints-extras-0.3.2.1.tar.gz"; flake = false; }; + retrie_1100 = { + url = "https://hackage.haskell.org/package/retrie-1.1.0.0/retrie-1.1.0.0.tar.gz"; + flake = false; + }; retrie = { url = "github:MercuryTechnologies/retrie/mercury/ghc94"; flake = false; @@ -188,6 +192,8 @@ hiedb = hsuper.callCabal2nix "hiedb" inputs.hiedb {}; hw-prim = hsuper.callCabal2nix "hw-prim" inputs.hw-prim {}; retrie = hsuper.callCabal2nix "retrie" inputs.retrie {}; + retrieHEAD = hsuper.callCabal2nix "retrie" inputs.retrie {}; + retrie_1_1_0_0 = hsuper.callCabal2nix "retrie" inputs.retrie_1100 {}; implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" inputs.implicit-hie-cradle {}; ghc-check = hself.callCabal2nix "ghc-check" inputs.ghc-check {}; From 2f04bcb76838a533d47d2eeef629ab2b9b09ed86 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 4 Nov 2022 12:17:47 -0700 Subject: [PATCH 07/78] unwrap big CPP conditional for GHC 9.4 --- .../src/Development/IDE/Plugin/CodeAction.hs | 10 ---------- .../src/Development/IDE/Plugin/CodeAction/Args.hs | 7 ------- 2 files changed, 17 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index f4c76212e2..309f4daed4 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -388,7 +388,6 @@ findDeclContainingLoc loc = find (\(L l _) -> loc `isInsideSrcSpan` locA l) -- imported from ‘Data.ByteString’ at B.hs:6:1-22 -- imported from ‘Data.ByteString.Lazy’ at B.hs:8:1-27 -- imported from ‘Data.Text’ at B.hs:7:1-16 -#if !MIN_VERSION_ghc(9,3,0) suggestHideShadow :: Annotated ParsedSource -> T.Text -> Maybe TcModuleResult -> Maybe HieAstResult -> Diagnostic -> [(T.Text, [Either TextEdit Rewrite])] suggestHideShadow ps fileContents mTcM mHar Diagnostic {_message, _range} | Just [identifier, modName, s] <- @@ -420,7 +419,6 @@ suggestHideShadow ps fileContents mTcM mHar Diagnostic {_message, _range} then maybeToList $ (\(_, te) -> (title, [Left te])) <$> newImportToEdit (hideImplicitPreludeSymbol identifier) ps fileContents else maybeToList $ (title,) . pure . pure . hideSymbol (T.unpack identifier) <$> mDecl | otherwise = [] -#endif findImportDeclByModuleName :: [LImportDecl GhcPs] -> String -> Maybe (LImportDecl GhcPs) findImportDeclByModuleName decls modName = flip find decls $ \case @@ -1264,7 +1262,6 @@ oneAndOthers = go isPreludeImplicit :: DynFlags -> Bool isPreludeImplicit = xopt Lang.ImplicitPrelude -#if !MIN_VERSION_ghc(9,3,0) -- | Suggests disambiguation for ambiguous symbols. suggestImportDisambiguation :: DynFlags -> @@ -1356,7 +1353,6 @@ suggestImportDisambiguation df (Just txt) ps fileContents diag@Diagnostic {..} <> "." <> symbol suggestImportDisambiguation _ _ _ _ _ = [] -#endif occursUnqualified :: T.Text -> ImportDecl GhcPs -> Bool occursUnqualified symbol ImportDecl{..} @@ -1379,7 +1375,6 @@ targetModuleName (ExistingImp (L _ ImportDecl{..} :| _)) = targetModuleName (ExistingImp _) = error "Cannot happen!" -#if !MIN_VERSION_ghc(9,3,0) disambiguateSymbol :: Annotated ParsedSource -> T.Text -> @@ -1412,7 +1407,6 @@ disambiguateSymbol ps fileContents Diagnostic {..} (T.unpack -> symbol) = \case liftParseAST @RdrName df $ T.unpack $ printOutputable $ L (mkGeneralSrcSpan "") rdr ] -#endif findImportDeclByRange :: [LImportDecl GhcPs] -> Range -> Maybe (LImportDecl GhcPs) findImportDeclByRange xs range = find (\(L (locA -> l) _)-> srcSpanToRange l == Just range) xs @@ -1431,7 +1425,6 @@ suggestFixConstructorImport Diagnostic{_range=_range,..} in [("Fix import of " <> fixedImport, TextEdit _range fixedImport)] | otherwise = [] -#if !MIN_VERSION_ghc(9,3,0) -- | Suggests a constraint for a declaration for which a constraint is missing. suggestConstraint :: DynFlags -> ParsedSource -> Diagnostic -> [(T.Text, Rewrite)] suggestConstraint df (makeDeltaAst -> parsedModule) diag@Diagnostic {..} @@ -1513,12 +1506,10 @@ suggestImplicitParameter (L _ HsModule {hsmodDecls}) Diagnostic {_message, _rang [( "Add " <> implicitT <> " to the context of " <> T.pack (printRdrName funId) , appendConstraint (T.unpack implicitT) hsib_body)] | otherwise = [] -#endif findTypeSignatureName :: T.Text -> Maybe T.Text findTypeSignatureName t = matchRegexUnifySpaces t "([^ ]+) :: " <&> head -#if !MIN_VERSION_ghc(9,3,0) -- | Suggests a constraint for a type signature with any number of existing constraints. suggestFunctionConstraint :: DynFlags -> ParsedSource -> Diagnostic -> T.Text -> [(T.Text, Rewrite)] @@ -1665,7 +1656,6 @@ suggestNewOrExtendImportForClassMethod packageExportsMap ps fileContents Diagnos ] <> [(quickFixImportKind "new.all", newImportAll moduleNameText)] | otherwise -> [] -#endif suggestNewImport :: ExportsMap -> Annotated ParsedSource -> T.Text -> Diagnostic -> [(T.Text, CodeActionKind, TextEdit)] suggestNewImport packageExportsMap ps fileContents Diagnostic{_message} diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs index 82e0134fcb..d76f4f9ffa 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs @@ -27,7 +27,6 @@ import Development.IDE.Core.Shake import Development.IDE.GHC.Compat import Development.IDE.GHC.Compat.ExactPrint import Development.IDE.GHC.ExactPrint -#if !MIN_VERSION_ghc(9,3,0) import Development.IDE.Plugin.CodeAction.ExactPrint (Rewrite, rewriteToEdit) #endif @@ -75,9 +74,7 @@ runGhcideCodeAction state (CodeActionParams _ _ (TextDocumentIdentifier uri) _ra Just (_, txt) -> pure txt _ -> pure Nothing caaDf <- onceIO $ fmap (ms_hspp_opts . pm_mod_summary) <$> caaParsedModule -#if !MIN_VERSION_ghc(9,3,0) caaAnnSource <- onceIO $ runRule GetAnnotatedParsedSource -#endif caaTmr <- onceIO $ runRule TypeCheck caaHar <- onceIO $ runRule GetHieAst caaBindings <- onceIO $ runRule GetBindings @@ -122,7 +119,6 @@ class ToTextEdit a where instance ToTextEdit TextEdit where toTextEdit _ = pure . pure -#if !MIN_VERSION_ghc(9,3,0) instance ToTextEdit Rewrite where toTextEdit CodeActionArgs {..} rw = fmap (fromMaybe []) $ runMaybeT $ do @@ -134,7 +130,6 @@ instance ToTextEdit Rewrite where let r = rewriteToEdit df rw #endif pure $ fromRight [] r -#endif instance ToTextEdit a => ToTextEdit [a] where toTextEdit caa = foldMap (toTextEdit caa) @@ -271,13 +266,11 @@ instance ToCodeAction r => ToCodeAction (Maybe DynFlags -> r) where instance ToCodeAction r => ToCodeAction (DynFlags -> r) where toCodeAction = toCodeAction2 caaDf -#if !MIN_VERSION_ghc(9,3,0) instance ToCodeAction r => ToCodeAction (Maybe (Annotated ParsedSource) -> r) where toCodeAction = toCodeAction1 caaAnnSource instance ToCodeAction r => ToCodeAction (Annotated ParsedSource -> r) where toCodeAction = toCodeAction2 caaAnnSource -#endif instance ToCodeAction r => ToCodeAction (Maybe TcModuleResult -> r) where toCodeAction = toCodeAction1 caaTmr From 16171856d459d145f7e9225ab3024c08709ced9a Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 4 Nov 2022 12:31:58 -0700 Subject: [PATCH 08/78] GHC 9.4 buildable by disabling a few suggest.. functions --- .../src/Development/IDE/Plugin/CodeAction.hs | 2 ++ .../src/Development/IDE/Plugin/CodeAction/Args.hs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index 309f4daed4..da132cd253 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -158,10 +158,12 @@ iePluginDescriptor recorder plId = , wrap suggestModuleTypo , wrap suggestFixConstructorImport , wrap suggestExtendImport +#if !MIN_VERSION_ghc(9,3,0) , wrap suggestImportDisambiguation , wrap suggestNewOrExtendImportForClassMethod , wrap suggestHideShadow , wrap suggestNewImport +#endif ] plId in mkExactprintPluginDescriptor recorder $ old {pluginHandlers = pluginHandlers old <> mkPluginHandler STextDocumentCodeAction codeAction } diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs index d76f4f9ffa..621f21f016 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs @@ -74,7 +74,9 @@ runGhcideCodeAction state (CodeActionParams _ _ (TextDocumentIdentifier uri) _ra Just (_, txt) -> pure txt _ -> pure Nothing caaDf <- onceIO $ fmap (ms_hspp_opts . pm_mod_summary) <$> caaParsedModule +#if !MIN_VERSION_ghc(9,3,0) caaAnnSource <- onceIO $ runRule GetAnnotatedParsedSource +#endif caaTmr <- onceIO $ runRule TypeCheck caaHar <- onceIO $ runRule GetHieAst caaBindings <- onceIO $ runRule GetBindings @@ -266,11 +268,13 @@ instance ToCodeAction r => ToCodeAction (Maybe DynFlags -> r) where instance ToCodeAction r => ToCodeAction (DynFlags -> r) where toCodeAction = toCodeAction2 caaDf +#if !MIN_VERSION_ghc(9,3,0) instance ToCodeAction r => ToCodeAction (Maybe (Annotated ParsedSource) -> r) where toCodeAction = toCodeAction1 caaAnnSource instance ToCodeAction r => ToCodeAction (Annotated ParsedSource -> r) where toCodeAction = toCodeAction2 caaAnnSource +#endif instance ToCodeAction r => ToCodeAction (Maybe TcModuleResult -> r) where toCodeAction = toCodeAction1 caaTmr From 04a0f43d22bfa8588711cf02866edd6de22fe5cd Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 4 Nov 2022 12:41:15 -0700 Subject: [PATCH 09/78] enable disabled suggest...! --- .../src/Development/IDE/Plugin/CodeAction.hs | 2 -- .../src/Development/IDE/Plugin/CodeAction/Args.hs | 8 -------- 2 files changed, 10 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index da132cd253..309f4daed4 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -158,12 +158,10 @@ iePluginDescriptor recorder plId = , wrap suggestModuleTypo , wrap suggestFixConstructorImport , wrap suggestExtendImport -#if !MIN_VERSION_ghc(9,3,0) , wrap suggestImportDisambiguation , wrap suggestNewOrExtendImportForClassMethod , wrap suggestHideShadow , wrap suggestNewImport -#endif ] plId in mkExactprintPluginDescriptor recorder $ old {pluginHandlers = pluginHandlers old <> mkPluginHandler STextDocumentCodeAction codeAction } diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs index 621f21f016..018e28c667 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs @@ -74,9 +74,7 @@ runGhcideCodeAction state (CodeActionParams _ _ (TextDocumentIdentifier uri) _ra Just (_, txt) -> pure txt _ -> pure Nothing caaDf <- onceIO $ fmap (ms_hspp_opts . pm_mod_summary) <$> caaParsedModule -#if !MIN_VERSION_ghc(9,3,0) caaAnnSource <- onceIO $ runRule GetAnnotatedParsedSource -#endif caaTmr <- onceIO $ runRule TypeCheck caaHar <- onceIO $ runRule GetHieAst caaBindings <- onceIO $ runRule GetBindings @@ -151,11 +149,7 @@ data CodeActionArgs = CodeActionArgs caaParsedModule :: IO (Maybe ParsedModule), caaContents :: IO (Maybe T.Text), caaDf :: IO (Maybe DynFlags), -#if MIN_VERSION_ghc(9,3,0) - caaAnnSource :: IO (Maybe ParsedSource), -#else caaAnnSource :: IO (Maybe (Annotated ParsedSource)), -#endif caaTmr :: IO (Maybe TcModuleResult), caaHar :: IO (Maybe HieAstResult), caaBindings :: IO (Maybe Bindings), @@ -268,13 +262,11 @@ instance ToCodeAction r => ToCodeAction (Maybe DynFlags -> r) where instance ToCodeAction r => ToCodeAction (DynFlags -> r) where toCodeAction = toCodeAction2 caaDf -#if !MIN_VERSION_ghc(9,3,0) instance ToCodeAction r => ToCodeAction (Maybe (Annotated ParsedSource) -> r) where toCodeAction = toCodeAction1 caaAnnSource instance ToCodeAction r => ToCodeAction (Annotated ParsedSource -> r) where toCodeAction = toCodeAction2 caaAnnSource -#endif instance ToCodeAction r => ToCodeAction (Maybe TcModuleResult -> r) where toCodeAction = toCodeAction1 caaTmr From dd9b3a1ab157f2f09976d7e707c0dbc064294bce Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 4 Nov 2022 17:08:00 -0400 Subject: [PATCH 10/78] hls-fourmolu-plugin is buildable --- plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal index e6dc991f81..1d976a1841 100644 --- a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal +++ b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal @@ -23,10 +23,6 @@ source-repository head location: git://github.com/haskell/haskell-language-server.git library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True exposed-modules: Ide.Plugin.Fourmolu , Ide.Plugin.Fourmolu.Shim @@ -48,10 +44,6 @@ library default-language: Haskell2010 test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test From 013217f58eb6ca69a02d1b6b9b05e92ac0ce110e Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 4 Nov 2022 17:15:07 -0400 Subject: [PATCH 11/78] hls-splice-plugin is buildable --- plugins/hls-splice-plugin/hls-splice-plugin.cabal | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plugins/hls-splice-plugin/hls-splice-plugin.cabal b/plugins/hls-splice-plugin/hls-splice-plugin.cabal index 8e045230c8..c2332ebb1d 100644 --- a/plugins/hls-splice-plugin/hls-splice-plugin.cabal +++ b/plugins/hls-splice-plugin/hls-splice-plugin.cabal @@ -27,10 +27,6 @@ source-repository head location: https://github.com/haskell/haskell-language-server.git library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True exposed-modules: Ide.Plugin.Splice Ide.Plugin.Splice.Types @@ -64,10 +60,6 @@ library TypeOperators test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test From 3fc6870686f0e73f6d57b71bb0c76bc27b857dfa Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 4 Nov 2022 17:20:00 -0400 Subject: [PATCH 12/78] hls-hlint-plugin is buildable --- plugins/hls-hlint-plugin/hls-hlint-plugin.cabal | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal index a29c40e033..345ba12dab 100644 --- a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal +++ b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal @@ -30,10 +30,6 @@ flag pedantic manual: True library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True exposed-modules: Ide.Plugin.Hlint hs-source-dirs: src build-depends: @@ -81,10 +77,6 @@ library TypeOperators test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test From 07e3d8e2119140cc27ae616df6e29c3009ed8702 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 4 Nov 2022 17:28:00 -0400 Subject: [PATCH 13/78] Enable plugins on GHC 9.4 --- haskell-language-server.cabal | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index f7e1b34980..e8dc0baa54 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -261,7 +261,7 @@ common tactic cpp-options: -Dhls_tactic common hlint - if flag(hlint) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(hlint) build-depends: hls-hlint-plugin ^>= 1.1 cpp-options: -Dhls_hlint @@ -281,7 +281,7 @@ common pragmas cpp-options: -Dhls_pragmas common splice - if flag(splice) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(splice) build-depends: hls-splice-plugin ^>=1.0.0.1 cpp-options: -Dhls_splice @@ -328,7 +328,7 @@ common floskell cpp-options: -Dhls_floskell common fourmolu - if flag(fourmolu) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(fourmolu) build-depends: hls-fourmolu-plugin ^>= 1.1 cpp-options: -Dhls_fourmolu @@ -348,7 +348,7 @@ common brittany cpp-options: -Dhls_brittany common refactor - if flag(refactor) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(refactor) build-depends: hls-refactor-plugin ^>= 1.0 cpp-options: -Dhls_refactor From e6fb469f3e5d8398ddccc9d30b9b1ffa6a5aa52e Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 4 Nov 2022 17:35:02 -0400 Subject: [PATCH 14/78] Add fourmolu for GHC 9.4 --- flake.nix | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/flake.nix b/flake.nix index 53d683e073..ea26065dff 100644 --- a/flake.nix +++ b/flake.nix @@ -202,6 +202,45 @@ if final.system == "aarch64-darwin" then overrideCabal hsuper.ormolu (_: { enableSeparateBinOutput = false; }) else hsuper.ormolu; + + # Fourmolu needs a handful of patches to build on GHC 9.4. + fourmolu = + appendPatches + (doJailbreak hsuper.fourmolu_0_8_2_0) + [ + # The GHC 9.4 pull request builds upon these unpublished changes, + # which is why we include them. + # + # Also, there is no PR for these changes. The fourmolu maintainers + # apparently commit straight to master … + (final.fetchpatch { + url = "https://github.com/fourmolu/fourmolu/commit/2c11f555945e755cc6e805de482404d5484d53b6.patch"; + sha256 = "sha256-bWJxOYQoLtsW7KaVbTxIxX+cFx9x3ekEmbA9NuJ3qtk="; + }) + (final.fetchpatch { + url = "https://github.com/fourmolu/fourmolu/commit/8eb7ef82676ab3bff9b249c74fc5d81dc23a2657.patch"; + sha256 = "sha256-rlKDRv27EGnlStNiKEniZiKSib1Zr9E3hGT3QuU5xLI="; + }) + (final.fetchpatch { + url = "https://github.com/fourmolu/fourmolu/commit/14b1bc832716edaf4239c4e364836185f0aa816b.patch"; + sha256 = "sha256-cfXh6ufxASbg2wXp/5ixfUNSC54O/eq8hx88lZKAJ18="; + }) + (final.fetchpatch { + url = "https://github.com/fourmolu/fourmolu/commit/e7fc4ec52aeeb50b3a886d1f55f4468ae6d46a46.patch"; + sha256 = "sha256-d+hg/mOEAybq461VLkmCrwtFyHgX8Q+715yaJXHn7/g="; + }) + (final.fetchpatch { + url = "https://github.com/fourmolu/fourmolu/commit/809256014cb6f65d8cd3447c0502493f57d3e307.patch"; + sha256 = "sha256-FdVj9MidRCfMUERVWvFV9k2rnvnorxJE7NpehNBQ8OQ="; + }) + + # The actual change to support GHC 9.4 + (final.fetchpatch { + url = "https://github.com/fourmolu/fourmolu/pull/242.patch"; + sha256 = "sha256-mWMtG+pkiNzmkXWVZhIILhhnPzQM070o6+hwyNZkY+0="; + includes = ["data/*" "src/*" "tests/*" "fourmolu.cabal"]; + }) + ]; }; hlsSources = From 0025609e17260856d3695a3ceca9b9be6531fe44 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 4 Nov 2022 17:41:36 -0400 Subject: [PATCH 15/78] fourmolu tweawk --- flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ea26065dff..a160640c0d 100644 --- a/flake.nix +++ b/flake.nix @@ -206,7 +206,9 @@ # Fourmolu needs a handful of patches to build on GHC 9.4. fourmolu = appendPatches - (doJailbreak hsuper.fourmolu_0_8_2_0) + (doJailbreak (if final.system == "aarch64-darwin" + then overrideCabal hsuper.fourmolu_0_8_2_0 (_: { enableSeparateBinOutput = false; }) + else hsuper.fourmolu_0_8_2_0)) [ # The GHC 9.4 pull request builds upon these unpublished changes, # which is why we include them. From 80efb1fca72e690e50abcb9dba36ad34a1e6f427 Mon Sep 17 00:00:00 2001 From: Gabriella Gonzalez Date: Mon, 7 Nov 2022 15:51:20 -0800 Subject: [PATCH 16/78] Fix `hls-hlint-plugin` build - Build against GHC 9.4 API - Increase upper bound on `hlint` --- plugins/hls-hlint-plugin/hls-hlint-plugin.cabal | 2 +- plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal index 345ba12dab..cc3c8c23b5 100644 --- a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal +++ b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal @@ -47,7 +47,7 @@ library , ghc-exactprint >=0.6.3.4 , ghcide ^>=1.8 , hashable - , hlint < 3.5 + , hlint < 3.6 , hls-plugin-api ^>=1.5 , hslogger , lens diff --git a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs index 280acf26f8..1fbbace05d 100644 --- a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs +++ b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs @@ -69,6 +69,9 @@ import Development.IDE.GHC.Compat (DynFlags, wopt) import qualified Development.IDE.GHC.Compat.Util as EnumSet +#if MIN_GHC_API_VERSION(9,2,0) +import qualified "ghc-lib-parser" GHC.Data.Strict as Strict +#endif #if MIN_GHC_API_VERSION(9,0,0) import "ghc-lib-parser" GHC.Types.SrcLoc hiding (RealSrcSpan) @@ -159,7 +162,9 @@ instance Pretty Log where type BufSpan = () #endif pattern RealSrcSpan :: GHC.RealSrcSpan -> Maybe BufSpan -> GHC.SrcSpan -#if MIN_GHC_API_VERSION(9,0,0) +#if MIN_GHC_API_VERSION(9,4,0) +pattern RealSrcSpan x y <- GHC.RealSrcSpan x (fromStrictMaybe -> y) +#elif MIN_GHC_API_VERSION(9,0,0) pattern RealSrcSpan x y = GHC.RealSrcSpan x y #else pattern RealSrcSpan x y <- ((,Nothing) -> (GHC.RealSrcSpan x, y)) @@ -167,6 +172,12 @@ pattern RealSrcSpan x y <- ((,Nothing) -> (GHC.RealSrcSpan x, y)) {-# COMPLETE RealSrcSpan, UnhelpfulSpan #-} #endif +#if MIN_GHC_API_VERSION(9,4,0) +fromStrictMaybe :: Strict.Maybe a -> Maybe a +fromStrictMaybe (Strict.Just a ) = Just a +fromStrictMaybe Strict.Nothing = Nothing +#endif + descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState descriptor recorder plId = (defaultPluginDescriptor plId) { pluginRules = rules recorder plId From 4f6a4510b788ee231a5bb13afbc593e416ada99b Mon Sep 17 00:00:00 2001 From: Gabriella Gonzalez Date: Mon, 7 Nov 2022 17:16:55 -0800 Subject: [PATCH 17/78] Fix build of `hls-splice-plugin` --- .../src/Ide/Plugin/Splice.hs | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs b/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs index 885151565e..5f67865d25 100644 --- a/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs +++ b/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs @@ -51,8 +51,11 @@ import Development.IDE.GHC.Compat as Compat hiding (getLoc) import Development.IDE.GHC.Compat.ExactPrint import qualified Development.IDE.GHC.Compat.Util as Util import Development.IDE.GHC.ExactPrint +#if MIN_VERSION_ghc(9,4,1) +import GHC.Data.Bag (Bag) +#endif import GHC.Exts -#if __GLASGOW_HASKELL__ >= 902 +#if MIN_VERSION_ghc(9,0,2) import GHC.Parser.Annotation (SrcSpanAnn'(..)) import qualified GHC.Types.Error as Error #endif @@ -271,7 +274,7 @@ adjustToRange uri ran (WorkspaceEdit mhult mlt x) = -- `GenLocated`. In GHC >= 9.2 this will be a SrcSpanAnn', with annotations; -- earlier it will just be a plain `SrcSpan`. {-# COMPLETE AsSrcSpan #-} -#if __GLASGOW_HASKELL__ >= 902 +#if MIN_VERSION_ghc(9,0,2) pattern AsSrcSpan :: SrcSpan -> SrcSpanAnn' a pattern AsSrcSpan locA <- SrcSpanAnn {locA} #else @@ -369,12 +372,12 @@ manualCalcEdit clientCapabilities reportEditor ran ps hscEnv typechkd srcSpan _e Right y -> unRenamedE dflags y _ -> pure Nothing let (warns, errs) = -#if __GLASGOW_HASKELL__ >= 902 +#if MIN_VERSION_ghc(9,0,2) (Error.getWarningMessages msgs, Error.getErrorMessages msgs) #else msgs #endif - pure $ (warns,) <$> fromMaybe (Left $ show errs) eresl + pure $ (warns,) <$> fromMaybe (Left $ showErrors errs) eresl unless (null warns) @@ -382,12 +385,31 @@ manualCalcEdit clientCapabilities reportEditor ran ps hscEnv typechkd srcSpan _e MtWarning [ "Warning during expanding: " , "" - , T.pack (show warns) + , T.pack (showBag warns) ] pure resl where dflags = hsc_dflags hscEnv +#if MIN_VERSION_ghc(9,4,1) + showErrors = showBag +#else + showErrors = show +#endif + +#if MIN_VERSION_ghc(9,4,1) +showBag :: Error.Diagnostic a => Bag (Error.MsgEnvelope a) -> String +showBag = show . fmap (fmap toDiagnosticMessage) + +toDiagnosticMessage :: Error.Diagnostic a => a -> Error.DiagnosticMessage +toDiagnosticMessage message = + Error.DiagnosticMessage + { diagMessage = Error.diagnosticMessage message + , diagReason = Error.diagnosticReason message + , diagHints = Error.diagnosticHints message + } +#endif + -- | FIXME: Is thereAny "clever" way to do this exploiting TTG? unRenamedE :: forall ast m l. @@ -397,15 +419,21 @@ unRenamedE :: TransformT m (LocatedAn l (ast GhcPs)) unRenamedE dflags expr = do uniq <- show <$> uniqueSrcSpanT -#if __GLASGOW_HASKELL__ >= 902 +#if MIN_VERSION_ghc(9,0,2) expr' <- #else (_anns, expr') <- #endif - either (fail . show) pure $ + either (fail . showErrors) pure $ parseAST @_ @(ast GhcPs) dflags uniq $ showSDoc dflags $ ppr expr pure expr' + where +#if MIN_VERSION_ghc(9,4,1) + showErrors = showBag . Error.getMessages +#else + showErrors = show +#endif data SearchResult r = Continue | Stop | Here r From bb863b410ed541bb8116e6746c782170c268198e Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 4 Nov 2022 14:49:27 -0700 Subject: [PATCH 18/78] annotation on close parenthesis. still need more work. --- .../src/Development/IDE/Plugin/CodeAction/ExactPrint.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs index 234745d55a..7ffb379b6b 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs @@ -453,7 +453,7 @@ extendImportViaParent df parent child (L l it@ImportDecl{..}) transferAnn lAbs x $ \old -> old{annsDP = annsDP old ++ [(G AnnOpenP, DP (0, 1)), (G AnnCloseP, dp00)]} addSimpleAnnT childRdr dp00 [(G AnnVal, dp00)] #else - x :: LIE GhcPs = L ll' $ IEThingWith (addAnns mempty [AddEpAnn AnnOpenP (EpaDelta (SameLine 1) []), AddEpAnn AnnCloseP def] emptyComments) absIE NoIEWildcard [childLIE] + x :: LIE GhcPs = L ll' $ IEThingWith (addAnns mempty [AddEpAnn AnnOpenP (epl 1), AddEpAnn AnnCloseP (epl 0)] emptyComments) absIE NoIEWildcard [childLIE] #endif return $ L l it{ideclHiding = Just (hide, L l' $ reverse pre ++ [x] ++ xs)} #if !MIN_VERSION_ghc(9,2,0) @@ -467,7 +467,7 @@ extendImportViaParent df parent child (L l it@ImportDecl{..}) #if MIN_VERSION_ghc(9,2,0) let it' = it{ideclHiding = Just (hide, lies)} thing = IEThingWith newl twIE (IEWildcard 2) [] - newl = (\ann -> ann ++ [(AddEpAnn AnnDotdot d0)]) <$> l''' + newl = addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments lies = L l' $ reverse pre ++ [L l'' thing] ++ xs return $ L l it' #else @@ -520,7 +520,7 @@ extendImportViaParent df parent child (L l it@ImportDecl{..}) #else let parentLIE = reLocA $ L srcParent $ (if isParentOperator then IEType (epl 0) parentRdr' else IEName parentRdr') parentRdr' = modifyAnns parentRdr $ \case - it@NameAnn{nann_adornment = NameParens} -> it{nann_open = epl 1} + it@NameAnn{nann_adornment = NameParens} -> it{nann_open = epl 1, nann_close = epl 0} other -> other childLIE = reLocA $ L srcChild $ IEName childRdr #endif From c8334fa68cb0c37807b82f1349a7a9d9656b1388 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 7 Nov 2022 14:54:48 -0800 Subject: [PATCH 19/78] found where closing parenthesis were missing --- .../IDE/Plugin/CodeAction/ExactPrint.hs | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs index 7ffb379b6b..f3cf5c322a 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs @@ -48,7 +48,7 @@ import GHC (AddEpAnn (..), AnnContext (..), AnnList (..), IsUnicodeSyntax (NormalSyntax), NameAdornment (NameParens), TrailingAnn (AddCommaAnn), addAnns, ann, - emptyComments, reAnnL) + emptyComments, noSrcSpanA, reAnnL) #else import Control.Applicative (Alternative ((<|>))) import Control.Monad.Extra (whenJust) @@ -464,7 +464,20 @@ extendImportViaParent df parent child (L l it@ImportDecl{..}) -- ThingWith ie lies' => ThingWith ie (lies' ++ [child]) | parent == unIEWrappedName ie , child == wildCardSymbol = do -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,4,0) + -- srcHiding <- uniqueSrcSpanT + let -- ann_94 = l' -- noAnnSrcSpanDP0 srcHiding + ann_94' = flip (fmap.fmap) l' $ \x -> x + {al_open = Just $ AddEpAnn AnnOpenP (epl 0) + ,al_close = Just $ AddEpAnn AnnCloseP (epl 0) + } + let it' = it{ideclHiding = Just (hide, lies)} + thing = IEThingWith newl twIE (IEWildcard 2) [] + newl = addAnns mempty [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments + -- addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments + lies = L ann_94' $ reverse pre ++ [L l'' thing] ++ xs + return $ L l it' +#elif MIN_VERSION_ghc(9,2,0) let it' = it{ideclHiding = Just (hide, lies)} thing = IEThingWith newl twIE (IEWildcard 2) [] newl = addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments @@ -544,7 +557,24 @@ extendImportViaParent df parent child (L l it@ImportDecl{..}) lies' = addCommaInImportList (reverse pre) x #endif + +{- + + srcHiding <- uniqueSrcSpanT + let ann_94 = noAnnSrcSpanDP0 srcHiding + ann_94' = flip (fmap.fmap) ann_94 $ \x -> x + {al_rest = [AddEpAnn AnnHiding (epl 1)] + ,al_open = Just $ AddEpAnn AnnOpenP (epl 1) + ,al_close = Just $ AddEpAnn AnnCloseP (epl 0) + } + + -- let l_94 = noSrcSpanA { ann = addAnns mempty [AddEpAnn AnnCloseP (epl 0)] emptyComments } + -- l' + return $ L l it{ideclHiding = Just (hide, L ann_94' lies')} + +-} return $ L l it{ideclHiding = Just (hide, L l' lies')} + extendImportViaParent _ _ _ _ = lift $ Left "Unable to extend the import list via parent" #if MIN_VERSION_ghc(9,2,0) From 83aef0ff4ce44b12af3896e62fe1f97776a96dc1 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 09:15:09 -0800 Subject: [PATCH 20/78] examine internal annotation information. --- .../IDE/Plugin/CodeAction/ExactPrint.hs | 60 ++++++++++++++++--- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs index f3cf5c322a..e44c97140d 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs @@ -62,6 +62,8 @@ import Language.Haskell.GHC.ExactPrint.Types (DeltaPos (DP), KeywordId (G), mkAnnKey) #endif +import Debug.Trace (trace) +import GHC (EpaLocation (..)) ------------------------------------------------------------------------------ -- | Construct a 'Rewrite', replacing the node at the given 'SrcSpan' with the @@ -453,7 +455,7 @@ extendImportViaParent df parent child (L l it@ImportDecl{..}) transferAnn lAbs x $ \old -> old{annsDP = annsDP old ++ [(G AnnOpenP, DP (0, 1)), (G AnnCloseP, dp00)]} addSimpleAnnT childRdr dp00 [(G AnnVal, dp00)] #else - x :: LIE GhcPs = L ll' $ IEThingWith (addAnns mempty [AddEpAnn AnnOpenP (epl 1), AddEpAnn AnnCloseP (epl 0)] emptyComments) absIE NoIEWildcard [childLIE] + x :: LIE GhcPs = L ll' $ IEThingWith (addAnns mempty [AddEpAnn AnnOpenP (EpaDelta (SameLine 1) []), AddEpAnn AnnCloseP def] emptyComments) absIE NoIEWildcard [childLIE] #endif return $ L l it{ideclHiding = Just (hide, L l' $ reverse pre ++ [x] ++ xs)} #if !MIN_VERSION_ghc(9,2,0) @@ -465,22 +467,64 @@ extendImportViaParent df parent child (L l it@ImportDecl{..}) | parent == unIEWrappedName ie , child == wildCardSymbol = do #if MIN_VERSION_ghc(9,4,0) - -- srcHiding <- uniqueSrcSpanT - let -- ann_94 = l' -- noAnnSrcSpanDP0 srcHiding + let insertDotdot ann = + trace ("ann size = " ++ show (Prelude.length ann)) $ goA [] ann + where + formatLoc (EpaSpan s) = "RealSrcSpan" + formatLoc (EpaDelta dp comm) = show (dp, comm) + goA ys [] = pure ys + goA ys (x@(AddEpAnn tag loc):xs) = + trace ("x = " ++ show tag ++ ", " ++ formatLoc loc) + $ case x of + AddEpAnn AnnOpenP s -> goA (ys ++ [AddEpAnn AnnOpenP s]) xs + AddEpAnn AnnCloseP _ -> goA (ys ++ [AddEpAnn AnnCloseP (epl 0), AddEpAnn AnnDotdot (epl 0)]) xs + _ -> goA ys xs + + -- (\ann -> [AddEpAnn AnnDotdot d0] ++ ann) <$> l''' -- l''' -- (\ann -> [AddEpAnn AnnOpenP (epl 1), AddEpAnn AnnDotdot d0] ++ ann ++ [AddEpAnn AnnCloseP (epl 0)]) <$> l''' + -- newl = addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments + -- newl = addAnns mempty [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments + -- addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments + let ann_ = anns l''' + + ann_' <- insertDotdot ann_ + -- ann_' = [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] + let newl = -- l''' -- + l''' {anns = ann_'} + -- addAnns {- l''' -} mempty [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments + -- (\ann -> [AddEpAnn AnnDotdot d0] ++ ann) <$> l''' -- + -- ann_94 = l' -- noAnnSrcSpanDP0 srcHiding + let thing = IEThingAll newl twIE -- IEThingWith newl twIE (IEWildcard 2) [] ann_94' = flip (fmap.fmap) l' $ \x -> x {al_open = Just $ AddEpAnn AnnOpenP (epl 0) ,al_close = Just $ AddEpAnn AnnCloseP (epl 0) } - let it' = it{ideclHiding = Just (hide, lies)} - thing = IEThingWith newl twIE (IEWildcard 2) [] - newl = addAnns mempty [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments - -- addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments lies = L ann_94' $ reverse pre ++ [L l'' thing] ++ xs + it' = it{ideclHiding = Just (hide, lies)} + return $ L l it' #elif MIN_VERSION_ghc(9,2,0) + -- experiment + let insertDotdot ann = + trace ("ann size = " ++ show (Prelude.length ann)) $ goA [] ann + where + formatLoc (EpaSpan s) = "RealSrcSpan" + formatLoc (EpaDelta dp comm) = show dp -- , (unLoc comm)) + goA ys [] = pure ys + goA ys (x@(AddEpAnn tag loc):xs) = + trace ("x = " ++ show tag ++ ", " ++ formatLoc loc) + $ case x of + AddEpAnn AnnOpenP s -> goA (ys ++ [AddEpAnn AnnOpenP s]) xs + AddEpAnn AnnCloseP _ -> goA (ys ++ [AddEpAnn AnnCloseP (epl 0), AddEpAnn AnnDotdot (epl 0)]) xs + _ -> goA ys xs + let ann_ = anns l''' + ann_' <- insertDotdot ann_ + let newl = l''' {anns = ann_'} + let it' = it{ideclHiding = Just (hide, lies)} thing = IEThingWith newl twIE (IEWildcard 2) [] - newl = addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments + newl = (\ann -> ann ++ [(AddEpAnn AnnDotdot d0)]) <$> l''' + + -- newl = addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments lies = L l' $ reverse pre ++ [L l'' thing] ++ xs return $ L l it' #else From cc327a1e73e2e5e54eb323f0917d70ee21756897 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 09:51:41 -0800 Subject: [PATCH 21/78] make use of makeDeltaAst. This fixes most of test failures in GHC 9.4 --- .../IDE/Plugin/CodeAction/ExactPrint.hs | 67 +++---------------- 1 file changed, 11 insertions(+), 56 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs index e44c97140d..ddae338e24 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs @@ -64,6 +64,8 @@ import Language.Haskell.GHC.ExactPrint.Types (DeltaPos (DP), import Debug.Trace (trace) import GHC (EpaLocation (..)) +import Language.Haskell.GHC.ExactPrint.ExactPrint (makeDeltaAst, showAst) + ------------------------------------------------------------------------------ -- | Construct a 'Rewrite', replacing the node at the given 'SrcSpan' with the @@ -352,8 +354,16 @@ extendImport mparent identifier lDecl@(L l _) = Rewrite (locA l) $ \df -> do case mparent of -- This will also work for `ImportAllConstructors` +#if !MIN_VERSION_ghc(9,2,0) Just parent -> extendImportViaParent df parent identifier lDecl _ -> extendImportTopLevel identifier lDecl +#else + -- Parsed source in GHC 9.4 uses absolute position annotation (RealSrcSpan), + -- while rewriting relies on relative positions. ghc-exactprint has the utility + -- makeDeltaAst for relativization. + Just parent -> extendImportViaParent df parent identifier (makeDeltaAst lDecl) + _ -> extendImportTopLevel identifier (makeDeltaAst lDecl) +#endif -- | Add an identifier or a data type to import list. Expects a Delta AST -- @@ -466,65 +476,10 @@ extendImportViaParent df parent child (L l it@ImportDecl{..}) -- ThingWith ie lies' => ThingWith ie (lies' ++ [child]) | parent == unIEWrappedName ie , child == wildCardSymbol = do -#if MIN_VERSION_ghc(9,4,0) - let insertDotdot ann = - trace ("ann size = " ++ show (Prelude.length ann)) $ goA [] ann - where - formatLoc (EpaSpan s) = "RealSrcSpan" - formatLoc (EpaDelta dp comm) = show (dp, comm) - goA ys [] = pure ys - goA ys (x@(AddEpAnn tag loc):xs) = - trace ("x = " ++ show tag ++ ", " ++ formatLoc loc) - $ case x of - AddEpAnn AnnOpenP s -> goA (ys ++ [AddEpAnn AnnOpenP s]) xs - AddEpAnn AnnCloseP _ -> goA (ys ++ [AddEpAnn AnnCloseP (epl 0), AddEpAnn AnnDotdot (epl 0)]) xs - _ -> goA ys xs - - -- (\ann -> [AddEpAnn AnnDotdot d0] ++ ann) <$> l''' -- l''' -- (\ann -> [AddEpAnn AnnOpenP (epl 1), AddEpAnn AnnDotdot d0] ++ ann ++ [AddEpAnn AnnCloseP (epl 0)]) <$> l''' - -- newl = addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments - -- newl = addAnns mempty [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments - -- addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments - let ann_ = anns l''' - - ann_' <- insertDotdot ann_ - -- ann_' = [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] - let newl = -- l''' -- - l''' {anns = ann_'} - -- addAnns {- l''' -} mempty [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments - -- (\ann -> [AddEpAnn AnnDotdot d0] ++ ann) <$> l''' -- - -- ann_94 = l' -- noAnnSrcSpanDP0 srcHiding - let thing = IEThingAll newl twIE -- IEThingWith newl twIE (IEWildcard 2) [] - ann_94' = flip (fmap.fmap) l' $ \x -> x - {al_open = Just $ AddEpAnn AnnOpenP (epl 0) - ,al_close = Just $ AddEpAnn AnnCloseP (epl 0) - } - lies = L ann_94' $ reverse pre ++ [L l'' thing] ++ xs - it' = it{ideclHiding = Just (hide, lies)} - - return $ L l it' -#elif MIN_VERSION_ghc(9,2,0) - -- experiment - let insertDotdot ann = - trace ("ann size = " ++ show (Prelude.length ann)) $ goA [] ann - where - formatLoc (EpaSpan s) = "RealSrcSpan" - formatLoc (EpaDelta dp comm) = show dp -- , (unLoc comm)) - goA ys [] = pure ys - goA ys (x@(AddEpAnn tag loc):xs) = - trace ("x = " ++ show tag ++ ", " ++ formatLoc loc) - $ case x of - AddEpAnn AnnOpenP s -> goA (ys ++ [AddEpAnn AnnOpenP s]) xs - AddEpAnn AnnCloseP _ -> goA (ys ++ [AddEpAnn AnnCloseP (epl 0), AddEpAnn AnnDotdot (epl 0)]) xs - _ -> goA ys xs - let ann_ = anns l''' - ann_' <- insertDotdot ann_ - let newl = l''' {anns = ann_'} - +#if MIN_VERSION_ghc(9,2,0) let it' = it{ideclHiding = Just (hide, lies)} thing = IEThingWith newl twIE (IEWildcard 2) [] newl = (\ann -> ann ++ [(AddEpAnn AnnDotdot d0)]) <$> l''' - - -- newl = addAnns l''' [AddEpAnn AnnOpenP (epl 0), AddEpAnn AnnDotdot d0, AddEpAnn AnnCloseP (epl 0)] emptyComments lies = L l' $ reverse pre ++ [L l'' thing] ++ xs return $ L l it' #else From e05ad59be99098975486997e0e1f9898bc1a8312 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 10:19:51 -0800 Subject: [PATCH 22/78] remove dead code --- cabal.project | 2 +- .../IDE/Plugin/CodeAction/ExactPrint.hs | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/cabal.project b/cabal.project index 4dee7fc198..e0e3816112 100644 --- a/cabal.project +++ b/cabal.project @@ -12,7 +12,7 @@ packages: ./plugins/hls-tactics-plugin ./plugins/hls-brittany-plugin ./plugins/hls-stylish-haskell-plugin - ./plugins/hls-fourmolu-plugin + -- ./plugins/hls-fourmolu-plugin ./plugins/hls-class-plugin ./plugins/hls-eval-plugin ./plugins/hls-explicit-imports-plugin diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs index ddae338e24..aaf9852af4 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs @@ -556,24 +556,7 @@ extendImportViaParent df parent child (L l it@ImportDecl{..}) lies' = addCommaInImportList (reverse pre) x #endif - -{- - - srcHiding <- uniqueSrcSpanT - let ann_94 = noAnnSrcSpanDP0 srcHiding - ann_94' = flip (fmap.fmap) ann_94 $ \x -> x - {al_rest = [AddEpAnn AnnHiding (epl 1)] - ,al_open = Just $ AddEpAnn AnnOpenP (epl 1) - ,al_close = Just $ AddEpAnn AnnCloseP (epl 0) - } - - -- let l_94 = noSrcSpanA { ann = addAnns mempty [AddEpAnn AnnCloseP (epl 0)] emptyComments } - -- l' - return $ L l it{ideclHiding = Just (hide, L ann_94' lies')} - --} return $ L l it{ideclHiding = Just (hide, L l' lies')} - extendImportViaParent _ _ _ _ = lift $ Left "Unable to extend the import list via parent" #if MIN_VERSION_ghc(9,2,0) From d9a65099806dc22acc48911ab58d3fb99e1d1e0e Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 11:54:11 -0800 Subject: [PATCH 23/78] update apply-refact and hlint deps --- cabal.project | 2 +- configuration-ghc-94.nix | 3 +-- flake.lock | 31 +++++++++++++++++++++++++++++++ flake.nix | 9 +++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/cabal.project b/cabal.project index e0e3816112..4dee7fc198 100644 --- a/cabal.project +++ b/cabal.project @@ -12,7 +12,7 @@ packages: ./plugins/hls-tactics-plugin ./plugins/hls-brittany-plugin ./plugins/hls-stylish-haskell-plugin - -- ./plugins/hls-fourmolu-plugin + ./plugins/hls-fourmolu-plugin ./plugins/hls-class-plugin ./plugins/hls-eval-plugin ./plugins/hls-explicit-imports-plugin diff --git a/configuration-ghc-94.nix b/configuration-ghc-94.nix index 772152be45..a314209d8c 100644 --- a/configuration-ghc-94.nix +++ b/configuration-ghc-94.nix @@ -2,7 +2,6 @@ let disabledPlugins = [ - "hls-hlint-plugin" # That one is not technically a plugin, but by putting it in this list, we # get it removed from the top level list of requirement and it is not pull # in the nix shell. @@ -27,7 +26,7 @@ let ghc-exactprint = hself.callCabal2nix "ghc-exactprint" inputs.ghc-exactprint-160 { }; # Hlint is still broken - hlint = doJailbreak (hself.callCabal2nix "hlint" inputs.hlint { }); + hlint = hsuper.callCabal2nix "hlint" inputs.hlint-35 {}; stylish-haskell = appendConfigureFlag hsuper.stylish-haskell "-fghc-lib"; diff --git a/flake.lock b/flake.lock index 039b979e24..64d0d7ed71 100644 --- a/flake.lock +++ b/flake.lock @@ -29,6 +29,23 @@ "type": "github" } }, + "apply-refact": { + "flake": false, + "locked": { + "lastModified": 1666418383, + "narHash": "sha256-a/qTzS1dgDfjT1vnOkaMHegKtBo6F1j3q62HY8g0V/Y=", + "owner": "July541", + "repo": "apply-refact", + "rev": "1943b3848e10f9824806c4a3a286fcaec22b4bb8", + "type": "github" + }, + "original": { + "owner": "July541", + "ref": "ghc-9.4", + "repo": "apply-refact", + "type": "github" + } + }, "brittany-01312": { "flake": false, "locked": { @@ -244,6 +261,18 @@ "url": "https://hackage.haskell.org/package/hw-prim-0.6.3.2/hw-prim-0.6.3.2.tar.gz" } }, + "hlint-35": { + "flake": false, + "locked": { + "narHash": "sha256-qQNUlQQnahUGEO92Lm0RwjTGBGr2Yaw0KRuFRMoc5No=", + "type": "tarball", + "url": "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz" + } + }, "implicit-hie-cradle": { "flake": false, "locked": { @@ -353,6 +382,7 @@ "inputs": { "aeson-1520": "aeson-1520", "all-cabal-hashes-unpacked": "all-cabal-hashes-unpacked", + "apply-refact": "apply-refact", "brittany-01312": "brittany-01312", "constraints-extras": "constraints-extras", "entropy": "entropy", @@ -370,6 +400,7 @@ "hlint": "hlint", "hlint-34": "hlint-34", "hw-prim": "hw-prim", + "hlint-35": "hlint-35", "implicit-hie-cradle": "implicit-hie-cradle", "lsp": "lsp", "lsp-test": "lsp-test", diff --git a/flake.nix b/flake.nix index a160640c0d..4a4d9526f3 100644 --- a/flake.nix +++ b/flake.nix @@ -91,6 +91,10 @@ url = "https://hackage.haskell.org/package/hlint-3.4/hlint-3.4.tar.gz"; flake = false; }; + hlint-35 = { + url = "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz"; + flake = false; + }; ptr-poker = { url = "https://hackage.haskell.org/package/ptr-poker-0.1.2.8/ptr-poker-0.1.2.8.tar.gz"; flake = false; @@ -119,6 +123,10 @@ url = "https://hackage.haskell.org/package/hw-prim-0.6.3.2/hw-prim-0.6.3.2.tar.gz"; flake = false; }; + apply-refact = { + url = "github:July541/apply-refact/ghc-9.4"; + flake = false; + }; }; outputs = inputs@{ self, nixpkgs, flake-compat, flake-utils, gitignore, all-cabal-hashes-unpacked, ... }: @@ -194,6 +202,7 @@ retrie = hsuper.callCabal2nix "retrie" inputs.retrie {}; retrieHEAD = hsuper.callCabal2nix "retrie" inputs.retrie {}; retrie_1_1_0_0 = hsuper.callCabal2nix "retrie" inputs.retrie_1100 {}; + apply-refact = hsuper.callCabal2nix "apply-refact" inputs.apply-refact {}; implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" inputs.implicit-hie-cradle {}; ghc-check = hself.callCabal2nix "ghc-check" inputs.ghc-check {}; From b4511b9a66b97225cfc3af4c5d25d6fe2fc4a8f2 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 11:56:34 -0800 Subject: [PATCH 24/78] temporarily comment out hls-fourmolu-plugin. --- cabal.project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index 4dee7fc198..e0e3816112 100644 --- a/cabal.project +++ b/cabal.project @@ -12,7 +12,7 @@ packages: ./plugins/hls-tactics-plugin ./plugins/hls-brittany-plugin ./plugins/hls-stylish-haskell-plugin - ./plugins/hls-fourmolu-plugin + -- ./plugins/hls-fourmolu-plugin ./plugins/hls-class-plugin ./plugins/hls-eval-plugin ./plugins/hls-explicit-imports-plugin From 24f45d2e26132833e9505bd4e7be3b49b4bea777 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 13:50:41 -0800 Subject: [PATCH 25/78] comment out build-tool-depends. then hls-fourmolu-plugin build succeeds with cabal v2-build --- cabal.project | 2 +- plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cabal.project b/cabal.project index e0e3816112..4dee7fc198 100644 --- a/cabal.project +++ b/cabal.project @@ -12,7 +12,7 @@ packages: ./plugins/hls-tactics-plugin ./plugins/hls-brittany-plugin ./plugins/hls-stylish-haskell-plugin - -- ./plugins/hls-fourmolu-plugin + ./plugins/hls-fourmolu-plugin ./plugins/hls-class-plugin ./plugins/hls-eval-plugin ./plugins/hls-explicit-imports-plugin diff --git a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal index 1d976a1841..c4a5f19ed0 100644 --- a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal +++ b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal @@ -49,8 +49,8 @@ test-suite tests hs-source-dirs: test main-is: Main.hs ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N - build-tool-depends: - fourmolu:fourmolu + -- build-tool-depends: + -- fourmolu:fourmolu build-depends: , base , aeson From fd92fa5a5ad62bd4c72642941ab6012d21494596 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 14:12:20 -0800 Subject: [PATCH 26/78] remove unused fourmolu flake inputs --- flake.lock | 26 -------------------------- flake.nix | 8 -------- 2 files changed, 34 deletions(-) diff --git a/flake.lock b/flake.lock index 64d0d7ed71..f36af93fd4 100644 --- a/flake.lock +++ b/flake.lock @@ -113,30 +113,6 @@ "type": "github" } }, - "fourmolu": { - "flake": false, - "locked": { - "narHash": "sha256-uo5UE2SzrimnZl+JjJ30Hlg/nIw1OXJTPFIgkQopaI0=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.5.0.1/fourmolu-0.5.0.1.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.5.0.1/fourmolu-0.5.0.1.tar.gz" - } - }, - "fourmolu-0300": { - "flake": false, - "locked": { - "narHash": "sha256-SFBwhkXfDArITiBSxGSp2qf8gl+yBpWHglBB5aKeaBU=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.3.0.0/fourmolu-0.3.0.0.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.3.0.0/fourmolu-0.3.0.0.tar.gz" - } - }, "ghc-check": { "flake": false, "locked": { @@ -388,8 +364,6 @@ "entropy": "entropy", "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "fourmolu": "fourmolu", - "fourmolu-0300": "fourmolu-0300", "ghc-check": "ghc-check", "ghc-exactprint": "ghc-exactprint", "ghc-exactprint-150": "ghc-exactprint-150", diff --git a/flake.nix b/flake.nix index 4a4d9526f3..1a527255ba 100644 --- a/flake.nix +++ b/flake.nix @@ -67,14 +67,6 @@ url = "github:MercuryTechnologies/retrie/mercury/ghc94"; flake = false; }; - fourmolu = { - url = "https://hackage.haskell.org/package/fourmolu-0.5.0.1/fourmolu-0.5.0.1.tar.gz"; - flake = false; - }; - fourmolu-0300 = { - url = "https://hackage.haskell.org/package/fourmolu-0.3.0.0/fourmolu-0.3.0.0.tar.gz"; - flake = false; - }; aeson-1520= { url = "https://hackage.haskell.org/package/aeson-1.5.2.0/aeson-1.5.2.0.tar.gz"; flake = false; From 49aeb73b64b036b4c94e6bd1d204e9ccd3870105 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 14:36:16 -0800 Subject: [PATCH 27/78] fix ghc 9.0 build again. --- configuration-ghc-92.nix | 1 + configuration-ghc-94.nix | 2 ++ flake.nix | 2 +- plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs | 2 +- .../src/Development/IDE/Plugin/CodeAction/ExactPrint.hs | 4 +--- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/configuration-ghc-92.nix b/configuration-ghc-92.nix index cead3f5193..7799c05c8d 100644 --- a/configuration-ghc-92.nix +++ b/configuration-ghc-92.nix @@ -38,6 +38,7 @@ let # retrie = hself.retrieHEAD; + apply-refact = hself.apply-refactHEAD; }); in { diff --git a/configuration-ghc-94.nix b/configuration-ghc-94.nix index a314209d8c..c813c43886 100644 --- a/configuration-ghc-94.nix +++ b/configuration-ghc-94.nix @@ -50,6 +50,8 @@ let # retrie = hself.retrieHEAD; + apply-refact = hself.apply-refactHEAD; + }); in { inherit disabledPlugins; diff --git a/flake.nix b/flake.nix index 1a527255ba..b8e67a0ef0 100644 --- a/flake.nix +++ b/flake.nix @@ -194,7 +194,7 @@ retrie = hsuper.callCabal2nix "retrie" inputs.retrie {}; retrieHEAD = hsuper.callCabal2nix "retrie" inputs.retrie {}; retrie_1_1_0_0 = hsuper.callCabal2nix "retrie" inputs.retrie_1100 {}; - apply-refact = hsuper.callCabal2nix "apply-refact" inputs.apply-refact {}; + apply-refactHEAD = hsuper.callCabal2nix "apply-refact" inputs.apply-refact {}; implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" inputs.implicit-hie-cradle {}; ghc-check = hself.callCabal2nix "ghc-check" inputs.ghc-check {}; diff --git a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs index 1fbbace05d..6a199a0e09 100644 --- a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs +++ b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs @@ -69,7 +69,7 @@ import Development.IDE.GHC.Compat (DynFlags, wopt) import qualified Development.IDE.GHC.Compat.Util as EnumSet -#if MIN_GHC_API_VERSION(9,2,0) +#if MIN_GHC_API_VERSION(9,4,0) import qualified "ghc-lib-parser" GHC.Data.Strict as Strict #endif #if MIN_GHC_API_VERSION(9,0,0) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs index aaf9852af4..afc1b9b5e2 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs @@ -49,6 +49,7 @@ import GHC (AddEpAnn (..), AnnContext (..), AnnList (..), NameAdornment (NameParens), TrailingAnn (AddCommaAnn), addAnns, ann, emptyComments, noSrcSpanA, reAnnL) +import Language.Haskell.GHC.ExactPrint.ExactPrint (makeDeltaAst, showAst) #else import Control.Applicative (Alternative ((<|>))) import Control.Monad.Extra (whenJust) @@ -62,9 +63,6 @@ import Language.Haskell.GHC.ExactPrint.Types (DeltaPos (DP), KeywordId (G), mkAnnKey) #endif -import Debug.Trace (trace) -import GHC (EpaLocation (..)) -import Language.Haskell.GHC.ExactPrint.ExactPrint (makeDeltaAst, showAst) ------------------------------------------------------------------------------ From 63ba2cbeee932d890f12aaca93c95233620c5bda Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 15:34:47 -0800 Subject: [PATCH 28/78] hlint and fourmolu for GHC 9.2! --- configuration-ghc-90.nix | 1 + configuration-ghc-92.nix | 6 ++---- configuration-ghc-94.nix | 2 +- flake.lock | 9 +++++---- flake.nix | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/configuration-ghc-90.nix b/configuration-ghc-90.nix index 34f1e42bb7..25bb53f95e 100644 --- a/configuration-ghc-90.nix +++ b/configuration-ghc-90.nix @@ -39,6 +39,7 @@ let { }; retrie = hself.retrie_1_1_0_0; + fourmolu = hself.fourmolu_0_8_2_0; }); in { diff --git a/configuration-ghc-92.nix b/configuration-ghc-92.nix index 7799c05c8d..03ff303a96 100644 --- a/configuration-ghc-92.nix +++ b/configuration-ghc-92.nix @@ -2,7 +2,6 @@ let disabledPlugins = [ - "hls-hlint-plugin" # That one is not technically a plugin, but by putting it in this list, we # get it removed from the top level list of requirement and it is not pull # in the nix shell. @@ -26,8 +25,7 @@ let ghc-exactprint = hself.callCabal2nix "ghc-exactprint" inputs.ghc-exactprint-150 { }; - # Hlint is still broken - hlint = doJailbreak (hself.callCabal2nix "hlint" inputs.hlint { }); + hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-341 {}) "-fghc-lib"; stylish-haskell = appendConfigureFlag hsuper.stylish-haskell "-fghc-lib"; @@ -38,7 +36,7 @@ let # retrie = hself.retrieHEAD; - apply-refact = hself.apply-refactHEAD; + fourmolu = hself.fourmolu_0_8_2_0; }); in { diff --git a/configuration-ghc-94.nix b/configuration-ghc-94.nix index c813c43886..4f3fa20dc2 100644 --- a/configuration-ghc-94.nix +++ b/configuration-ghc-94.nix @@ -25,7 +25,6 @@ let ghc-exactprint = hself.callCabal2nix "ghc-exactprint" inputs.ghc-exactprint-160 { }; - # Hlint is still broken hlint = hsuper.callCabal2nix "hlint" inputs.hlint-35 {}; stylish-haskell = appendConfigureFlag hsuper.stylish-haskell "-fghc-lib"; @@ -51,6 +50,7 @@ let # retrie = hself.retrieHEAD; apply-refact = hself.apply-refactHEAD; + fourmolu = hself.fourmoluHEAD; }); in { diff --git a/flake.lock b/flake.lock index f36af93fd4..552331f2f7 100644 --- a/flake.lock +++ b/flake.lock @@ -213,16 +213,16 @@ "url": "https://hackage.haskell.org/package/hlint-3.3.6/hlint-3.3.6.tar.gz" } }, - "hlint-34": { + "hlint-341": { "flake": false, "locked": { - "narHash": "sha256-mDncRtVkjWnUbZc1fgDMGcGjy8CFNxUF8z2HGuuN7GU=", + "narHash": "sha256-qJF5mDe4N5MG7C1x62Aumo2b49tIUvQE3wQe8nBUx4U=", "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.4/hlint-3.4.tar.gz" + "url": "https://hackage.haskell.org/package/hlint-3.4.1/hlint-3.4.1.tar.gz" }, "original": { "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.4/hlint-3.4.tar.gz" + "url": "https://hackage.haskell.org/package/hlint-3.4.1/hlint-3.4.1.tar.gz" } }, "hw-prim": { @@ -374,6 +374,7 @@ "hlint": "hlint", "hlint-34": "hlint-34", "hw-prim": "hw-prim", + "hlint-341": "hlint-341", "hlint-35": "hlint-35", "implicit-hie-cradle": "implicit-hie-cradle", "lsp": "lsp", diff --git a/flake.nix b/flake.nix index b8e67a0ef0..2db44b043d 100644 --- a/flake.nix +++ b/flake.nix @@ -79,8 +79,8 @@ url = "https://hackage.haskell.org/package/hlint-3.3.6/hlint-3.3.6.tar.gz"; flake = false; }; - hlint-34 = { - url = "https://hackage.haskell.org/package/hlint-3.4/hlint-3.4.tar.gz"; + hlint-341 = { + url = "https://hackage.haskell.org/package/hlint-3.4.1/hlint-3.4.1.tar.gz"; flake = false; }; hlint-35 = { @@ -205,7 +205,7 @@ else hsuper.ormolu; # Fourmolu needs a handful of patches to build on GHC 9.4. - fourmolu = + fourmoluHEAD = appendPatches (doJailbreak (if final.system == "aarch64-darwin" then overrideCabal hsuper.fourmolu_0_8_2_0 (_: { enableSeparateBinOutput = false; }) From 79a92729f1890f3bf92dc914b6f2211c5e32e4ab Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 15:44:57 -0800 Subject: [PATCH 29/78] fix mistakenly overriden nix exp. --- configuration-ghc-90.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/configuration-ghc-90.nix b/configuration-ghc-90.nix index 25bb53f95e..04fa809d68 100644 --- a/configuration-ghc-90.nix +++ b/configuration-ghc-90.nix @@ -25,8 +25,7 @@ let Cabal = hself.Cabal_3_6_3_0; ormolu = hself.ormolu_0_5_0_1; fourmolu = hself.fourmolu_0_8_2_0; - # Hlint is still broken - hlint = doJailbreak (hself.callCabal2nix "hlint" inputs.hlint-34 { }); + hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-341 {}) "-fghc-lib"; hls-hlint-plugin = hself.callCabal2nixWithOptions "hls-hlint-plugin" ./plugins/hls-hlint-plugin @@ -39,7 +38,6 @@ let { }; retrie = hself.retrie_1_1_0_0; - fourmolu = hself.fourmolu_0_8_2_0; }); in { From 2ab0974ed22d40bdc5117a96585cd73b6edb0916 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 8 Nov 2022 15:46:29 -0800 Subject: [PATCH 30/78] remove unused hlint-3.3.6 --- flake.lock | 12 ------------ flake.nix | 4 ---- 2 files changed, 16 deletions(-) diff --git a/flake.lock b/flake.lock index 552331f2f7..e7257af26a 100644 --- a/flake.lock +++ b/flake.lock @@ -201,18 +201,6 @@ "url": "https://hackage.haskell.org/package/hiedb-0.4.2.0/hiedb-0.4.2.0.tar.gz" } }, - "hlint": { - "flake": false, - "locked": { - "narHash": "sha256-Kz6adx97kY7ojoDlw3y0R6LQ0h/EtXGR5+N07/b6uGk=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.3.6/hlint-3.3.6.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.3.6/hlint-3.3.6.tar.gz" - } - }, "hlint-341": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 2db44b043d..9eab0f753f 100644 --- a/flake.nix +++ b/flake.nix @@ -75,10 +75,6 @@ url = "https://hackage.haskell.org/package/brittany-0.13.1.2/brittany-0.13.1.2.tar.gz"; flake = false; }; - hlint = { - url = "https://hackage.haskell.org/package/hlint-3.3.6/hlint-3.3.6.tar.gz"; - flake = false; - }; hlint-341 = { url = "https://hackage.haskell.org/package/hlint-3.4.1/hlint-3.4.1.tar.gz"; flake = false; From 8a0c4f3fbf5c86a50e6673b4af23111edc0ca412 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Wed, 9 Nov 2022 12:13:45 -0500 Subject: [PATCH 31/78] Fix CPP in hls-refactor-plugin --- .../src/Development/IDE/Plugin/CodeAction/Args.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs index 018e28c667..23aadc9c73 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs @@ -13,6 +13,8 @@ module Development.IDE.Plugin.CodeAction.Args where import Control.Concurrent.STM.Stats (readTVarIO) +import Control.Monad.Except (ExceptT (..), + runExceptT) import Control.Monad.Reader import Control.Monad.Trans.Maybe import Data.Either (fromRight, @@ -29,9 +31,6 @@ import Development.IDE.GHC.Compat.ExactPrint import Development.IDE.GHC.ExactPrint import Development.IDE.Plugin.CodeAction.ExactPrint (Rewrite, rewriteToEdit) -#endif -import Control.Monad.Except (ExceptT (..), - runExceptT) import Development.IDE.Plugin.TypeLenses (GetGlobalBindingTypeSigs (GetGlobalBindingTypeSigs), GlobalBindingTypeSigsResult) import Development.IDE.Spans.LocalBindings (Bindings) From 5b569e2312f7fc5fe87b96e177f0920b054df46a Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Wed, 9 Nov 2022 12:29:01 -0500 Subject: [PATCH 32/78] Fix build error in hls-refactor-plugin --- .../src/Development/IDE/Plugin/CodeAction/Args.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs index 23aadc9c73..4338e07a77 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs @@ -228,10 +228,10 @@ instance ToCodeAction r => ToCodeAction (ParsedSource -> r) where Just s -> flip runReaderT caa . runExceptT . toCodeAction . f . astA $ s _ -> pure $ Right [] #else - toCodeAction f = ReaderT $ \caa@CodeActionArgs {caaParsedModule = x} -> + toCodeAction f = ExceptT . ReaderT $ \caa@CodeActionArgs {caaParsedModule = x} -> x >>= \case - Just s -> flip runReaderT caa . toCodeAction . f . pm_parsed_source $ s - _ -> pure [] + Just s -> flip runReaderT caa . runExceptT . toCodeAction . f . pm_parsed_source $ s + _ -> pure $ Right [] #endif instance ToCodeAction r => ToCodeAction (ExportsMap -> r) where From 747e02c1a27573f55dbd4b66a0c6f5b993b344c3 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Wed, 9 Nov 2022 12:35:18 -0500 Subject: [PATCH 33/78] Fix import --- .../hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index 309f4daed4..893b2833cc 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -94,6 +94,7 @@ import Text.Regex.TDFA (mrAfter, (=~), (=~~)) #if MIN_VERSION_ghc(9,2,1) import Data.Either.Extra (maybeToEither) +import Development.IDE.GHC.Error (spanContainsRange) import GHC.Types.SrcLoc (generatedSrcSpan) import Language.Haskell.GHC.ExactPrint (noAnnSrcSpanDP1, runTransformT) From c943767af10c68b85981e2e3e94cb8661fffc461 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Wed, 9 Nov 2022 13:14:08 -0500 Subject: [PATCH 34/78] Use `showErrors` instead of `showBag` --- plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs b/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs index 5f67865d25..c50292571a 100644 --- a/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs +++ b/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs @@ -385,7 +385,7 @@ manualCalcEdit clientCapabilities reportEditor ran ps hscEnv typechkd srcSpan _e MtWarning [ "Warning during expanding: " , "" - , T.pack (showBag warns) + , T.pack (showErrors warns) ] pure resl where From 5f492d013d68b83d21b4c77907305dad28415d6a Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Wed, 9 Nov 2022 12:03:59 -0800 Subject: [PATCH 35/78] fix initialization test error in refactor plugin. --- plugins/hls-refactor-plugin/test/Main.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/hls-refactor-plugin/test/Main.hs b/plugins/hls-refactor-plugin/test/Main.hs index 46fb1fb616..01c4e2fc58 100644 --- a/plugins/hls-refactor-plugin/test/Main.hs +++ b/plugins/hls-refactor-plugin/test/Main.hs @@ -101,7 +101,8 @@ initializeTests = withResource acquire release tests doTest = do ir <- getInitializeResponse let Just ExecuteCommandOptions {_commands = List commands} = getActual $ innerCaps ir - zipWithM_ (\e o -> T.isSuffixOf e o @? show (e,o)) expected commands + -- Check if expected exists in commands. Note that commands can arrive in different order. + mapM_ (\e -> any (\o -> T.isSuffixOf e o) commands @? show (expected, show commands)) expected acquire :: IO (ResponseMessage Initialize) acquire = run initializeResponse From e2e3a012417763bcd64d63770eabb581c9ae1588 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Wed, 9 Nov 2022 16:58:34 -0500 Subject: [PATCH 36/78] alternateNumberFormat and explicitFixity don't build on GHC 9.4 --- haskell-language-server.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index e8dc0baa54..fab50f69fd 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -286,7 +286,7 @@ common splice cpp-options: -Dhls_splice common alternateNumberFormat - if flag(alternateNumberFormat) + if flag(alternateNumberFormat) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) build-depends: hls-alternate-number-format-plugin ^>= 1.2 cpp-options: -Dhls_alternateNumberFormat @@ -311,7 +311,7 @@ common gadt cpp-options: -Dhls_gadt common explicitFixity - if flag(explicitFixity) + if flag(explicitFixity) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) build-depends: hls-explicit-fixity-plugin ^>= 1.0 cpp-options: -DexplicitFixity From 5c05d35816dd49eb20560f019a3da4de98c695f5 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Wed, 9 Nov 2022 16:40:45 -0800 Subject: [PATCH 37/78] force demoteIfDefer = id in typecheckModule for GHC 9.4. --- ghcide/src/Development/IDE/Core/Compile.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ghcide/src/Development/IDE/Core/Compile.hs b/ghcide/src/Development/IDE/Core/Compile.hs index 68e7b29000..5d5a4b40d9 100644 --- a/ghcide/src/Development/IDE/Core/Compile.hs +++ b/ghcide/src/Development/IDE/Core/Compile.hs @@ -192,7 +192,15 @@ typecheckModule (IdeDefer defer) hsc tc_helpers pm = do Left errs -> return (map snd diags ++ errs, Nothing) Right tcm -> return (map snd diags, Just $ tcm{tmrDeferredError = deferredError}) where +#if MIN_VERSION_ghc(9,4,0) + -- Unfortunately, on GHC 9.4, with DynFlags corresponding -fdefer-type-errors, + -- the error messages are significantly different from the ones without that, and + -- thus the code action triggers (such as in hls-refactor-plugin) are not fired properly. + -- So we disable the error demotion. + demoteIfDefer = id +#else demoteIfDefer = if defer then demoteTypeErrorsToWarnings else id +#endif -- | Install hooks to capture the splices as well as the runtime module dependencies captureSplicesAndDeps :: TypecheckHelpers -> HscEnv -> (HscEnv -> IO a) -> IO (a, Splices, ModuleEnv BS.ByteString) From 9ca95ed0016279fa9c4ad1d74e2805583d3ab8a3 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Wed, 9 Nov 2022 18:09:08 -0800 Subject: [PATCH 38/78] ignore tests which were already ignored with GHC 9.2 --- plugins/hls-refactor-plugin/test/Main.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/hls-refactor-plugin/test/Main.hs b/plugins/hls-refactor-plugin/test/Main.hs index 01c4e2fc58..412955eef3 100644 --- a/plugins/hls-refactor-plugin/test/Main.hs +++ b/plugins/hls-refactor-plugin/test/Main.hs @@ -1460,7 +1460,7 @@ extendImportTests = testGroup "extend import actions" , "import A (pattern Some)" , "k (Some x) = x" ]) - , ignoreForGHC92 "Diagnostic message has no suggestions" $ + , ignoreFor (BrokenForGHC [GHC92, GHC94]) "Diagnostic message has no suggestions" $ testSession "type constructor name same as data constructor name" $ template [("ModuleA.hs", T.unlines [ "module ModuleA where" @@ -3351,7 +3351,7 @@ exportUnusedTests = testGroup "export unused actions" (R 2 0 2 11) "Export ‘bar’" Nothing - , ignoreForGHC92 "Diagnostic message has no suggestions" $ + , ignoreFor (BrokenForGHC [GHC92, GHC94]) "Diagnostic message has no suggestions" $ testSession "type is exported but not the constructor of same name" $ template (T.unlines [ "{-# OPTIONS_GHC -Wunused-top-binds #-}" @@ -3986,6 +3986,9 @@ withTempDir f = System.IO.Extra.withTempDir $ \dir -> do ignoreForGHC92 :: String -> TestTree -> TestTree ignoreForGHC92 = ignoreFor (BrokenForGHC [GHC92]) +ignoreForGHC94 :: String -> TestTree -> TestTree +ignoreForGHC94 = ignoreFor (BrokenForGHC [GHC94]) + data BrokenTarget = BrokenSpecific OS [GhcVersion] -- ^Broken for `BrokenOS` with `GhcVersion` From 5f2e77d0ec11851f891fee51c73e3b65e9a74d07 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Wed, 9 Nov 2022 21:13:47 -0800 Subject: [PATCH 39/78] fix extractDoesNotExportModuleName for GHC 9.4 by adjusting regex match --- .../src/Development/IDE/Plugin/CodeAction.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index 893b2833cc..0d5b993e39 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -1970,8 +1970,13 @@ extractQualifiedModuleName x extractDoesNotExportModuleName :: T.Text -> Maybe T.Text extractDoesNotExportModuleName x | Just [m] <- +#if MIN_VERSION_ghc(9,4,0) + matchRegexUnifySpaces x "the module ‘([^’]*)’ does not export" + <|> matchRegexUnifySpaces x "nor ‘([^’]*)’ export" +#else matchRegexUnifySpaces x "Module ‘([^’]*)’ does not export" <|> matchRegexUnifySpaces x "nor ‘([^’]*)’ exports" +#endif = Just m | otherwise = Nothing From a3647c06b7d0cee86de7e32b8d170b67b190bf26 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Wed, 9 Nov 2022 21:37:29 -0800 Subject: [PATCH 40/78] use makeDeltaAst in removeRedundantConstraints --- .../src/Development/IDE/Plugin/CodeAction.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index 0d5b993e39..79a7a04e5a 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -1554,7 +1554,7 @@ suggestFunctionConstraint df (L _ HsModule {hsmodDecls}) Diagnostic {..} missing -- | Suggests the removal of a redundant constraint for a type signature. removeRedundantConstraints :: DynFlags -> ParsedSource -> Diagnostic -> [(T.Text, Rewrite)] -removeRedundantConstraints df (L _ HsModule {hsmodDecls}) Diagnostic{..} +removeRedundantConstraints df (makeDeltaAst -> L _ HsModule {hsmodDecls}) Diagnostic{..} -- • Redundant constraint: Eq a -- • In the type signature for: -- foo :: forall a. Eq a => a -> a From b38226caecf2b48dfe95dc6d0bbe1bc3e4d7b01b Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Wed, 9 Nov 2022 23:10:07 -0800 Subject: [PATCH 41/78] fix addTypeAnnotationsToLiteralsTest --- .../src/Development/IDE/Plugin/CodeAction.hs | 14 ++++++- plugins/hls-refactor-plugin/test/Main.hs | 37 ++++++++++++++++--- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index 79a7a04e5a..6b8d76c4d4 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -840,6 +840,18 @@ suggestAddTypeAnnotationToSatisfyConstraints sourceOpt Diagnostic{_range=_range, | otherwise = [] where makeAnnotatedLit ty lit = "(" <> lit <> " :: " <> ty <> ")" +#if MIN_VERSION_ghc(9,4,0) + pat multiple at inArg inExpr = T.concat [ ".*Defaulting the type variable " + , ".*to type ‘([^ ]+)’ " + , "in the following constraint" + , if multiple then "s" else "" + , ".*arising from the literal ‘(.+)’" + , if inArg then ".+In the.+argument" else "" + , if at then ".+at" else "" + , if inExpr then ".+In the expression" else "" + , ".+In the expression" + ] +#else pat multiple at inArg inExpr = T.concat [ ".*Defaulting the following constraint" , if multiple then "s" else "" , " to type ‘([^ ]+)’ " @@ -849,12 +861,12 @@ suggestAddTypeAnnotationToSatisfyConstraints sourceOpt Diagnostic{_range=_range, , if inExpr then ".+In the expression" else "" , ".+In the expression" ] +#endif codeEdit ty lit replacement = let title = "Add type annotation ‘" <> ty <> "’ to ‘" <> lit <> "’" edits = [TextEdit _range replacement] in [( title, edits )] - -- | GHC strips out backticks in case of infix functions as well as single quote -- in case of quoted name when using TemplateHaskellQuotes. Which is not desired. -- diff --git a/plugins/hls-refactor-plugin/test/Main.hs b/plugins/hls-refactor-plugin/test/Main.hs index 412955eef3..85ba6b6ef1 100644 --- a/plugins/hls-refactor-plugin/test/Main.hs +++ b/plugins/hls-refactor-plugin/test/Main.hs @@ -2558,7 +2558,11 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t , "" , "f = 1" ]) +#if MIN_VERSION_ghc(9,4,0) + [ (DsWarning, (3, 4), "Defaulting the type variable") ] +#else [ (DsWarning, (3, 4), "Defaulting the following constraint") ] +#endif "Add type annotation ‘Integer’ to ‘1’" (T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}" , "module A (f) where" @@ -2575,7 +2579,11 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t , " let x = 3" , " in x" ]) +#if MIN_VERSION_ghc(9,4,0) + [ (DsWarning, (4, 12), "Defaulting the type variable") ] +#else [ (DsWarning, (4, 12), "Defaulting the following constraint") ] +#endif "Add type annotation ‘Integer’ to ‘3’" (T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}" , "module A where" @@ -2593,7 +2601,11 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t , " let x = let y = 5 in y" , " in x" ]) +#if MIN_VERSION_ghc(9,4,0) + [ (DsWarning, (4, 20), "Defaulting the type variable") ] +#else [ (DsWarning, (4, 20), "Defaulting the following constraint") ] +#endif "Add type annotation ‘Integer’ to ‘5’" (T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}" , "module A where" @@ -2612,9 +2624,15 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t , "" , "f = seq \"debug\" traceShow \"debug\"" ]) +#if MIN_VERSION_ghc(9,4,0) + [ (DsWarning, (6, 8), "Defaulting the type variable") + , (DsWarning, (6, 16), "Defaulting the type variable") + ] +#else [ (DsWarning, (6, 8), "Defaulting the following constraint") , (DsWarning, (6, 16), "Defaulting the following constraint") ] +#endif ("Add type annotation ‘" <> listOfChar <> "’ to ‘\"debug\"’") (T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}" , "{-# LANGUAGE OverloadedStrings #-}" @@ -2624,7 +2642,7 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t , "" , "f = seq (\"debug\" :: " <> listOfChar <> ") traceShow \"debug\"" ]) - , knownBrokenForGhcVersions [GHC92] "GHC 9.2 only has 'traceShow' in error span" $ + , knownBrokenForGhcVersions [GHC92, GHC94] "GHC 9.2 only has 'traceShow' in error span" $ testSession "add default type to satisfy two constraints" $ testFor (T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}" @@ -2635,7 +2653,11 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t , "" , "f a = traceShow \"debug\" a" ]) +#if MIN_VERSION_ghc(9,4,0) + [ (DsWarning, (6, 6), "Defaulting the type variable") ] +#else [ (DsWarning, (6, 6), "Defaulting the following constraint") ] +#endif ("Add type annotation ‘" <> listOfChar <> "’ to ‘\"debug\"’") (T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}" , "{-# LANGUAGE OverloadedStrings #-}" @@ -2645,7 +2667,7 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t , "" , "f a = traceShow (\"debug\" :: " <> listOfChar <> ") a" ]) - , knownBrokenForGhcVersions [GHC92] "GHC 9.2 only has 'traceShow' in error span" $ + , knownBrokenForGhcVersions [GHC92, GHC94] "GHC 9.2 only has 'traceShow' in error span" $ testSession "add default type to satisfy two constraints with duplicate literals" $ testFor (T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}" @@ -2656,7 +2678,11 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t , "" , "f = seq (\"debug\" :: [Char]) (seq (\"debug\" :: [Char]) (traceShow \"debug\"))" ]) +#if MIN_VERSION_ghc(9,4,0) + [ (DsWarning, (6, 54), "Defaulting the type variable") ] +#else [ (DsWarning, (6, 54), "Defaulting the following constraint") ] +#endif ("Add type annotation ‘" <> listOfChar <> "’ to ‘\"debug\"’") (T.unlines [ "{-# OPTIONS_GHC -Wtype-defaults #-}" , "{-# LANGUAGE OverloadedStrings #-}" @@ -3273,15 +3299,15 @@ removeRedundantConstraintsTests = let "Remove redundant constraints `(Monoid a, Show a)` from the context of the type signature for `foo`" (typeSignatureSpaces $ Just "Monoid a, Show a") (typeSignatureSpaces Nothing) - , check + , check "Remove redundant constraint `Eq a` from the context of the type signature for `foo`" typeSignatureLined1 typeSignatureOneLine - , check + , check "Remove redundant constraints `(Eq a, Show a)` from the context of the type signature for `foo`" typeSignatureLined2 typeSignatureOneLine - , check + , check "Remove redundant constraint `Show a` from the context of the type signature for `foo`" typeSignatureLined3 typeSignatureLined3' @@ -4034,4 +4060,3 @@ assertJust s = \case listOfChar :: T.Text listOfChar | ghcVersion >= GHC90 = "String" | otherwise = "[Char]" - From 765fb9c571f9c95f732d575c655e4cfc856f6496 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 10 Nov 2022 09:58:16 -0500 Subject: [PATCH 42/78] Revert "alternateNumberFormat and explicitFixity don't build on GHC 9.4" This reverts commit 4903092780031fb400b28f1e9ce696f1057855d8. --- haskell-language-server.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index fab50f69fd..e8dc0baa54 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -286,7 +286,7 @@ common splice cpp-options: -Dhls_splice common alternateNumberFormat - if flag(alternateNumberFormat) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(alternateNumberFormat) build-depends: hls-alternate-number-format-plugin ^>= 1.2 cpp-options: -Dhls_alternateNumberFormat @@ -311,7 +311,7 @@ common gadt cpp-options: -Dhls_gadt common explicitFixity - if flag(explicitFixity) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(explicitFixity) build-depends: hls-explicit-fixity-plugin ^>= 1.0 cpp-options: -DexplicitFixity From 77a097e3998c272824e54c116a4b69ce903e6446 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Mon, 14 Nov 2022 10:50:39 -0500 Subject: [PATCH 43/78] Update flake lockfile --- flake.lock | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/flake.lock b/flake.lock index e7257af26a..cebb999151 100644 --- a/flake.lock +++ b/flake.lock @@ -15,11 +15,11 @@ "all-cabal-hashes-unpacked": { "flake": false, "locked": { - "lastModified": 1663164766, - "narHash": "sha256-7ypfdEzJwfaQMQx9HV8B+r9BV7bN6iIO0lWhDy+8+0k=", + "lastModified": 1668108032, + "narHash": "sha256-z0L4I5ADn786XmVrKqmQ6qRY1RyTQWgLyZXFVinq4LA=", "owner": "commercialhaskell", "repo": "all-cabal-hashes", - "rev": "ed701f5e64ece3e57efa4227243f9fb64f935253", + "rev": "670aa678eef4c0d19ea370137cf9a51da039d706", "type": "github" }, "original": { @@ -100,11 +100,11 @@ }, "flake-utils": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -213,28 +213,28 @@ "url": "https://hackage.haskell.org/package/hlint-3.4.1/hlint-3.4.1.tar.gz" } }, - "hw-prim": { + "hlint-35": { "flake": false, "locked": { - "narHash": "sha256-++rg/bx4TjWUDyHSWKm/8ITwQLonPRLXHPLlnhJy8ik=", + "narHash": "sha256-qQNUlQQnahUGEO92Lm0RwjTGBGr2Yaw0KRuFRMoc5No=", "type": "tarball", - "url": "https://hackage.haskell.org/package/hw-prim-0.6.3.2/hw-prim-0.6.3.2.tar.gz" + "url": "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz" }, "original": { "type": "tarball", - "url": "https://hackage.haskell.org/package/hw-prim-0.6.3.2/hw-prim-0.6.3.2.tar.gz" + "url": "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz" } }, - "hlint-35": { + "hw-prim": { "flake": false, "locked": { - "narHash": "sha256-qQNUlQQnahUGEO92Lm0RwjTGBGr2Yaw0KRuFRMoc5No=", + "narHash": "sha256-++rg/bx4TjWUDyHSWKm/8ITwQLonPRLXHPLlnhJy8ik=", "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz" + "url": "https://hackage.haskell.org/package/hw-prim-0.6.3.2/hw-prim-0.6.3.2.tar.gz" }, "original": { "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz" + "url": "https://hackage.haskell.org/package/hw-prim-0.6.3.2/hw-prim-0.6.3.2.tar.gz" } }, "implicit-hie-cradle": { @@ -287,11 +287,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1667292599, - "narHash": "sha256-7ISOUI1aj6UKMPIL+wwthENL22L3+A9V+jS8Is3QsRo=", + "lastModified": 1668058645, + "narHash": "sha256-vHAXeYfKVO6ZbDN0GquEPVFZ42LzlYoX4ZWuKteFzj0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ef2f213d9659a274985778bff4ca322f3ef3ac68", + "rev": "d01cb18be494e3d860fcfe6be4ad63614360333c", "type": "github" }, "original": { @@ -316,11 +316,11 @@ "retrie": { "flake": false, "locked": { - "lastModified": 1667519855, - "narHash": "sha256-6xr3fsqy28VGQo+by3sKIB5F5lSAg2HwJMzfiQ0uuNw=", + "lastModified": 1668115819, + "narHash": "sha256-oMAdLkJTnX4NNxCPROxjQt+S3++dzfnu7kjIHmGyMDQ=", "owner": "MercuryTechnologies", "repo": "retrie", - "rev": "415e5e6c01acac6ef77255834edc90fe80f37396", + "rev": "12223a54fe01e9d49f94e86125fb82d689cc562c", "type": "github" }, "original": { @@ -359,11 +359,9 @@ "gitignore": "gitignore", "hie-bios": "hie-bios", "hiedb": "hiedb", - "hlint": "hlint", - "hlint-34": "hlint-34", - "hw-prim": "hw-prim", "hlint-341": "hlint-341", "hlint-35": "hlint-35", + "hw-prim": "hw-prim", "implicit-hie-cradle": "implicit-hie-cradle", "lsp": "lsp", "lsp-test": "lsp-test", From c0b4951e1f36fec6316945e299b52d44afc862d6 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Mon, 14 Nov 2022 10:54:15 -0500 Subject: [PATCH 44/78] Use upstream `retrie` --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 9eab0f753f..169738eee5 100644 --- a/flake.nix +++ b/flake.nix @@ -64,7 +64,7 @@ flake = false; }; retrie = { - url = "github:MercuryTechnologies/retrie/mercury/ghc94"; + url = "https://hackage.haskell.org/package/retrie-1.2.1/retrie-1.2.1.tar.gz"; flake = false; }; aeson-1520= { From 87f04c021924fffa1d650fab312f3dc4f0dc1f37 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Mon, 14 Nov 2022 10:57:29 -0500 Subject: [PATCH 45/78] Use upstream `retrie` --- configuration-ghc-92.nix | 2 -- configuration-ghc-94.nix | 2 -- flake.nix | 3 ++- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/configuration-ghc-92.nix b/configuration-ghc-92.nix index 03ff303a96..743942d3b5 100644 --- a/configuration-ghc-92.nix +++ b/configuration-ghc-92.nix @@ -34,8 +34,6 @@ let hself.callCabal2nixWithOptions "haskell-language-server" ./. (pkgs.lib.concatStringsSep " " [ "-fpedantic" "-f-hlint" ]) { }; - # - retrie = hself.retrieHEAD; fourmolu = hself.fourmolu_0_8_2_0; }); diff --git a/configuration-ghc-94.nix b/configuration-ghc-94.nix index 4f3fa20dc2..76c4eb9429 100644 --- a/configuration-ghc-94.nix +++ b/configuration-ghc-94.nix @@ -47,8 +47,6 @@ let hself.callCabal2nixWithOptions "haskell-language-server" ./. (pkgs.lib.concatStringsSep " " [ "-fpedantic" "-f-hlint" ]) { }; - # - retrie = hself.retrieHEAD; apply-refact = hself.apply-refactHEAD; fourmolu = hself.fourmoluHEAD; diff --git a/flake.nix b/flake.nix index 169738eee5..4460867b86 100644 --- a/flake.nix +++ b/flake.nix @@ -188,7 +188,6 @@ hiedb = hsuper.callCabal2nix "hiedb" inputs.hiedb {}; hw-prim = hsuper.callCabal2nix "hw-prim" inputs.hw-prim {}; retrie = hsuper.callCabal2nix "retrie" inputs.retrie {}; - retrieHEAD = hsuper.callCabal2nix "retrie" inputs.retrie {}; retrie_1_1_0_0 = hsuper.callCabal2nix "retrie" inputs.retrie_1100 {}; apply-refactHEAD = hsuper.callCabal2nix "apply-refact" inputs.apply-refact {}; @@ -355,6 +354,8 @@ gmp zlib ncurses # Changelog tooling (gen-hls-changelogs pkgs.haskellPackages) + # For the documentation + pythonWithPackages # @guibou: I'm not sure this is needed. hlint pkgs.haskellPackages.opentelemetry-extra From b7eac4da58e12efdff1818e3d4605ce9c78cc4a3 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Mon, 14 Nov 2022 12:24:28 -0500 Subject: [PATCH 46/78] Update lockfile --- flake.lock | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/flake.lock b/flake.lock index cebb999151..ec3f90d8a6 100644 --- a/flake.lock +++ b/flake.lock @@ -15,11 +15,11 @@ "all-cabal-hashes-unpacked": { "flake": false, "locked": { - "lastModified": 1668108032, - "narHash": "sha256-z0L4I5ADn786XmVrKqmQ6qRY1RyTQWgLyZXFVinq4LA=", + "lastModified": 1668441869, + "narHash": "sha256-6dTPbQBy9XZDQi6tDW8w09hArHp/ZA5s1DkSaJNYwSU=", "owner": "commercialhaskell", "repo": "all-cabal-hashes", - "rev": "670aa678eef4c0d19ea370137cf9a51da039d706", + "rev": "3f9094b2ab1f351a7036b0bbf39236a74fc77b6e", "type": "github" }, "original": { @@ -287,11 +287,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1668058645, - "narHash": "sha256-vHAXeYfKVO6ZbDN0GquEPVFZ42LzlYoX4ZWuKteFzj0=", + "lastModified": 1668415355, + "narHash": "sha256-F52qWYvLFJV1jibZiuNzeca8+UgZ7NZrr44J2ednmpE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d01cb18be494e3d860fcfe6be4ad63614360333c", + "rev": "69f8e94c46904a3194afcc8b232402287c7f91c9", "type": "github" }, "original": { @@ -316,18 +316,13 @@ "retrie": { "flake": false, "locked": { - "lastModified": 1668115819, - "narHash": "sha256-oMAdLkJTnX4NNxCPROxjQt+S3++dzfnu7kjIHmGyMDQ=", - "owner": "MercuryTechnologies", - "repo": "retrie", - "rev": "12223a54fe01e9d49f94e86125fb82d689cc562c", - "type": "github" + "narHash": "sha256-yokMPa3T7gO3YGwaE0CwCO+vG4IVvObSo+q8fzGbAvc=", + "type": "tarball", + "url": "https://hackage.haskell.org/package/retrie-1.2.1/retrie-1.2.1.tar.gz" }, "original": { - "owner": "MercuryTechnologies", - "ref": "mercury/ghc94", - "repo": "retrie", - "type": "github" + "type": "tarball", + "url": "https://hackage.haskell.org/package/retrie-1.2.1/retrie-1.2.1.tar.gz" } }, "retrie_1100": { From a2e200bd50adba78a31e69347f7aacd719cf70cb Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Tue, 15 Nov 2022 12:42:55 -0500 Subject: [PATCH 47/78] Use upstream fourmolu --- flake.nix | 49 +++++++++++-------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/flake.nix b/flake.nix index 4460867b86..5643150e2d 100644 --- a/flake.nix +++ b/flake.nix @@ -201,44 +201,17 @@ # Fourmolu needs a handful of patches to build on GHC 9.4. fourmoluHEAD = - appendPatches - (doJailbreak (if final.system == "aarch64-darwin" - then overrideCabal hsuper.fourmolu_0_8_2_0 (_: { enableSeparateBinOutput = false; }) - else hsuper.fourmolu_0_8_2_0)) - [ - # The GHC 9.4 pull request builds upon these unpublished changes, - # which is why we include them. - # - # Also, there is no PR for these changes. The fourmolu maintainers - # apparently commit straight to master … - (final.fetchpatch { - url = "https://github.com/fourmolu/fourmolu/commit/2c11f555945e755cc6e805de482404d5484d53b6.patch"; - sha256 = "sha256-bWJxOYQoLtsW7KaVbTxIxX+cFx9x3ekEmbA9NuJ3qtk="; - }) - (final.fetchpatch { - url = "https://github.com/fourmolu/fourmolu/commit/8eb7ef82676ab3bff9b249c74fc5d81dc23a2657.patch"; - sha256 = "sha256-rlKDRv27EGnlStNiKEniZiKSib1Zr9E3hGT3QuU5xLI="; - }) - (final.fetchpatch { - url = "https://github.com/fourmolu/fourmolu/commit/14b1bc832716edaf4239c4e364836185f0aa816b.patch"; - sha256 = "sha256-cfXh6ufxASbg2wXp/5ixfUNSC54O/eq8hx88lZKAJ18="; - }) - (final.fetchpatch { - url = "https://github.com/fourmolu/fourmolu/commit/e7fc4ec52aeeb50b3a886d1f55f4468ae6d46a46.patch"; - sha256 = "sha256-d+hg/mOEAybq461VLkmCrwtFyHgX8Q+715yaJXHn7/g="; - }) - (final.fetchpatch { - url = "https://github.com/fourmolu/fourmolu/commit/809256014cb6f65d8cd3447c0502493f57d3e307.patch"; - sha256 = "sha256-FdVj9MidRCfMUERVWvFV9k2rnvnorxJE7NpehNBQ8OQ="; - }) - - # The actual change to support GHC 9.4 - (final.fetchpatch { - url = "https://github.com/fourmolu/fourmolu/pull/242.patch"; - sha256 = "sha256-mWMtG+pkiNzmkXWVZhIILhhnPzQM070o6+hwyNZkY+0="; - includes = ["data/*" "src/*" "tests/*" "fourmolu.cabal"]; - }) - ]; + doJailbreak (overrideCabal hsuper.fourmolu_0_8_2_0 (old: { + enableSeparateBinOutput = final.system != "aarch64-darwin"; + # Update to Fourmolu 0.9 for GHC 9.4 support. + src = self.fetchFromGitHub { + owner = "fourmolu"; + repo = "fourmolu"; + # Branch: `main` + rev = "47017e0f7c333676f3fd588695c1b3d16f2075cc"; + hash = "sha256-MPFWDMc9nSpTtCjAIHmjLyENkektm72tCWaKnkAQfuk="; + }; + }); }; hlsSources = From 256c55da2af1e6d1495c3b11ea527f12a788323d Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 15 Nov 2022 10:34:25 -0800 Subject: [PATCH 48/78] fix arrow annotation on ghc 9.4 --- .../src/Development/IDE/Plugin/CodeAction.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index 6b8d76c4d4..e7c97bd93a 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -65,6 +65,9 @@ import Development.IDE.Types.Logger hiding import Development.IDE.Types.Options import GHC.Exts (fromList) import qualified GHC.LanguageExtensions as Lang +#if MIN_VERSION_ghc(9,4,0) +import GHC.Parser.Annotation (TokenLocation (..)) +#endif import Ide.PluginUtils (makeDiffTextEdit, subRange) import Ide.Types @@ -1067,8 +1070,14 @@ hsTypeFromFunTypeAsList (args, res) = addTyHoleToTySigArg :: Int -> LHsSigType GhcPs -> (LHsSigType GhcPs) addTyHoleToTySigArg loc (L annHsSig (HsSig xHsSig tyVarBndrs lsigTy)) = let (args, res) = hsTypeToFunTypeAsList lsigTy +#if MIN_VERSION_ghc(9,4,0) + wildCardAnn = SrcSpanAnn (EpAnn genAnchor1 (AnnListItem []) emptyComments) generatedSrcSpan + arrowAnn = TokenLoc (epl 1) + newArg = (SrcSpanAnn mempty generatedSrcSpan, noAnn, HsUnrestrictedArrow (L arrowAnn HsNormalTok), L wildCardAnn $ HsWildCardTy noExtField) +#else wildCardAnn = SrcSpanAnn (EpAnn genAnchor1 (AnnListItem [AddRarrowAnn d1]) emptyComments) generatedSrcSpan newArg = (SrcSpanAnn mempty generatedSrcSpan, noAnn, HsUnrestrictedArrow NormalSyntax, L wildCardAnn $ HsWildCardTy noExtField) +#endif -- NOTE if the location that the argument wants to be placed at is not one more than the number of arguments -- in the signature, then we return the original type signature. -- This situation most likely occurs due to a function type synonym in the signature From 1b5e33f720bbc3bbd86315c03c399ec65d4beffa Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 15 Nov 2022 10:45:26 -0800 Subject: [PATCH 49/78] fix flake.nix issue --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 5643150e2d..8b6fb1fcd7 100644 --- a/flake.nix +++ b/flake.nix @@ -204,14 +204,14 @@ doJailbreak (overrideCabal hsuper.fourmolu_0_8_2_0 (old: { enableSeparateBinOutput = final.system != "aarch64-darwin"; # Update to Fourmolu 0.9 for GHC 9.4 support. - src = self.fetchFromGitHub { + src = prev.fetchFromGitHub { owner = "fourmolu"; repo = "fourmolu"; # Branch: `main` rev = "47017e0f7c333676f3fd588695c1b3d16f2075cc"; hash = "sha256-MPFWDMc9nSpTtCjAIHmjLyENkektm72tCWaKnkAQfuk="; }; - }); + })); }; hlsSources = From 7af62711bf6fac69f07a122287401dc1f835724e Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 15 Nov 2022 11:06:23 -0800 Subject: [PATCH 50/78] revert demoteIfDefer change for GHC 9.4. --- ghcide/src/Development/IDE/Core/Compile.hs | 8 -------- plugins/hls-refactor-plugin/test/Main.hs | 4 +++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Compile.hs b/ghcide/src/Development/IDE/Core/Compile.hs index 5d5a4b40d9..68e7b29000 100644 --- a/ghcide/src/Development/IDE/Core/Compile.hs +++ b/ghcide/src/Development/IDE/Core/Compile.hs @@ -192,15 +192,7 @@ typecheckModule (IdeDefer defer) hsc tc_helpers pm = do Left errs -> return (map snd diags ++ errs, Nothing) Right tcm -> return (map snd diags, Just $ tcm{tmrDeferredError = deferredError}) where -#if MIN_VERSION_ghc(9,4,0) - -- Unfortunately, on GHC 9.4, with DynFlags corresponding -fdefer-type-errors, - -- the error messages are significantly different from the ones without that, and - -- thus the code action triggers (such as in hls-refactor-plugin) are not fired properly. - -- So we disable the error demotion. - demoteIfDefer = id -#else demoteIfDefer = if defer then demoteTypeErrorsToWarnings else id -#endif -- | Install hooks to capture the splices as well as the runtime module dependencies captureSplicesAndDeps :: TypecheckHelpers -> HscEnv -> (HscEnv -> IO a) -> IO (a, Splices, ModuleEnv BS.ByteString) diff --git a/plugins/hls-refactor-plugin/test/Main.hs b/plugins/hls-refactor-plugin/test/Main.hs index 85ba6b6ef1..77267a1bc7 100644 --- a/plugins/hls-refactor-plugin/test/Main.hs +++ b/plugins/hls-refactor-plugin/test/Main.hs @@ -744,6 +744,7 @@ typeWildCardActionTests = testGroup "type wildcard actions" contentAfterAction <- documentContents doc liftIO $ expectedContentAfterAction @=? contentAfterAction + {-# HLINT ignore "Use nubOrd" #-} removeImportTests :: TestTree removeImportTests = testGroup "remove import actions" @@ -1289,7 +1290,8 @@ extendImportTests = testGroup "extend import actions" , "b :: A" , "b = ConstructorFoo" ]) - , testSession "extend single line qualified import with value" $ template + , ignoreForGHC94 "On GHC 9.4, the error messages with -fdefer-type-errors don't have necessary imported target srcspan info." $ + testSession "extend single line qualified import with value" $ template [("ModuleA.hs", T.unlines [ "module ModuleA where" , "stuffA :: Double" From c2c7461150b5c5b348f31422109dbdc98a8f9cf5 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Tue, 15 Nov 2022 13:17:33 -0800 Subject: [PATCH 51/78] fix hls-splice-plugin build on GHC 9.0.2 --- plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs b/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs index c50292571a..645a723807 100644 --- a/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs +++ b/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs @@ -55,7 +55,7 @@ import Development.IDE.GHC.ExactPrint import GHC.Data.Bag (Bag) #endif import GHC.Exts -#if MIN_VERSION_ghc(9,0,2) +#if MIN_VERSION_ghc(9,2,0) import GHC.Parser.Annotation (SrcSpanAnn'(..)) import qualified GHC.Types.Error as Error #endif @@ -274,7 +274,7 @@ adjustToRange uri ran (WorkspaceEdit mhult mlt x) = -- `GenLocated`. In GHC >= 9.2 this will be a SrcSpanAnn', with annotations; -- earlier it will just be a plain `SrcSpan`. {-# COMPLETE AsSrcSpan #-} -#if MIN_VERSION_ghc(9,0,2) +#if MIN_VERSION_ghc(9,2,0) pattern AsSrcSpan :: SrcSpan -> SrcSpanAnn' a pattern AsSrcSpan locA <- SrcSpanAnn {locA} #else @@ -372,7 +372,7 @@ manualCalcEdit clientCapabilities reportEditor ran ps hscEnv typechkd srcSpan _e Right y -> unRenamedE dflags y _ -> pure Nothing let (warns, errs) = -#if MIN_VERSION_ghc(9,0,2) +#if MIN_VERSION_ghc(9,2,0) (Error.getWarningMessages msgs, Error.getErrorMessages msgs) #else msgs @@ -419,7 +419,7 @@ unRenamedE :: TransformT m (LocatedAn l (ast GhcPs)) unRenamedE dflags expr = do uniq <- show <$> uniqueSrcSpanT -#if MIN_VERSION_ghc(9,0,2) +#if MIN_VERSION_ghc(9,2,0) expr' <- #else (_anns, expr') <- From 0770865315604c92d0bedc0b8edbcfcda8f54ebd Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 12 Dec 2022 10:41:09 -0800 Subject: [PATCH 52/78] disable tracy on darwin. --- flake.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 48ac7a30bb..6e31fefedc 100644 --- a/flake.nix +++ b/flake.nix @@ -299,11 +299,15 @@ # @guibou: I'm not sure this is needed. hlint pkgs.haskellPackages.opentelemetry-extra - capstone tracy + capstone # ormolu # stylish-haskell pre-commit - ] ++ lib.optionals stdenv.isDarwin + ] ++ lib.optionals (!stdenv.isDarwin) + [ # tracy has a build problem on macos. + tracy + ] + ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Cocoa CoreServices From 6730eaf8e37937d572a7ef749db41756730b203e Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 12 Dec 2022 11:02:31 -0800 Subject: [PATCH 53/78] disable fourmolu plugin and ekg-json for now. --- cabal.project | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/cabal.project b/cabal.project index 6536f26465..7c19716a44 100644 --- a/cabal.project +++ b/cabal.project @@ -13,7 +13,7 @@ packages: ./plugins/hls-tactics-plugin ./plugins/hls-brittany-plugin ./plugins/hls-stylish-haskell-plugin - ./plugins/hls-fourmolu-plugin + -- ./plugins/hls-fourmolu-plugin ./plugins/hls-class-plugin ./plugins/hls-eval-plugin ./plugins/hls-explicit-imports-plugin @@ -67,19 +67,19 @@ constraints: ghc-lib-parser-ex -auto, stylish-haskell +ghc-lib --- This is benign and won't affect our ability to release to Hackage, --- because we only depend on `ekg-json` when a non-default flag --- is turned on. --- DELETE MARKER FOR CI --- centos7 has an old version of git which cabal doesn't --- support. We delete these lines in gitlab ci to workaround --- this issue, as this is not necessary to build our binaries. -source-repository-package - type:git - location: https://github.com/pepeiborra/ekg-json - tag: 7a0af7a8fd38045fd15fb13445bdcc7085325460 - -- https://github.com/tibbe/ekg-json/pull/12 --- END DELETE +-- -- This is benign and won't affect our ability to release to Hackage, +-- -- because we only depend on `ekg-json` when a non-default flag +-- -- is turned on. +-- -- DELETE MARKER FOR CI +-- -- centos7 has an old version of git which cabal doesn't +-- -- support. We delete these lines in gitlab ci to workaround +-- -- this issue, as this is not necessary to build our binaries. +-- source-repository-package +-- type:git +-- location: https://github.com/pepeiborra/ekg-json +-- tag: 7a0af7a8fd38045fd15fb13445bdcc7085325460 +-- -- https://github.com/tibbe/ekg-json/pull/12 +-- -- END DELETE allow-newer: -- ghc-9.4 From 0ce9e6de2c1f81045bb1e157ff50ead327214604 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 12 Dec 2022 11:54:03 -0800 Subject: [PATCH 54/78] fourmolu update to 0.10.1.0 --- cabal.project | 28 +++++++++---------- configuration-ghc-90.nix | 1 - configuration-ghc-92.nix | 2 -- configuration-ghc-94.nix | 1 - flake.lock | 6 ++-- flake.nix | 21 ++++---------- .../hls-cabal-plugin/hls-cabal-plugin.cabal | 2 +- .../hls-fourmolu-plugin.cabal | 2 +- 8 files changed, 25 insertions(+), 38 deletions(-) diff --git a/cabal.project b/cabal.project index 7c19716a44..6536f26465 100644 --- a/cabal.project +++ b/cabal.project @@ -13,7 +13,7 @@ packages: ./plugins/hls-tactics-plugin ./plugins/hls-brittany-plugin ./plugins/hls-stylish-haskell-plugin - -- ./plugins/hls-fourmolu-plugin + ./plugins/hls-fourmolu-plugin ./plugins/hls-class-plugin ./plugins/hls-eval-plugin ./plugins/hls-explicit-imports-plugin @@ -67,19 +67,19 @@ constraints: ghc-lib-parser-ex -auto, stylish-haskell +ghc-lib --- -- This is benign and won't affect our ability to release to Hackage, --- -- because we only depend on `ekg-json` when a non-default flag --- -- is turned on. --- -- DELETE MARKER FOR CI --- -- centos7 has an old version of git which cabal doesn't --- -- support. We delete these lines in gitlab ci to workaround --- -- this issue, as this is not necessary to build our binaries. --- source-repository-package --- type:git --- location: https://github.com/pepeiborra/ekg-json --- tag: 7a0af7a8fd38045fd15fb13445bdcc7085325460 --- -- https://github.com/tibbe/ekg-json/pull/12 --- -- END DELETE +-- This is benign and won't affect our ability to release to Hackage, +-- because we only depend on `ekg-json` when a non-default flag +-- is turned on. +-- DELETE MARKER FOR CI +-- centos7 has an old version of git which cabal doesn't +-- support. We delete these lines in gitlab ci to workaround +-- this issue, as this is not necessary to build our binaries. +source-repository-package + type:git + location: https://github.com/pepeiborra/ekg-json + tag: 7a0af7a8fd38045fd15fb13445bdcc7085325460 + -- https://github.com/tibbe/ekg-json/pull/12 +-- END DELETE allow-newer: -- ghc-9.4 diff --git a/configuration-ghc-90.nix b/configuration-ghc-90.nix index dcafd6820a..3a846b7066 100644 --- a/configuration-ghc-90.nix +++ b/configuration-ghc-90.nix @@ -24,7 +24,6 @@ let Cabal = hself.Cabal_3_6_3_0; ormolu = hself.ormolu_0_5_0_1; - fourmolu = hself.fourmolu_0_8_2_0; hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-341 {}) "-fghc-lib"; hls-hlint-plugin = hself.callCabal2nixWithOptions "hls-hlint-plugin" diff --git a/configuration-ghc-92.nix b/configuration-ghc-92.nix index 743942d3b5..fa48d4e046 100644 --- a/configuration-ghc-92.nix +++ b/configuration-ghc-92.nix @@ -34,8 +34,6 @@ let hself.callCabal2nixWithOptions "haskell-language-server" ./. (pkgs.lib.concatStringsSep " " [ "-fpedantic" "-f-hlint" ]) { }; - fourmolu = hself.fourmolu_0_8_2_0; - }); in { inherit disabledPlugins; diff --git a/configuration-ghc-94.nix b/configuration-ghc-94.nix index cb734b8a38..e123f8db63 100644 --- a/configuration-ghc-94.nix +++ b/configuration-ghc-94.nix @@ -35,7 +35,6 @@ let (pkgs.lib.concatStringsSep " " [ "-fpedantic" "-f-hlint" ]) { }; apply-refact = hself.apply-refactHEAD; - fourmolu = hself.fourmoluHEAD; }); in { diff --git a/flake.lock b/flake.lock index 100be0c868..8db4409aa9 100644 --- a/flake.lock +++ b/flake.lock @@ -104,13 +104,13 @@ "fourmolu": { "flake": false, "locked": { - "narHash": "sha256-vbqgYaAd/JUPFGv6O2+OosBXFceKah9OYrjTuEkEZ3E=", + "narHash": "sha256-nmMz6kgI9cRljNSH9lbuozKJ7nd5pM4EKfUs0+x5N4U=", "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.9.0.0/fourmolu-0.9.0.0.tar.gz" + "url": "https://hackage.haskell.org/package/fourmolu-0.10.1.0/fourmolu-0.10.1.0.tar.gz" }, "original": { "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.9.0.0/fourmolu-0.9.0.0.tar.gz" + "url": "https://hackage.haskell.org/package/fourmolu-0.10.1.0/fourmolu-0.10.1.0.tar.gz" } }, "ghc-check": { diff --git a/flake.nix b/flake.nix index 6e31fefedc..29a1bdbe56 100644 --- a/flake.nix +++ b/flake.nix @@ -64,7 +64,7 @@ flake = false; }; fourmolu = { - url = "https://hackage.haskell.org/package/fourmolu-0.9.0.0/fourmolu-0.9.0.0.tar.gz"; + url = "https://hackage.haskell.org/package/fourmolu-0.10.1.0/fourmolu-0.10.1.0.tar.gz"; flake = false; }; hlint-341 = { @@ -165,20 +165,11 @@ then overrideCabal hsuper.ormolu (_: { enableSeparateBinOutput = false; }) else hsuper.ormolu; - # Fourmolu needs a handful of patches to build on GHC 9.4. - fourmoluHEAD = - doJailbreak (overrideCabal hsuper.fourmolu_0_9_0_0 (old: { - enableSeparateBinOutput = final.system != "aarch64-darwin"; - # Update to Fourmolu 0.9 for GHC 9.4 support. - src = prev.fetchFromGitHub { - owner = "fourmolu"; - repo = "fourmolu"; - # Branch: `main` - rev = "47017e0f7c333676f3fd588695c1b3d16f2075cc"; - hash = "sha256-MPFWDMc9nSpTtCjAIHmjLyENkektm72tCWaKnkAQfuk="; - }; - })); - fourmolu = hself.callCabal2nix "fourmolu" inputs.fourmolu {}; + # with fixith-th, OOM is likely to happen in link time. + fourmolu = + addBuildDepend + (appendConfigureFlag (hself.callCabal2nix "fourmolu" inputs.fourmolu {}) "-f-fixity-th") + hself.file-embed; }; hlsSources = diff --git a/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal b/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal index f202b633c3..93c3d6117f 100644 --- a/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal +++ b/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal @@ -45,7 +45,7 @@ library -- This is a lot of work for almost zero benefit, so we just allow more versions here -- and we eventually completely drop support for building HLS with stack. , Cabal ^>=3.2 || ^>=3.4 || ^>=3.6 || ^>= 3.8 - , Cabal-syntax ^>= 3.6 + , Cabal-syntax ^>= 3.6 || ^>= 3.8 , deepseq , directory , extra >=1.7.4 diff --git a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal index c4a5f19ed0..ab7311c15d 100644 --- a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal +++ b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal @@ -31,7 +31,7 @@ library build-depends: , base >=4.12 && <5 , filepath - , fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.6 || ^>= 0.7 || ^>= 0.8 || ^>= 0.9 + , fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.6 || ^>= 0.7 || ^>= 0.8 || ^>= 0.9 || ^>= 0.10 , ghc , ghc-boot-th , ghcide ^>=1.8 From c86a07cbc2f0a327c793b38af7e3838da8cbf39c Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 12 Dec 2022 12:05:06 -0800 Subject: [PATCH 55/78] build fix for hls-refactor-plugin after merge --- .../src/Development/IDE/Plugin/Plugins/AddArgument.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/Plugins/AddArgument.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/Plugins/AddArgument.hs index d7e59c1db2..cdb4086133 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/Plugins/AddArgument.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/Plugins/AddArgument.hs @@ -1,6 +1,10 @@ {-# LANGUAGE CPP #-} module Development.IDE.Plugin.Plugins.AddArgument (plugin) where +#if MIN_VERSION_ghc(9,4,0) +import Development.IDE.GHC.ExactPrint (epl) +import GHC.Parser.Annotation (TokenLocation (..)) +#endif #if !MIN_VERSION_ghc(9,2,1) import qualified Data.Text as T import Language.LSP.Types @@ -140,8 +144,14 @@ hsTypeFromFunTypeAsList (args, res) = addTyHoleToTySigArg :: Int -> LHsSigType GhcPs -> (LHsSigType GhcPs) addTyHoleToTySigArg loc (L annHsSig (HsSig xHsSig tyVarBndrs lsigTy)) = let (args, res) = hsTypeToFunTypeAsList lsigTy +#if MIN_VERSION_ghc(9,4,0) + wildCardAnn = SrcSpanAnn (EpAnn genAnchor1 (AnnListItem []) emptyComments) generatedSrcSpan + arrowAnn = TokenLoc (epl 1) + newArg = (SrcSpanAnn mempty generatedSrcSpan, noAnn, HsUnrestrictedArrow (L arrowAnn HsNormalTok), L wildCardAnn $ HsWildCardTy noExtField) +#else wildCardAnn = SrcSpanAnn (EpAnn genAnchor1 (AnnListItem [AddRarrowAnn d1]) emptyComments) generatedSrcSpan newArg = (SrcSpanAnn mempty generatedSrcSpan, noAnn, HsUnrestrictedArrow NormalSyntax, L wildCardAnn $ HsWildCardTy noExtField) +#endif -- NOTE if the location that the argument wants to be placed at is not one more than the number of arguments -- in the signature, then we return the original type signature. -- This situation most likely occurs due to a function type synonym in the signature From 140866764a754ad04288dc2f5b748c62933f0865 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 12 Dec 2022 12:31:58 -0800 Subject: [PATCH 56/78] update index-state. --- cabal.project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index 6536f26465..28d94e7808 100644 --- a/cabal.project +++ b/cabal.project @@ -51,7 +51,7 @@ package * write-ghc-environment-files: never -index-state: 2022-10-07T12:19:15Z +index-state: 2022-12-12T19:06:16Z constraints: -- For GHC 9.4, older versions of entropy fail to build on Windows From e7b83bfe1c24aa7dfa12830d2370114a984fee70 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 12 Dec 2022 12:51:31 -0800 Subject: [PATCH 57/78] downgrade fourmolu to 0.9 for ghc 9.2 and 9.0 --- configuration-ghc-90.nix | 1 + configuration-ghc-92.nix | 2 ++ 2 files changed, 3 insertions(+) diff --git a/configuration-ghc-90.nix b/configuration-ghc-90.nix index 3a846b7066..49126f3aaf 100644 --- a/configuration-ghc-90.nix +++ b/configuration-ghc-90.nix @@ -24,6 +24,7 @@ let Cabal = hself.Cabal_3_6_3_0; ormolu = hself.ormolu_0_5_0_1; + fourmolu = hself.fourmolu_0_9_0_0; hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-341 {}) "-fghc-lib"; hls-hlint-plugin = hself.callCabal2nixWithOptions "hls-hlint-plugin" diff --git a/configuration-ghc-92.nix b/configuration-ghc-92.nix index fa48d4e046..ffa87e669b 100644 --- a/configuration-ghc-92.nix +++ b/configuration-ghc-92.nix @@ -25,10 +25,12 @@ let ghc-exactprint = hself.callCabal2nix "ghc-exactprint" inputs.ghc-exactprint-150 { }; + fourmolu = hself.fourmolu_0_9_0_0; hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-341 {}) "-fghc-lib"; stylish-haskell = appendConfigureFlag hsuper.stylish-haskell "-fghc-lib"; + # Re-generate HLS drv excluding some plugins haskell-language-server = hself.callCabal2nixWithOptions "haskell-language-server" ./. From 4a2e757fa0048fe83aaa90365980a41c6907ef07 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 12 Dec 2022 14:24:30 -0800 Subject: [PATCH 58/78] remove unnecessary problematic Cabal-syntax dependency. --- configuration-ghc-90.nix | 5 ++--- configuration-ghc-92.nix | 1 - plugins/hls-cabal-plugin/hls-cabal-plugin.cabal | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/configuration-ghc-90.nix b/configuration-ghc-90.nix index 49126f3aaf..b487830746 100644 --- a/configuration-ghc-90.nix +++ b/configuration-ghc-90.nix @@ -18,11 +18,10 @@ let # https://github.com/nikita-volkov/ptr-poker/issues/11 ptr-poker = hself.callCabal2nix "ptr-poker" inputs.ptr-poker { }; - ghc-lib = hself.ghc-lib_9_2_4_20220729; - ghc-lib-parser = hself.ghc-lib-parser_9_2_4_20220729; + ghc-lib = hself.ghc-lib_9_2_5_20221107; + ghc-lib-parser = hself.ghc-lib-parser_9_2_5_20221107; ghc-lib-parser-ex = hself.ghc-lib-parser-ex_9_2_1_1; - Cabal = hself.Cabal_3_6_3_0; ormolu = hself.ormolu_0_5_0_1; fourmolu = hself.fourmolu_0_9_0_0; hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-341 {}) "-fghc-lib"; diff --git a/configuration-ghc-92.nix b/configuration-ghc-92.nix index ffa87e669b..e21b10e6b1 100644 --- a/configuration-ghc-92.nix +++ b/configuration-ghc-92.nix @@ -30,7 +30,6 @@ let stylish-haskell = appendConfigureFlag hsuper.stylish-haskell "-fghc-lib"; - # Re-generate HLS drv excluding some plugins haskell-language-server = hself.callCabal2nixWithOptions "haskell-language-server" ./. diff --git a/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal b/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal index 93c3d6117f..67170c10ab 100644 --- a/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal +++ b/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal @@ -45,7 +45,6 @@ library -- This is a lot of work for almost zero benefit, so we just allow more versions here -- and we eventually completely drop support for building HLS with stack. , Cabal ^>=3.2 || ^>=3.4 || ^>=3.6 || ^>= 3.8 - , Cabal-syntax ^>= 3.6 || ^>= 3.8 , deepseq , directory , extra >=1.7.4 From 9e1fef15f948c93ce202909acf3fc52101ed4297 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 12 Dec 2022 14:34:35 -0800 Subject: [PATCH 59/78] update Cabal for ormolu in ghc 9.0 nix env. --- configuration-ghc-90.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/configuration-ghc-90.nix b/configuration-ghc-90.nix index b487830746..eb472a2db5 100644 --- a/configuration-ghc-90.nix +++ b/configuration-ghc-90.nix @@ -22,6 +22,7 @@ let ghc-lib-parser = hself.ghc-lib-parser_9_2_5_20221107; ghc-lib-parser-ex = hself.ghc-lib-parser-ex_9_2_1_1; + Cabal = hself.Cabal_3_6_3_0; ormolu = hself.ormolu_0_5_0_1; fourmolu = hself.fourmolu_0_9_0_0; hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-341 {}) "-fghc-lib"; From 665b083dcea4c1d361863ef959b384b68067d5d4 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Wed, 14 Dec 2022 11:58:06 -0800 Subject: [PATCH 60/78] use custom apply-refact for now for both ghc 9.2 and 9.4 --- cabal.project | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cabal.project b/cabal.project index 28d94e7808..7387b63934 100644 --- a/cabal.project +++ b/cabal.project @@ -81,6 +81,12 @@ source-repository-package -- https://github.com/tibbe/ekg-json/pull/12 -- END DELETE +source-repository-package + type:git + location: https://github.com/wavewave/apply-refact + tag: b5594f9a274234879b1c0ce2834c2d5df4b1b48a + -- https://github.com/wavewave/apply-refact/pull/1 + allow-newer: -- ghc-9.4 Chart-diagrams:lens, From c757206ba644aee7340be2a09372c1ddca0b3578 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Wed, 14 Dec 2022 13:09:08 -0800 Subject: [PATCH 61/78] added ghc >= 9.2 condition --- cabal.project | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cabal.project b/cabal.project index 7787ef1cff..fbc93b0147 100644 --- a/cabal.project +++ b/cabal.project @@ -81,11 +81,12 @@ source-repository-package -- https://github.com/tibbe/ekg-json/pull/12 -- END DELETE -source-repository-package - type:git - location: https://github.com/wavewave/apply-refact - tag: b5594f9a274234879b1c0ce2834c2d5df4b1b48a - -- https://github.com/wavewave/apply-refact/pull/1 +if (impl(ghc >= 9.2)) + source-repository-package + type:git + location: https://github.com/wavewave/apply-refact + tag: b5594f9a274234879b1c0ce2834c2d5df4b1b48a + -- https://github.com/wavewave/apply-refact/pull/1 allow-newer: -- ghc-9.4 From 476f168793ae6df83e81aed2e193440634399947 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Wed, 14 Dec 2022 15:46:11 -0800 Subject: [PATCH 62/78] fix fourmolu with -f-fixity-th in nix env --- flake.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c78cd3a843..f3518d2761 100644 --- a/flake.nix +++ b/flake.nix @@ -129,7 +129,10 @@ then overrideCabal hsuper.ormolu (_: { enableSeparateBinOutput = false; }) else hsuper.ormolu; - fourmolu = hself.callCabal2nix "fourmolu" inputs.fourmolu {}; + fourmolu = + addBuildDepend + (appendConfigureFlag (hself.callCabal2nix "fourmolu" inputs.fourmolu {}) "-f-fixity-th") + hself.file-embed; }; hlsSources = From cb6b3c16696a8671b12e41c4b78692a683e41a25 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 09:33:00 -0800 Subject: [PATCH 63/78] limit implicit-hie < 0.1.3 --- cabal.project | 5 ++++- flake.lock | 13 +++++++++++++ flake.nix | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index fbc93b0147..bd80253006 100644 --- a/cabal.project +++ b/cabal.project @@ -65,7 +65,10 @@ constraints: -- https://github.com/ndmitchell/hlint/issues/1376 hlint +ghc-lib, ghc-lib-parser-ex -auto, - stylish-haskell +ghc-lib + stylish-haskell +ghc-lib, + -- implicit-hie 0.1.3.0 introduced an unexpected behavioral change. + -- https://github.com/Avi-D-coder/implicit-hie/issues/50 + implicit-hie < 0.1.3 -- This is benign and won't affect our ability to release to Hackage, -- because we only depend on `ekg-json` when a non-default flag diff --git a/flake.lock b/flake.lock index 8db4409aa9..564230f8da 100644 --- a/flake.lock +++ b/flake.lock @@ -225,6 +225,18 @@ "url": "https://hackage.haskell.org/package/hw-prim-0.6.3.2/hw-prim-0.6.3.2.tar.gz" } }, + "implicit-hie": { + "flake": false, + "locked": { + "narHash": "sha256-bFPhAuQe5IjKYQIz1OEC/j/imDESAv3H1nLNVM3lZF4=", + "type": "tarball", + "url": "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz" + } + }, "nixpkgs": { "locked": { "lastModified": 1670827406, @@ -296,6 +308,7 @@ "hlint-341": "hlint-341", "hlint-35": "hlint-35", "hw-prim": "hw-prim", + "implicit-hie": "implicit-hie", "nixpkgs": "nixpkgs", "ptr-poker": "ptr-poker", "retrie": "retrie", diff --git a/flake.nix b/flake.nix index 29a1bdbe56..a6d7457756 100644 --- a/flake.nix +++ b/flake.nix @@ -91,6 +91,10 @@ url = "github:July541/apply-refact/ghc-9.4"; flake = false; }; + implicit-hie = { + url = "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz"; + flake = false; + }; }; outputs = inputs@{ self, nixpkgs, flake-compat, flake-utils, gitignore, all-cabal-hashes-unpacked, ... }: @@ -158,6 +162,7 @@ retrie = hsuper.callCabal2nix "retrie" inputs.retrie {}; retrie_1_1_0_0 = hsuper.callCabal2nix "retrie" inputs.retrie_1100 {}; apply-refactHEAD = hsuper.callCabal2nix "apply-refact" inputs.apply-refact {}; + implicit-hie = hsuper.callCabal2nix "implicit-hie" inputs.implicit-hie {}; # https://github.com/NixOS/nixpkgs/issues/140774 ormolu = From 99de03d3898ae04bd0024095d3a14bcf4307778b Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 12:20:22 -0800 Subject: [PATCH 64/78] add fourmolu back to build-tools-depends --- cabal.project | 3 ++- plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cabal.project b/cabal.project index bd80253006..10fc188eae 100644 --- a/cabal.project +++ b/cabal.project @@ -68,7 +68,8 @@ constraints: stylish-haskell +ghc-lib, -- implicit-hie 0.1.3.0 introduced an unexpected behavioral change. -- https://github.com/Avi-D-coder/implicit-hie/issues/50 - implicit-hie < 0.1.3 + implicit-hie < 0.1.3, + fourmolu -fixity-th -- This is benign and won't affect our ability to release to Hackage, -- because we only depend on `ekg-json` when a non-default flag diff --git a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal index 8d5c3c79b7..cb6052070b 100644 --- a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal +++ b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal @@ -52,8 +52,8 @@ test-suite tests hs-source-dirs: test main-is: Main.hs ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N - -- build-tool-depends: - -- fourmolu:fourmolu + build-tool-depends: + fourmolu:fourmolu build-depends: , base , aeson From 7ab1e11c05098dfd3d6594218968d0c5e675b35e Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 15:11:33 -0800 Subject: [PATCH 65/78] mark GHC92-failing tests to be failed on GHC 9.4 --- test/functional/FunctionalCodeAction.hs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index da715f5817..f1a28821af 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -260,15 +260,15 @@ typedHoleTests = testGroup "typed hole code actions" [ , "foo x = maxBound" ] - , expectFailIfGhc92 "The wingman plugin doesn't yet compile in GHC92" $ - testCase "doesn't work when wingman is active" $ - runSession hlsCommand fullCaps "test/testdata" $ do - doc <- openDoc "TypedHoles.hs" "haskell" - _ <- waitForDiagnosticsFromSource doc "typecheck" - cas <- getAllCodeActions doc - liftIO $ do - dontExpectCodeAction cas ["replace _ with minBound"] - dontExpectCodeAction cas ["replace _ with foo _"] + , knownBrokenForGhcVersions [GHC92, GHC94] "The wingman plugin doesn't yet compile in GHC92/GHC94" $ + testCase "doesn't work when wingman is active" $ + runSession hlsCommand fullCaps "test/testdata" $ do + doc <- openDoc "TypedHoles.hs" "haskell" + _ <- waitForDiagnosticsFromSource doc "typecheck" + cas <- getAllCodeActions doc + liftIO $ do + dontExpectCodeAction cas ["replace _ with minBound"] + dontExpectCodeAction cas ["replace _ with foo _"] , testCase "shows more suggestions" $ runSession hlsCommand fullCaps "test/testdata" $ do @@ -295,7 +295,7 @@ typedHoleTests = testGroup "typed hole code actions" [ , " stuff (A a) = A (a + 1)" ] - , expectFailIfGhc92 "The wingman plugin doesn't yet compile in GHC92" $ + , knownBrokenForGhcVersions [GHC92, GHC94] "The wingman plugin doesn't yet compile in GHC92/GHC94" $ testCase "doesnt show more suggestions when wingman is active" $ runSession hlsCommand fullCaps "test/testdata" $ do doc <- openDoc "TypedHoles2.hs" "haskell" @@ -384,9 +384,6 @@ unusedTermTests = testGroup "unused term code actions" [ $ Just CodeActionQuickFix `notElem` kinds ] -expectFailIfGhc92 :: String -> TestTree -> TestTree -expectFailIfGhc92 = knownBrokenForGhcVersions [GHC92] - disableWingman :: Session () disableWingman = sendConfigurationChanged $ toJSON $ def From 837b040dabc19fda18bd96a86cc9a9891239514e Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 21:36:18 -0800 Subject: [PATCH 66/78] ci failure test From 14bbec3b1d4a4159725514a07532f89ce0080cf7 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 21:47:21 -0800 Subject: [PATCH 67/78] bump nix file. --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index c78cd3a843..3ae8870fda 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,7 @@ # - Edit `sourceDirs` to update the set of local packages # # For more details: https://nixos.wiki/wiki/Flakes +# { description = "haskell language server flake"; From ab753bac811fbd7ff9c95bd6d339e5ce934dd20b Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 21:54:19 -0800 Subject: [PATCH 68/78] disable cachix action --- .github/workflows/nix.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index fc9f300315..e6e77c0fa6 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -94,10 +94,10 @@ jobs: extra_nix_config: | experimental-features = nix-command flakes nix_path: nixpkgs=channel:nixos-unstable - - uses: cachix/cachix-action@v12 - with: - name: haskell-language-server - authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} + #- uses: cachix/cachix-action@v12 + # with: + # name: haskell-language-server + # authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - name: Build development shell run: nix develop --print-build-logs --profile dev - name: Build all development shell (without nix dependencies) From 299c3c17a60f2d9c7e448cdb423c3c8a261f575c Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 22:07:55 -0800 Subject: [PATCH 69/78] further comment out --- .github/workflows/nix.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index e6e77c0fa6..570bb2161b 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -89,8 +89,8 @@ jobs: - uses: cachix/install-nix-action@v18 with: - install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install - install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' + #install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install + #install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' extra_nix_config: | experimental-features = nix-command flakes nix_path: nixpkgs=channel:nixos-unstable From 5b98a6e89e41428cc26da483418138944426c6a7 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 22:11:36 -0800 Subject: [PATCH 70/78] revive cachix action. --- .github/workflows/nix.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 570bb2161b..3a7cb572b1 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -94,10 +94,10 @@ jobs: extra_nix_config: | experimental-features = nix-command flakes nix_path: nixpkgs=channel:nixos-unstable - #- uses: cachix/cachix-action@v12 - # with: - # name: haskell-language-server - # authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} + - uses: cachix/cachix-action@v12 + with: + name: haskell-language-server + authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - name: Build development shell run: nix develop --print-build-logs --profile dev - name: Build all development shell (without nix dependencies) From 4c518f813fefc7a00d0b0f3cb27f63d20ce09166 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 22:23:28 -0800 Subject: [PATCH 71/78] remove commented-out --- .github/workflows/nix.yml | 2 -- flake.nix | 1 - 2 files changed, 3 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 3a7cb572b1..65d102e45f 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -89,8 +89,6 @@ jobs: - uses: cachix/install-nix-action@v18 with: - #install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install - #install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' extra_nix_config: | experimental-features = nix-command flakes nix_path: nixpkgs=channel:nixos-unstable diff --git a/flake.nix b/flake.nix index 3ae8870fda..c78cd3a843 100644 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,6 @@ # - Edit `sourceDirs` to update the set of local packages # # For more details: https://nixos.wiki/wiki/Flakes -# { description = "haskell language server flake"; From f6d857a052151151cbac8a89db5845fedf16f7f3 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 23:25:33 -0800 Subject: [PATCH 72/78] fix hls-cabal-plugin by removing Cabal-syntax. note that this is an opposite to #3383, to prioritize CI fix first. --- plugins/hls-cabal-plugin/hls-cabal-plugin.cabal | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal b/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal index f202b633c3..67170c10ab 100644 --- a/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal +++ b/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal @@ -45,7 +45,6 @@ library -- This is a lot of work for almost zero benefit, so we just allow more versions here -- and we eventually completely drop support for building HLS with stack. , Cabal ^>=3.2 || ^>=3.4 || ^>=3.6 || ^>= 3.8 - , Cabal-syntax ^>= 3.6 , deepseq , directory , extra >=1.7.4 From 30dac518886f4d9680161e3f50da7a1b95e5f8ad Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 15 Dec 2022 09:33:00 -0800 Subject: [PATCH 73/78] limit implicit-hie < 0.1.3 --- cabal.project | 5 ++++- flake.lock | 13 +++++++++++++ flake.nix | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index bad4eda52e..33a71b3ea8 100644 --- a/cabal.project +++ b/cabal.project @@ -65,7 +65,10 @@ constraints: -- https://github.com/ndmitchell/hlint/issues/1376 hlint +ghc-lib, ghc-lib-parser-ex -auto, - stylish-haskell +ghc-lib + stylish-haskell +ghc-lib, + -- implicit-hie 0.1.3.0 introduced an unexpected behavioral change. + -- https://github.com/Avi-D-coder/implicit-hie/issues/50 + implicit-hie < 0.1.3 -- This is benign and won't affect our ability to release to Hackage, -- because we only depend on `ekg-json` when a non-default flag diff --git a/flake.lock b/flake.lock index 2ac39dc862..fa08ce799d 100644 --- a/flake.lock +++ b/flake.lock @@ -148,6 +148,18 @@ "url": "https://hackage.haskell.org/package/hlint-3.4/hlint-3.4.tar.gz" } }, + "implicit-hie": { + "flake": false, + "locked": { + "narHash": "sha256-bFPhAuQe5IjKYQIz1OEC/j/imDESAv3H1nLNVM3lZF4=", + "type": "tarball", + "url": "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz" + } + }, "nixpkgs": { "locked": { "lastModified": 1668650906, @@ -189,6 +201,7 @@ "hiedb": "hiedb", "hlint": "hlint", "hlint-34": "hlint-34", + "implicit-hie": "implicit-hie", "nixpkgs": "nixpkgs", "ptr-poker": "ptr-poker" } diff --git a/flake.nix b/flake.nix index f3518d2761..167eb328bd 100644 --- a/flake.nix +++ b/flake.nix @@ -59,6 +59,10 @@ url = "https://hackage.haskell.org/package/hiedb-0.4.2.0/hiedb-0.4.2.0.tar.gz"; flake = false; }; + implicit-hie = { + url = "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz"; + flake = false; + }; }; outputs = inputs@{ self, nixpkgs, flake-compat, flake-utils, gitignore, all-cabal-hashes-unpacked, ... }: @@ -122,6 +126,7 @@ # Patches don't apply github = overrideCabal hsuper.github (drv: { patches = []; }); hiedb = hsuper.callCabal2nix "hiedb" inputs.hiedb {}; + implicit-hie = hsuper.callCabal2nix "implicit-hie" inputs.implicit-hie {}; # https://github.com/NixOS/nixpkgs/issues/140774 ormolu = From f0bcb95e2c0e7fa923290a98793ae0d206e0d0d8 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 16 Dec 2022 07:16:51 -0800 Subject: [PATCH 74/78] added a small comment and link to the issue. --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index f3518d2761..99820fc88b 100644 --- a/flake.nix +++ b/flake.nix @@ -129,6 +129,8 @@ then overrideCabal hsuper.ormolu (_: { enableSeparateBinOutput = false; }) else hsuper.ormolu; + # Due to the following issue, fixity-th should be disabled, especially for darwin. + # https://github.com/fourmolu/fourmolu/issues/238 fourmolu = addBuildDepend (appendConfigureFlag (hself.callCabal2nix "fourmolu" inputs.fourmolu {}) "-f-fixity-th") From 0557552716c6109be17fc745397f39a80073697e Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 16 Dec 2022 12:24:32 -0800 Subject: [PATCH 75/78] put implicit-hie to ghcide dep --- cabal.project | 5 +---- ghcide/ghcide.cabal | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cabal.project b/cabal.project index 33a71b3ea8..bad4eda52e 100644 --- a/cabal.project +++ b/cabal.project @@ -65,10 +65,7 @@ constraints: -- https://github.com/ndmitchell/hlint/issues/1376 hlint +ghc-lib, ghc-lib-parser-ex -auto, - stylish-haskell +ghc-lib, - -- implicit-hie 0.1.3.0 introduced an unexpected behavioral change. - -- https://github.com/Avi-D-coder/implicit-hie/issues/50 - implicit-hie < 0.1.3 + stylish-haskell +ghc-lib -- This is benign and won't affect our ability to release to Hackage, -- because we only depend on `ekg-json` when a non-default flag diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index 9d898bbef9..5034e354c2 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -104,6 +104,11 @@ library ghc-paths, cryptohash-sha1 >=0.11.100 && <0.12, hie-bios ^>= 0.11.0, + -- implicit-hie 0.1.3.0 introduced an unexpected behavioral change. + -- https://github.com/Avi-D-coder/implicit-hie/issues/50 + -- to make sure ghcide behaves in a desirable way, we put implicit-hie + -- fake dependency here. + implicit-hie < 0.1.3, implicit-hie-cradle ^>= 0.3.0.5 || ^>= 0.5, base16-bytestring >=0.1.1 && <1.1 if os(windows) From eac6f1b9c0341b01c633dc976b2402815f3e7535 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 19 Dec 2022 08:13:59 -0800 Subject: [PATCH 76/78] update apply-refact rev --- cabal.project | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cabal.project b/cabal.project index 95f993e98a..0e7067ffdd 100644 --- a/cabal.project +++ b/cabal.project @@ -82,12 +82,12 @@ source-repository-package -- https://github.com/tibbe/ekg-json/pull/12 -- END DELETE +-- THIS WILL BE DELETED WHEN apply-refact-0.11 is released. if (impl(ghc >= 9.2)) source-repository-package type:git - location: https://github.com/wavewave/apply-refact - tag: 2f346adb54ae3d911c9055b48fb62eb4ceab583a - -- https://github.com/wavewave/apply-refact/pull/1 + location: https://github.com/mpickering/apply-refact + tag: 671b02946f8cb2b5062f4d314ec902a8e0989938 allow-newer: -- ghc-9.4 From 61aca1023dc1506bda4ac33f0a03014cb40ec20d Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 19 Dec 2022 11:28:25 -0800 Subject: [PATCH 77/78] use apply-refact-0.11.0.0 on hackage. --- cabal.project | 9 +-- configuration-ghc-90.nix | 1 + configuration-ghc-94.nix | 2 - flake.lock | 56 +++++++------------ flake.nix | 13 +++-- .../hls-hlint-plugin/hls-hlint-plugin.cabal | 5 +- 6 files changed, 35 insertions(+), 51 deletions(-) diff --git a/cabal.project b/cabal.project index 0e7067ffdd..efab6d710e 100644 --- a/cabal.project +++ b/cabal.project @@ -51,7 +51,7 @@ package * write-ghc-environment-files: never -index-state: 2022-12-13T21:00:15Z +index-state: 2022-12-19T19:08:33Z constraints: -- For GHC 9.4, older versions of entropy fail to build on Windows @@ -82,13 +82,6 @@ source-repository-package -- https://github.com/tibbe/ekg-json/pull/12 -- END DELETE --- THIS WILL BE DELETED WHEN apply-refact-0.11 is released. -if (impl(ghc >= 9.2)) - source-repository-package - type:git - location: https://github.com/mpickering/apply-refact - tag: 671b02946f8cb2b5062f4d314ec902a8e0989938 - allow-newer: -- ghc-9.4 Chart-diagrams:lens, diff --git a/configuration-ghc-90.nix b/configuration-ghc-90.nix index eb472a2db5..8979f6bd3b 100644 --- a/configuration-ghc-90.nix +++ b/configuration-ghc-90.nix @@ -38,6 +38,7 @@ let { }; retrie = hself.retrie_1_1_0_0; + apply-refact = hself.apply-refact_0_9_3_0; }); in { diff --git a/configuration-ghc-94.nix b/configuration-ghc-94.nix index e123f8db63..0c01c66d35 100644 --- a/configuration-ghc-94.nix +++ b/configuration-ghc-94.nix @@ -34,8 +34,6 @@ let hself.callCabal2nixWithOptions "haskell-language-server" ./. (pkgs.lib.concatStringsSep " " [ "-fpedantic" "-f-hlint" ]) { }; - apply-refact = hself.apply-refactHEAD; - }); in { inherit disabledPlugins; diff --git a/flake.lock b/flake.lock index 70f5154ee5..8e4365019d 100644 --- a/flake.lock +++ b/flake.lock @@ -32,18 +32,25 @@ "apply-refact": { "flake": false, "locked": { - "lastModified": 1666418383, - "narHash": "sha256-a/qTzS1dgDfjT1vnOkaMHegKtBo6F1j3q62HY8g0V/Y=", - "owner": "July541", - "repo": "apply-refact", - "rev": "1943b3848e10f9824806c4a3a286fcaec22b4bb8", - "type": "github" + "narHash": "sha256-cK+rsko/aydlvr7di9XS9XEP9tq3SwFWTRrwYrhfCLs=", + "type": "tarball", + "url": "https://hackage.haskell.org/package/apply-refact-0.11.0.0/apply-refact-0.11.0.0.tar.gz" }, "original": { - "owner": "July541", - "ref": "ghc-9.4", - "repo": "apply-refact", - "type": "github" + "type": "tarball", + "url": "https://hackage.haskell.org/package/apply-refact-0.11.0.0/apply-refact-0.11.0.0.tar.gz" + } + }, + "apply-refact-0930": { + "flake": false, + "locked": { + "narHash": "sha256-EosZM++NRncMEr1KM+UIEjGivknqWFvwpTa6kLgK2Mk=", + "type": "tarball", + "url": "https://hackage.haskell.org/package/apply-refact-0.9.3.0/apply-refact-0.9.3.0.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://hackage.haskell.org/package/apply-refact-0.9.3.0/apply-refact-0.9.3.0.tar.gz" } }, "brittany-01312": { @@ -237,30 +244,6 @@ "url": "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz" } }, - "implicit-hie": { - "flake": false, - "locked": { - "narHash": "sha256-bFPhAuQe5IjKYQIz1OEC/j/imDESAv3H1nLNVM3lZF4=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz" - } - }, - "implicit-hie": { - "flake": false, - "locked": { - "narHash": "sha256-bFPhAuQe5IjKYQIz1OEC/j/imDESAv3H1nLNVM3lZF4=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/implicit-hie-0.1.2.7/implicit-hie-0.1.2.7.tar.gz" - } - }, "nixpkgs": { "locked": { "lastModified": 1670827406, @@ -301,7 +284,7 @@ "url": "https://hackage.haskell.org/package/retrie-1.2.1/retrie-1.2.1.tar.gz" } }, - "retrie_1100": { + "retrie-1100": { "flake": false, "locked": { "narHash": "sha256-yn8gguMdBtrB3fCa+4Rq6GHtPSyxYlriENPTgOvjeHE=", @@ -318,6 +301,7 @@ "aeson-1520": "aeson-1520", "all-cabal-hashes-unpacked": "all-cabal-hashes-unpacked", "apply-refact": "apply-refact", + "apply-refact-0930": "apply-refact-0930", "brittany-01312": "brittany-01312", "constraints-extras": "constraints-extras", "flake-compat": "flake-compat", @@ -336,7 +320,7 @@ "nixpkgs": "nixpkgs", "ptr-poker": "ptr-poker", "retrie": "retrie", - "retrie_1100": "retrie_1100" + "retrie-1100": "retrie-1100" } } }, diff --git a/flake.nix b/flake.nix index d6af536978..6ec9913013 100644 --- a/flake.nix +++ b/flake.nix @@ -47,7 +47,7 @@ url = "https://hackage.haskell.org/package/constraints-extras-0.3.2.1/constraints-extras-0.3.2.1.tar.gz"; flake = false; }; - retrie_1100 = { + retrie-1100 = { url = "https://hackage.haskell.org/package/retrie-1.1.0.0/retrie-1.1.0.0.tar.gz"; flake = false; }; @@ -88,7 +88,11 @@ flake = false; }; apply-refact = { - url = "github:July541/apply-refact/ghc-9.4"; + url = "https://hackage.haskell.org/package/apply-refact-0.11.0.0/apply-refact-0.11.0.0.tar.gz"; + flake = false; + }; + apply-refact-0930 = { + url = "https://hackage.haskell.org/package/apply-refact-0.9.3.0/apply-refact-0.9.3.0.tar.gz"; flake = false; }; implicit-hie = { @@ -160,8 +164,9 @@ hiedb = hsuper.callCabal2nix "hiedb" inputs.hiedb {}; hw-prim = hsuper.callCabal2nix "hw-prim" inputs.hw-prim {}; retrie = hsuper.callCabal2nix "retrie" inputs.retrie {}; - retrie_1_1_0_0 = hsuper.callCabal2nix "retrie" inputs.retrie_1100 {}; - apply-refactHEAD = hsuper.callCabal2nix "apply-refact" inputs.apply-refact {}; + retrie_1_1_0_0 = hsuper.callCabal2nix "retrie" inputs.retrie-1100 {}; + apply-refact = hsuper.callCabal2nix "apply-refact" inputs.apply-refact {}; + apply-refact_0_9_3_0 = hsuper.callCabal2nix "apply-refact" inputs.apply-refact-0930 {}; implicit-hie = hsuper.callCabal2nix "implicit-hie" inputs.implicit-hie {}; # https://github.com/NixOS/nixpkgs/issues/140774 diff --git a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal index cc3c8c23b5..f466af0c47 100644 --- a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal +++ b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal @@ -59,9 +59,12 @@ library , text , transformers , unordered-containers - , apply-refact >=0.9.0.0 , ghc-lib-parser , ghc-lib-parser-ex + if impl(ghc >= 9.2) + build-depends: apply-refact ^>= 0.11.0.0 + else + build-depends: apply-refact ^>= 0.9.0.0 cpp-options: -DHLINT_ON_GHC_LIB ghc-options: From 410d0d0d079410ef1f08639bcd001e70ed625e6f Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Wed, 21 Dec 2022 16:05:43 +0530 Subject: [PATCH 78/78] 9.4 support for gadt and retrie plugins --- haskell-language-server.cabal | 4 ++-- plugins/hls-gadt-plugin/hls-gadt-plugin.cabal | 8 -------- plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs | 9 +++++++++ plugins/hls-gadt-plugin/test/Main.hs | 8 ++++---- plugins/hls-retrie-plugin/hls-retrie-plugin.cabal | 4 ---- plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs | 9 +++++++++ 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 5f136f58f6..ef787ec01c 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -262,7 +262,7 @@ common rename cpp-options: -Dhls_rename common retrie - if flag(retrie) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(retrie) build-depends: hls-retrie-plugin ^>= 1.0 cpp-options: -Dhls_retrie @@ -317,7 +317,7 @@ common changeTypeSignature cpp-options: -Dhls_changeTypeSignature common gadt - if flag(gadt) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(gadt) build-depends: hls-gadt-plugin ^>= 1.0 cpp-options: -Dhls_gadt diff --git a/plugins/hls-gadt-plugin/hls-gadt-plugin.cabal b/plugins/hls-gadt-plugin/hls-gadt-plugin.cabal index a4b1568436..6cbb593526 100644 --- a/plugins/hls-gadt-plugin/hls-gadt-plugin.cabal +++ b/plugins/hls-gadt-plugin/hls-gadt-plugin.cabal @@ -20,10 +20,6 @@ source-repository head location: https://github.com/haskell/haskell-language-server.git library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True exposed-modules: Ide.Plugin.GADT other-modules: Ide.Plugin.GHC @@ -54,10 +50,6 @@ library default-extensions: DataKinds test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test diff --git a/plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs b/plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs index bd651ef0bf..73901b0c14 100644 --- a/plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs +++ b/plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs @@ -111,7 +111,12 @@ h98ToGADTConDecl dataName tyVars ctxt = \case renderDetails :: HsConDeclH98Details GP -> HsConDeclGADTDetails GP renderDetails (PrefixCon _ args) = PrefixConGADT args renderDetails (InfixCon arg1 arg2) = PrefixConGADT [arg1, arg2] +#if MIN_VERSION_ghc(9,3,0) + renderDetails (RecCon recs) = RecConGADT recs noHsUniTok +#else renderDetails (RecCon recs) = RecConGADT recs +#endif + #else renderDetails (PrefixCon args) = PrefixCon args renderDetails (InfixCon arg1 arg2) = PrefixCon [arg1, arg2] @@ -185,7 +190,11 @@ prettyGADTDecl df decl = adjustTyClD = \case Right (L _ (TyClD _ tycld)) -> Right $ adjustDataDecl tycld Right x -> Left $ "Expect TyClD but got " <> showAst x +#if MIN_VERSION_ghc(9,3,0) + Left err -> Left $ printWithoutUniques err +#else Left err -> Left $ show err +#endif adjustDataDecl DataDecl{..} = DataDecl { tcdDExt = adjustWhere tcdDExt diff --git a/plugins/hls-gadt-plugin/test/Main.hs b/plugins/hls-gadt-plugin/test/Main.hs index ec4f901736..5fe112dc40 100644 --- a/plugins/hls-gadt-plugin/test/Main.hs +++ b/plugins/hls-gadt-plugin/test/Main.hs @@ -35,13 +35,13 @@ tests = testGroup "GADT" , runTest "ConstructorContext" "ConstructorContext" 2 0 2 38 , runTest "Context" "Context" 2 0 4 41 , runTest "Pragma" "Pragma" 2 0 3 29 - , onlyWorkForGhcVersions (==GHC92) "Single deriving has different output on ghc9.2" $ + , onlyWorkForGhcVersions (`elem`[GHC92, GHC94]) "Single deriving has different output on ghc9.2+" $ runTest "SingleDerivingGHC92" "SingleDerivingGHC92" 2 0 3 14 - , knownBrokenForGhcVersions [GHC92] "Single deriving has different output on ghc9.2" $ + , knownBrokenForGhcVersions [GHC92,GHC94] "Single deriving has different output on ghc9.2+" $ runTest "SingleDeriving" "SingleDeriving" 2 0 3 14 - , onlyWorkForGhcVersions (==GHC92) "only ghc-9.2 enabled GADTs pragma implicitly" $ + , onlyWorkForGhcVersions (`elem`[GHC92, GHC94]) "only ghc-9.2+ enabled GADTs pragma implicitly" $ gadtPragmaTest "ghc-9.2 don't need to insert GADTs pragma" False - , knownBrokenForGhcVersions [GHC92] "ghc-9.2 has enabled GADTs pragma implicitly" $ + , knownBrokenForGhcVersions [GHC92,GHC94] "ghc-9.2 has enabled GADTs pragma implicitly" $ gadtPragmaTest "insert pragma" True ] diff --git a/plugins/hls-retrie-plugin/hls-retrie-plugin.cabal b/plugins/hls-retrie-plugin/hls-retrie-plugin.cabal index 9b1347b4d0..908f2f94a0 100644 --- a/plugins/hls-retrie-plugin/hls-retrie-plugin.cabal +++ b/plugins/hls-retrie-plugin/hls-retrie-plugin.cabal @@ -17,10 +17,6 @@ source-repository head location: https://github.com/haskell/haskell-language-server.git library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True exposed-modules: Ide.Plugin.Retrie hs-source-dirs: src build-depends: diff --git a/plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs b/plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs index 3b4d632822..f006163124 100644 --- a/plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs +++ b/plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs @@ -96,6 +96,11 @@ import Language.LSP.Types as J hiding import Retrie.CPP (CPP (NoCPP), parseCPP) import Retrie.ExactPrint (Annotated, fix, transformA, unsafeMkA) + +#if MIN_VERSION_ghc(9,3,0) +import GHC.Types.PkgQual +#endif + #if MIN_VERSION_ghc(9,2,0) import Retrie.ExactPrint (makeDeltaAst) #else @@ -548,7 +553,11 @@ toImportDecl AddImport {..} = GHC.ImportDecl {ideclSource = ideclSource', ..} ideclSource' = if ideclSource then IsBoot else NotBoot toMod = noLocA . GHC.mkModuleName ideclName = toMod ideclNameString +#if MIN_VERSION_ghc(9,3,0) + ideclPkgQual = NoRawPkgQual +#else ideclPkgQual = Nothing +#endif ideclSafe = False ideclImplicit = False ideclHiding = Nothing