From 40b77d88be54c6c6b6e15396a59b8e7554a679e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Thu, 16 Sep 2021 19:45:59 +0800 Subject: [PATCH 01/31] Initial partially broken ghc9 support for tactics It compiles and most tests succeed, but some fail. In particular, the ones where it should suggest `show` fails to find that as a possible solution and fails to find evidence for `Show a`. --- cabal-ghc901.project | 4 ++-- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 23 +++++++++++++++---- .../hls-tactics-plugin/src/Wingman/CodeGen.hs | 10 ++++++-- .../hls-tactics-plugin/src/Wingman/Context.hs | 1 + .../src/Wingman/EmptyCase.hs | 2 +- plugins/hls-tactics-plugin/src/Wingman/GHC.hs | 13 +++++++++-- .../src/Wingman/Judgements/Theta.hs | 8 +++++++ .../src/Wingman/LanguageServer.hs | 14 ++++++++--- .../Wingman/LanguageServer/TacticProviders.hs | 2 +- .../hls-tactics-plugin/src/Wingman/Naming.hs | 5 ++-- .../hls-tactics-plugin/src/Wingman/Tactics.hs | 14 ++++++----- .../hls-tactics-plugin/test/AutoTupleSpec.hs | 3 +-- .../test/UnificationSpec.hs | 4 ++-- stack-9.0.1.yaml | 3 +-- 14 files changed, 76 insertions(+), 30 deletions(-) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index 34331958de..6f4e582871 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -6,7 +6,7 @@ packages: ./ghcide ./hls-plugin-api ./hls-test-utils - -- ./plugins/hls-tactics-plugin + ./plugins/hls-tactics-plugin -- ./plugins/hls-brittany-plugin -- ./plugins/hls-stylish-haskell-plugin -- ./plugins/hls-fourmolu-plugin @@ -65,7 +65,7 @@ index-state: 2021-09-06T12:12:22Z constraints: -- These plugins don't work on GHC9 yet - haskell-language-server -brittany -class -fourmolu -stylishhaskell -tactic + haskell-language-server -brittany -class -fourmolu -stylishhaskell allow-newer: floskell:base, diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index b2f560e9c3..1ab4aafe62 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -66,7 +66,10 @@ module Development.IDE.GHC.Compat.Core ( -- slightly unsafe setUnsafeGlobalDynFlags, -- * Linear Haskell +#if !MIN_VERSION_ghc(9,0,0) Scaled, + unrestricted, +#endif scaledThing, -- * Interface Files IfaceExport, @@ -121,9 +124,12 @@ module Development.IDE.GHC.Compat.Core ( TyCoRep.CoercionTy ), pattern FunTy, + pattern ConPatIn, Development.IDE.GHC.Compat.Core.splitForAllTyCoVars, +#if !MIN_VERSION_ghc(9,0,0) Development.IDE.GHC.Compat.Core.mkVisFunTys, Development.IDE.GHC.Compat.Core.mkInfForAllTys, +#endif -- * Specs ImpDeclSpec(..), ImportSpec(..), @@ -336,6 +342,7 @@ module Development.IDE.GHC.Compat.Core ( module GHC.Types.Var, module GHC.Unit.Module, module GHC.Utils.Error, + module TcType, #else module BasicTypes, module Class, @@ -769,7 +776,9 @@ dataConExTyCoVars = DataCon.dataConExTyVars type Scaled a = a scaledThing :: Scaled a -> a scaledThing = id -#endif + +unrestricted :: a -> Scaled a +unrestricted = id mkVisFunTys :: [Scaled Type] -> Type -> Type mkVisFunTys = @@ -781,10 +790,7 @@ mkVisFunTys = mkInfForAllTys :: [TyVar] -> Type -> Type mkInfForAllTys = -#if MIN_VERSION_ghc(9,0,0) - TcType.mkInfForAllTys -#else - mkInvForAllTys + mkInfForAllTys #endif splitForAllTyCoVars :: Type -> ([TyCoVar], Type) @@ -846,3 +852,10 @@ type PlainGhcException = Plain.PlainGhcException #else type PlainGhcException = Plain.GhcException #endif + +#if MIN_VERSION_ghc(9,0,0) +-- This is from the old api, but it still simplifies +pattern ConPatIn :: SrcLoc.Located (ConLikeP GhcPs) -> HsConPatDetails GhcPs -> Pat GhcPs +pattern ConPatIn con args = ConPat NoExtField con args +#endif + diff --git a/plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs b/plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs index 5f2f86605c..2ef491a5ec 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE OverloadedStrings #-} @@ -57,7 +58,7 @@ destructMatches use_field_puns f scrut t jdg = do Just (dcs, apps) -> fmap unzipTrace $ for dcs $ \dc -> do let con = RealDataCon dc - ev = concatMap mkEvidence $ dataConInstArgTys dc apps + ev = concatMap (mkEvidence . scaledThing) $ dataConInstArgTys dc apps -- We explicitly do not need to add the method hypothesis to -- #syn_scoped method_hy = foldMap evidenceToHypothesis ev @@ -140,6 +141,7 @@ mkDestructPat already_in_scope con names in (names', ) $ ConPatIn (noLoc $ Unqual $ occName $ conLikeName con) + -- $ ConPat NoExtField (noLoc $ Unqual $ occName $ conLikeName con) $ RecCon $ HsRecFields rec_fields $ Nothing @@ -186,7 +188,7 @@ conLikeInstOrigArgTys' -- ^ Types of arguments to the ConLike with returned type is instantiated with the second argument. conLikeInstOrigArgTys' con uniTys = let exvars = conLikeExTys con - in conLikeInstOrigArgTys con $ + in map scaledThing $ conLikeInstOrigArgTys con $ uniTys ++ fmap mkTyVarTy exvars -- Rationale: At least in GHC <= 8.10, 'dataConInstOrigArgTys' -- unifies the second argument with DataCon's universals followed by existentials. @@ -230,7 +232,11 @@ destructLambdaCase' use_field_puns f jdg = do when (isDestructBlacklisted jdg) $ cut -- throwError NoApplicableTactic let g = jGoal jdg case splitFunTy_maybe (unCType g) of +#if __GLASGOW_HASKELL__ >= 900 + Just (_multiplicity, arg, _) | isAlgType arg -> +#else Just (arg, _) | isAlgType arg -> +#endif fmap (fmap noLoc lambdaCase) <$> destructMatches use_field_puns f Nothing (CType arg) jdg _ -> cut -- throwError $ GoalMismatch "destructLambdaCase'" g diff --git a/plugins/hls-tactics-plugin/src/Wingman/Context.hs b/plugins/hls-tactics-plugin/src/Wingman/Context.hs index 9aea0bf5eb..2e3880893a 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Context.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Context.hs @@ -11,6 +11,7 @@ import Development.IDE.GHC.Compat.Util import Wingman.GHC (normalizeType) import Wingman.Judgements.Theta import Wingman.Types +-- import GHC.Tc.Utils.TcType (tcSplitPhiTy, tcSplitTyConApp) mkContext diff --git a/plugins/hls-tactics-plugin/src/Wingman/EmptyCase.hs b/plugins/hls-tactics-plugin/src/Wingman/EmptyCase.hs index 42c62cfc19..8cbdd442e7 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/EmptyCase.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/EmptyCase.hs @@ -88,7 +88,7 @@ scrutinzedType :: EmptyCaseSort Type -> Maybe Type scrutinzedType (EmptyCase ty) = pure ty scrutinzedType (EmptyLamCase ty) = case tacticsSplitFunTy ty of - (_, _, tys, _) -> listToMaybe tys + (_, _, tys, _) -> listToMaybe $ map scaledThing tys ------------------------------------------------------------------------------ diff --git a/plugins/hls-tactics-plugin/src/Wingman/GHC.hs b/plugins/hls-tactics-plugin/src/Wingman/GHC.hs index 647d6cd60b..9da9f5ade7 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/GHC.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/GHC.hs @@ -17,6 +17,7 @@ import Data.Traversable import Development.IDE.GHC.Compat import Development.IDE.GHC.Compat.Util import GHC.SourceGen (lambda) +-- import GHC.Tc.Utils.TcType (tcSplitSigmaTy, tcSplitNestedSigmaTys, tcSplitFunTys, tyCoVarsOfTypeList) import Generics.SYB (Data, everything, everywhere, listify, mkQ, mkT) import Wingman.StaticPlugin (pattern MetaprogramSyntax) import Wingman.Types @@ -57,7 +58,7 @@ isFunction _ = True ------------------------------------------------------------------------------ -- | Split a function, also splitting out its quantified variables and theta -- context. -tacticsSplitFunTy :: Type -> ([TyVar], ThetaType, [Type], Type) +tacticsSplitFunTy :: Type -> ([TyVar], ThetaType, [Scaled Type], Type) tacticsSplitFunTy t = let (vars, theta, t') = tcSplitNestedSigmaTys t (args, res) = tcSplitFunTys t' @@ -182,7 +183,11 @@ allOccNames = everything (<>) $ mkQ mempty $ \case ------------------------------------------------------------------------------ -- | Unpack the relevant parts of a 'Match' +#if __GLASGOW_HASKELL__ >= 900 +pattern AMatch :: HsMatchContext (NoGhcTc GhcPs) -> [Pat GhcPs] -> HsExpr GhcPs -> Match GhcPs (LHsExpr GhcPs) +#else pattern AMatch :: HsMatchContext (NameOrRdrName (IdP GhcPs)) -> [Pat GhcPs] -> HsExpr GhcPs -> Match GhcPs (LHsExpr GhcPs) +#endif pattern AMatch ctx pats body <- Match { m_ctxt = ctx , m_pats = fmap fromPatCompat -> pats @@ -195,7 +200,7 @@ pattern SingleLet bind pats val expr <- HsLet _ (L _ (HsValBinds _ (ValBinds _ (bagToList -> - [(L _ (FunBind _ (L _ bind) (MG _ (L _ [L _ (AMatch _ pats val)]) _) _ _))]) _))) + [L _ (FunBind {fun_id = (L _ bind), fun_matches = (MG _ (L _ [L _ (AMatch _ pats val)]) _)})]) _))) (L _ expr) @@ -258,7 +263,11 @@ pattern LamCase matches <- -- @Just False@ if it can't be homomorphic -- @Just True@ if it can lambdaCaseable :: Type -> Maybe Bool +#if __GLASGOW_HASKELL__ >= 900 +lambdaCaseable (splitFunTy_maybe -> Just (_multiplicity, arg, res)) +#else lambdaCaseable (splitFunTy_maybe -> Just (arg, res)) +#endif | isJust (algebraicTyCon arg) = Just $ isJust $ algebraicTyCon res lambdaCaseable _ = Nothing diff --git a/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs b/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs index c2fccd4d7d..b9fc3e0059 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs @@ -180,7 +180,11 @@ absBinds _ _ = [] ------------------------------------------------------------------------------ -- | Extract evidence from 'HsWrapper's in scope wrapperBinds :: SrcSpan -> LHsExpr GhcTc -> [PredType] +#if __GLASGOW_HASKELL__ >= 900 +wrapperBinds dst (L src (XExpr (WrapExpr (HsWrap h _)))) +#else wrapperBinds dst (L src (HsWrap _ h _)) +#endif | dst `isSubspanOf` src = wrapper h wrapperBinds _ _ = [] @@ -196,7 +200,11 @@ matchBinds _ _ = [] ------------------------------------------------------------------------------ -- | Extract evidence from a 'ConPatOut'. patBinds :: Pat GhcTc -> [PredType] +#if __GLASGOW_HASKELL__ >= 900 +patBinds (ConPat{ pat_con_ext = ConPatTc { cpt_dicts = dicts }}) +#else patBinds (ConPatOut { pat_dicts = dicts }) +#endif = fmap idType dicts patBinds _ = [] diff --git a/plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs b/plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs index 3524194fb1..ae3b4eb5c4 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs @@ -292,8 +292,8 @@ getAlreadyDestructed (unTrack -> span) (unTrack -> binds) = getSpanAndTypeAtHole :: Tracked age Range - -> Tracked age (HieASTs b) - -> Maybe (Tracked age RealSrcSpan, b) + -> Tracked age (HieASTs Type) + -> Maybe (Tracked age RealSrcSpan, Type) getSpanAndTypeAtHole r@(unTrack -> range) (unTrack -> hf) = do join $ listToMaybe $ M.elems $ flip M.mapWithKey (getAsts hf) $ \fs ast -> case selectSmallestContaining (rangeToRealSrcSpan (FastString.unpackFS fs) range) ast of @@ -386,7 +386,11 @@ buildPatHy prov (fromPatCompat -> p0) = (RealDataCon $ tupleDataCon boxity $ length pats) tys $ zip [0.. ] pats - ConPatOut (L _ con) args _ _ _ f _ -> +#if __GLASGOW_HASKELL__ >= 900 + ConPat {pat_con = (L _ con), pat_con_ext = ConPatTc {cpt_arg_tys = args}, pat_args = f} -> +#else + ConPatOut {pat_con = (L _ con), pat_arg_tys = args, pat_args = f} -> +#endif case f of PrefixCon l_pgt -> mkDerivedConHypothesis prov con args $ zip [0..] l_pgt @@ -540,7 +544,11 @@ wingmanRules plId = do L span (HsVar _ (L _ name)) | isHole (occName name) -> maybeToList $ srcSpanToRange span +#if __GLASGOW_HASKELL__ >= 900 + L span (HsUnboundVar _ occ) +#else L span (HsUnboundVar _ (TrueExprHole occ)) +#endif | isHole occ -> maybeToList $ srcSpanToRange span #if __GLASGOW_HASKELL__ <= 808 diff --git a/plugins/hls-tactics-plugin/src/Wingman/LanguageServer/TacticProviders.hs b/plugins/hls-tactics-plugin/src/Wingman/LanguageServer/TacticProviders.hs index 631baf58b7..f6672a354e 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/LanguageServer/TacticProviders.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/LanguageServer/TacticProviders.hs @@ -296,7 +296,7 @@ homoFilter codomain domain = liftLambdaCase :: r -> (Type -> Type -> r) -> Type -> r liftLambdaCase nil f t = case tacticsSplitFunTy t of - (_, _, arg : _, res) -> f res arg + (_, _, arg : _, res) -> f res $ scaledThing arg _ -> nil diff --git a/plugins/hls-tactics-plugin/src/Wingman/Naming.hs b/plugins/hls-tactics-plugin/src/Wingman/Naming.hs index 05f5c2b85a..3dcb365d46 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Naming.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Naming.hs @@ -17,6 +17,7 @@ import Data.Traversable import Development.IDE.GHC.Compat.Core hiding (IsFunction) import Text.Hyphenation (hyphenate, english_US) import Wingman.GHC (tcTyVar_maybe) +-- import GHC.Tc.Utils.TcType (tcSplitFunTys, isBoolTy, isIntegerTy, isIntTy, isFloatingTy, isStringTy, tcSplitAppTys) ------------------------------------------------------------------------------ @@ -38,11 +39,11 @@ data Purpose pattern IsPredicate :: Type pattern IsPredicate <- - (tcSplitFunTys -> ([isFunTy -> False], isBoolTy -> True)) + (tcSplitFunTys -> ([isFunTy . scaledThing -> False], isBoolTy -> True)) pattern IsFunction :: [Type] -> Type -> Type pattern IsFunction args res <- - (tcSplitFunTys -> (args@(_:_), res)) + (first (map scaledThing) . tcSplitFunTys -> (args@(_:_), res)) pattern IsString :: Type pattern IsString <- diff --git a/plugins/hls-tactics-plugin/src/Wingman/Tactics.hs b/plugins/hls-tactics-plugin/src/Wingman/Tactics.hs index d6909a11ca..b2fb62d9ca 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Tactics.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Tactics.hs @@ -24,7 +24,6 @@ import Data.Maybe import Data.Set (Set) import qualified Data.Set as S import Data.Traversable (for) -import DataCon import Development.IDE.GHC.Compat hiding (empty) import GHC.Exts import GHC.SourceGen ((@@)) @@ -132,7 +131,8 @@ intros' params = rule $ \jdg -> do let g = jGoal jdg case tacticsSplitFunTy $ unCType g of (_, _, [], _) -> cut -- failure $ GoalMismatch "intros" g - (_, _, args, res) -> do + (_, _, scaledArgs, res) -> do + let args = map scaledThing scaledArgs ctx <- ask let gen_names = mkManyGoodNames (hyNamesInScope $ jEntireHypothesis jdg) args occs = case params of @@ -145,7 +145,7 @@ intros' params = rule $ \jdg -> do bound_occs = fmap fst bindings hy' = lambdaHypothesis top_hole bindings jdg' = introduce ctx hy' - $ withNewGoal (CType $ mkVisFunTys (drop num_occs args) res) jdg + $ withNewGoal (CType $ mkVisFunTys (drop num_occs scaledArgs) res) jdg ext <- newSubgoal jdg' pure $ ext @@ -291,6 +291,7 @@ apply (Unsaturated n) hi = tracing ("apply' " <> show (hi_name hi)) $ do . blacklistingDestruct . flip withNewGoal jdg . CType + . scaledThing ) saturated_args pure $ ext @@ -524,6 +525,7 @@ applyByType ty = tracing ("applyByType " <> show ty) $ do . blacklistingDestruct . flip withNewGoal jdg . CType + . scaledThing ) args app <- newSubgoal . blacklistingDestruct $ withNewGoal (CType ty) jdg pure $ @@ -540,7 +542,7 @@ nary :: Int -> TacticsM () nary n = do a <- newUnivar b <- newUnivar - applyByType $ mkVisFunTys (replicate n a) b + applyByType $ mkVisFunTys (replicate n $ unrestricted a) b self :: TacticsM () @@ -558,7 +560,7 @@ cata :: HyInfo CType -> TacticsM () cata hi = do (_, _, calling_args, _) <- tacticsSplitFunTy . unCType <$> getDefiningType - freshened_args <- traverse freshTyvars calling_args + freshened_args <- traverse (freshTyvars . scaledThing) calling_args diff <- hyDiff $ destruct hi -- For for every destructed term, check to see if it can unify with any of @@ -625,7 +627,7 @@ with_arg = rule $ \jdg -> do let g = jGoal jdg fresh_ty <- newUnivar a <- newSubgoal $ withNewGoal (CType fresh_ty) jdg - f <- newSubgoal $ withNewGoal (coerce mkVisFunTys [fresh_ty] g) jdg + f <- newSubgoal $ withNewGoal (coerce mkVisFunTys [unrestricted fresh_ty] g) jdg pure $ fmap noLoc $ (@@) <$> fmap unLoc f <*> fmap unLoc a diff --git a/plugins/hls-tactics-plugin/test/AutoTupleSpec.hs b/plugins/hls-tactics-plugin/test/AutoTupleSpec.hs index a3164f713f..11ba11e2ae 100644 --- a/plugins/hls-tactics-plugin/test/AutoTupleSpec.hs +++ b/plugins/hls-tactics-plugin/test/AutoTupleSpec.hs @@ -7,11 +7,10 @@ module AutoTupleSpec where import Control.Monad (replicateM) import Control.Monad.State (evalState) import Data.Either (isRight) -import OccName (mkVarOcc) +import Development.IDE.GHC.Compat.Core ( mkVarOcc, mkBoxedTupleTy ) import System.IO.Unsafe import Test.Hspec import Test.QuickCheck -import TysWiredIn (mkBoxedTupleTy) import Wingman.Judgements (mkFirstJudgement) import Wingman.Machinery import Wingman.Tactics (auto') diff --git a/plugins/hls-tactics-plugin/test/UnificationSpec.hs b/plugins/hls-tactics-plugin/test/UnificationSpec.hs index db39fdfe10..69ea9c2459 100644 --- a/plugins/hls-tactics-plugin/test/UnificationSpec.hs +++ b/plugins/hls-tactics-plugin/test/UnificationSpec.hs @@ -12,13 +12,13 @@ import Data.Maybe (mapMaybe) import qualified Data.Set as S import Data.Traversable import Data.Tuple (swap) -import TcType (substTy, tcGetTyVar_maybe) +import Development.IDE.GHC.Compat.Core (substTy, tcGetTyVar_maybe, mkBoxedTupleTy) import Test.Hspec import Test.QuickCheck -import TysWiredIn (mkBoxedTupleTy) import Wingman.GHC import Wingman.Machinery (newUnivar) import Wingman.Types +-- import GHC.Tc.Utils.TcType (tcGetTyVar_maybe) spec :: Spec diff --git a/stack-9.0.1.yaml b/stack-9.0.1.yaml index 010e96af4a..814e89b9eb 100644 --- a/stack-9.0.1.yaml +++ b/stack-9.0.1.yaml @@ -18,7 +18,7 @@ packages: - ./plugins/hls-rename-plugin - ./plugins/hls-retrie-plugin - ./plugins/hls-splice-plugin - # - ./plugins/hls-tactics-plugin + - ./plugins/hls-tactics-plugin # - ./plugins/hls-brittany-plugin # - ./plugins/hls-stylish-haskell-plugin - ./plugins/hls-floskell-plugin @@ -103,7 +103,6 @@ flags: pedantic: true class: false - tactic: false # Dependencies fail fourmolu: false stylishHaskell: false From caba0ca14c1122eec532794149be3330728b3af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Fri, 17 Sep 2021 10:53:33 +0800 Subject: [PATCH 02/31] Enable tactics plugin for nix as well --- configuration-ghc-901.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/configuration-ghc-901.nix b/configuration-ghc-901.nix index f10724f125..6053c54b87 100644 --- a/configuration-ghc-901.nix +++ b/configuration-ghc-901.nix @@ -3,7 +3,6 @@ let disabledPlugins = [ - "hls-tactics-plugin" "hls-brittany-plugin" "hls-stylish-haskell-plugin" "hls-fourmolu-plugin" From cda69718ec8e49eb097fa41db97bcea212b725f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Sat, 18 Sep 2021 09:17:41 +0800 Subject: [PATCH 03/31] Wingman does support ghc9 now --- test/functional/FunctionalCodeAction.hs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index 6c0bd95c4a..820f2c8483 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -422,8 +422,7 @@ typedHoleTests = testGroup "typed hole code actions" [ , "foo x = maxBound" ] - , expectFailIfGhc9 "The wingman plugin doesn't yet compile in GHC9" $ - testCase "doesn't work when wingman is active" $ + , testCase "doesn't work when wingman is active" $ runSession hlsCommand fullCaps "test/testdata" $ do doc <- openDoc "TypedHoles.hs" "haskell" _ <- waitForDiagnosticsFromSource doc "typecheck" @@ -457,8 +456,7 @@ typedHoleTests = testGroup "typed hole code actions" [ , " stuff (A a) = A (a + 1)" ] - , expectFailIfGhc9 "The wingman plugin doesn't yet compile in GHC9" $ - testCase "doesnt show more suggestions when wingman is active" $ + , testCase "doesnt show more suggestions when wingman is active" $ runSession hlsCommand fullCaps "test/testdata" $ do doc <- openDoc "TypedHoles2.hs" "haskell" _ <- waitForDiagnosticsFromSource doc "typecheck" @@ -545,12 +543,6 @@ unusedTermTests = testGroup "unused term code actions" [ nub kinds @?= nub [Just CodeActionRefactorInline, Just CodeActionRefactorExtract] ] -expectFailIfGhc9 :: String -> TestTree -> TestTree -expectFailIfGhc9 reason = - case ghcVersion of - GHC90 -> expectFailBecause reason - _ -> id - disableWingman :: Session () disableWingman = sendConfigurationChanged $ def From dec5fc3d5939f506e647c28c06b5300beb722a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Sat, 18 Sep 2021 10:01:26 +0800 Subject: [PATCH 04/31] Fix stack support for tactics ghc-9.0.1 --- stack-9.0.1.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stack-9.0.1.yaml b/stack-9.0.1.yaml index ed59213e57..e249040f0f 100644 --- a/stack-9.0.1.yaml +++ b/stack-9.0.1.yaml @@ -38,6 +38,8 @@ extra-deps: - dependent-sum-0.7.1.0@sha256:0e419237f5b86da3659772afff9cab355c0f8d5b3fdb15a5b30e673d8dc83941,2147 - extra-1.7.9 - floskell-0.10.5 +- generic-lens-2.2.0.0@sha256:4008a39f464e377130346e46062e2ac1211f9d2e256bbb1857216e889c7196be,3867 +- generic-lens-core-2.2.0.0@sha256:b6b69e992f15fa80001de737f41f2123059011a1163d6c8941ce2e3ab44f8c03,2913 - ghc-source-gen-0.4.1.0 - heapsize-0.3.0.1@sha256:0b69aa97a46d819b700ac7b145f3b5493c3565cf2c5b8298682238d405d0326e,1417 - hie-bios-0.7.6 From d382412570c9d0f7ec6372f08d643c42c057c605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Sat, 18 Sep 2021 11:22:08 +0800 Subject: [PATCH 05/31] Enable tests for tactics on ghc-9 on ci --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 659b6df72f..0c6d9b0f00 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -200,7 +200,7 @@ jobs: name: Test hls-fourmolu-plugin run: cabal test hls-fourmolu-plugin --test-options="-j1 --rerun-update" || cabal test hls-fourmolu-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-fourmolu-plugin --test-options="-j1 --rerun" - - if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }} + - if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }} name: Test hls-tactics-plugin test suite run: cabal test hls-tactics-plugin --test-options="-j1 --rerun-update" || cabal test hls-tactics-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-tactics-plugin --test-options="-j1 --rerun" From ed528be477b9327e267d9fdcf5cc9d44ddfd8ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Sat, 18 Sep 2021 11:25:54 +0800 Subject: [PATCH 06/31] Actually enable tactics for ghc-9 on nix --- configuration-ghc-901.nix | 6 ++++-- flake.lock | 6 +++--- stack-9.0.1.yaml | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/configuration-ghc-901.nix b/configuration-ghc-901.nix index 6053c54b87..81c7acc012 100644 --- a/configuration-ghc-901.nix +++ b/configuration-ghc-901.nix @@ -53,7 +53,10 @@ let dependent-sum-template = hself.callCabal2nix "dependent-sum-template" "${dependent-sum-src}/dependent-sum-template" { }; - hlint = hself.hlint_3_3_1; + hlint = hself.hlint_3_3_4; + + generic-lens = hself.generic-lens_2_2_0_0; + generic-lens-core = hself.generic-lens-core_2_2_0_0; ghc-lib-parser = hself.ghc-lib-parser_9_0_1_20210324; @@ -84,7 +87,6 @@ let "-f-class" "-f-fourmolu" "-f-stylishhaskell" - "-f-tactic" ]) { }; # YOLO diff --git a/flake.lock b/flake.lock index ed2b424993..8dd8d39887 100644 --- a/flake.lock +++ b/flake.lock @@ -49,11 +49,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1630887066, - "narHash": "sha256-0ecIlrLsNIIa+zrNmzXXmbMBLZlmHU/aWFsa4bq99Hk=", + "lastModified": 1631786778, + "narHash": "sha256-CCMDj/0yXJnrlO4/NpHKhYRifNADQ1WUeQmFUD4sU4c=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5e47a07e9f2d7ed999f2c7943b0896f5f7321ca3", + "rev": "a39ee95a86b1fbdfa9edd65f3810b23d82457241", "type": "github" }, "original": { diff --git a/stack-9.0.1.yaml b/stack-9.0.1.yaml index e249040f0f..6245968357 100644 --- a/stack-9.0.1.yaml +++ b/stack-9.0.1.yaml @@ -40,7 +40,7 @@ extra-deps: - floskell-0.10.5 - generic-lens-2.2.0.0@sha256:4008a39f464e377130346e46062e2ac1211f9d2e256bbb1857216e889c7196be,3867 - generic-lens-core-2.2.0.0@sha256:b6b69e992f15fa80001de737f41f2123059011a1163d6c8941ce2e3ab44f8c03,2913 -- ghc-source-gen-0.4.1.0 +# - ghc-source-gen-0.4.2.0 # Already in snapshot - heapsize-0.3.0.1@sha256:0b69aa97a46d819b700ac7b145f3b5493c3565cf2c5b8298682238d405d0326e,1417 - hie-bios-0.7.6 - hiedb-0.4.1.0 @@ -119,6 +119,6 @@ flags: embed: true nix: - packages: [ icu libcxx zlib ] + packages: [ icu libcxx zlib darwin.apple_sdk.frameworks.CoreServices darwin.apple_sdk.frameworks.Cocoa ] concurrent-tests: false From 147418822dd47edeec764f4bd76d9ed5c6edf123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Sat, 18 Sep 2021 15:23:20 +0800 Subject: [PATCH 07/31] Wingman: Improve test failure messages Previously when wingman fails to find a solution, the test failure would say "Timed out when waiting for a message". Now it instead prints the error message from wingman. --- plugins/hls-tactics-plugin/test/Utils.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/hls-tactics-plugin/test/Utils.hs b/plugins/hls-tactics-plugin/test/Utils.hs index 36bdc8dfc8..25558be8f0 100644 --- a/plugins/hls-tactics-plugin/test/Utils.hs +++ b/plugins/hls-tactics-plugin/test/Utils.hs @@ -23,6 +23,7 @@ import qualified Data.Text.IO as T import Ide.Plugin.Tactic as Tactic import Language.LSP.Types import Language.LSP.Types.Lens hiding (actions, applyEdit, capabilities, executeCommand, id, line, message, name, rename, title) +import qualified Language.LSP.Types.Lens as J import System.Directory (doesFileExist) import System.FilePath import Test.Hls @@ -112,7 +113,10 @@ mkGoldenTest eq tc occ line col input = Just (InR CodeAction {_command = Just c}) <- pure $ find ((== Just (tacticTitle tc occ)) . codeActionTitle) actions executeCommand c - _resp <- skipManyTill anyMessage (message SWorkspaceApplyEdit) + resp <- skipManyTill anyMessage (Right <$> message SWorkspaceApplyEdit <|> Left <$> message SWindowShowMessage) + case resp of + Left nm -> liftIO $ expectationFailure $ "Expected WorkspaceApplyEdit.\nInstead got message:\n " ++ show (nm ^. params . J.message) + Right _ -> pure () edited <- documentContents doc let expected_name = input <.> "expected" <.> "hs" -- Write golden tests if they don't already exist From 2a9ea27ef977357b04992497602b05f1fe5ef4d9 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Wed, 12 Jan 2022 13:35:51 -0800 Subject: [PATCH 08/31] Get theta --- .../src/Wingman/Judgements/Theta.hs | 16 +++++++++++++--- .../src/Wingman/StaticPlugin.hs | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs b/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs index b9fc3e0059..233c2ef814 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs @@ -172,8 +172,16 @@ excludeForbiddenMethods = filter (not . flip S.member forbiddenMethods . hi_name ------------------------------------------------------------------------------ -- | Extract evidence from 'AbsBinds' in scope. absBinds :: SrcSpan -> LHsBindLR GhcTc GhcTc -> [PredType] +#if __GLASGOW_HASKELL__ >= 900 +absBinds dst (L src (AbsBinds _ _ h _ _ z _)) +#else absBinds dst (L src (AbsBinds _ _ h _ _ _ _)) - | dst `isSubspanOf` src = fmap idType h +#endif + | dst `isSubspanOf` src + = fmap idType h +#if __GLASGOW_HASKELL__ >= 900 + <> everything (<>) (mkQ mempty wrapper) z +#endif absBinds _ _ = [] @@ -185,7 +193,8 @@ wrapperBinds dst (L src (XExpr (WrapExpr (HsWrap h _)))) #else wrapperBinds dst (L src (HsWrap _ h _)) #endif - | dst `isSubspanOf` src = wrapper h + | dst `isSubspanOf` src + = wrapper h wrapperBinds _ _ = [] @@ -193,7 +202,8 @@ wrapperBinds _ _ = [] -- | Extract evidence from the 'ConPatOut's bound in this 'Match'. matchBinds :: SrcSpan -> LMatch GhcTc (LHsExpr GhcTc) -> [PredType] matchBinds dst (L src (Match _ _ pats _)) - | dst `isSubspanOf` src = everything (<>) (mkQ mempty patBinds) pats + | dst `isSubspanOf` src + = everything (<>) (mkQ mempty patBinds) pats matchBinds _ _ = [] diff --git a/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs b/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs index 82be432a3a..ec84580fd4 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs @@ -13,7 +13,11 @@ import Development.IDE.GHC.Compat.Util import GHC.LanguageExtensions.Type (Extension(EmptyCase, QuasiQuotes)) import Generics.SYB import Ide.Types +#if __GLASGOW_HASKELL__ >= 900 +import GHC.Driver.Plugins (purePlugin) +#else import Plugins (purePlugin) +#endif staticPlugin :: DynFlagsModifications staticPlugin = mempty From 0aa62a11ace5f6b05a868e94543f3d9baef2d29b Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Wed, 12 Jan 2022 15:18:21 -0800 Subject: [PATCH 09/31] Make wrapper theta discovery more reliable --- plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs b/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs index 233c2ef814..9682c6e078 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs @@ -173,6 +173,9 @@ excludeForbiddenMethods = filter (not . flip S.member forbiddenMethods . hi_name -- | Extract evidence from 'AbsBinds' in scope. absBinds :: SrcSpan -> LHsBindLR GhcTc GhcTc -> [PredType] #if __GLASGOW_HASKELL__ >= 900 +absBinds dst (L src (FunBind w _ _ _)) + | dst `isSubspanOf` src + = wrapper w absBinds dst (L src (AbsBinds _ _ h _ _ z _)) #else absBinds dst (L src (AbsBinds _ _ h _ _ _ _)) @@ -180,7 +183,7 @@ absBinds dst (L src (AbsBinds _ _ h _ _ _ _)) | dst `isSubspanOf` src = fmap idType h #if __GLASGOW_HASKELL__ >= 900 - <> everything (<>) (mkQ mempty wrapper) z + <> foldMap (absBinds dst) z #endif absBinds _ _ = [] From 4460c6c29110527ef35ca48dc6f95d1996a00866 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Wed, 12 Jan 2022 15:18:33 -0800 Subject: [PATCH 10/31] Fix AutoThetaRankN --- plugins/hls-tactics-plugin/test/CodeAction/AutoSpec.hs | 2 +- .../hls-tactics-plugin/test/golden/AutoThetaRankN.expected.hs | 2 +- plugins/hls-tactics-plugin/test/golden/AutoThetaRankN.hs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/hls-tactics-plugin/test/CodeAction/AutoSpec.hs b/plugins/hls-tactics-plugin/test/CodeAction/AutoSpec.hs index cc97666a2a..9322b0912b 100644 --- a/plugins/hls-tactics-plugin/test/CodeAction/AutoSpec.hs +++ b/plugins/hls-tactics-plugin/test/CodeAction/AutoSpec.hs @@ -59,7 +59,7 @@ spec = do describe "theta" $ do autoTest 12 10 "AutoThetaFix" - autoTest 7 20 "AutoThetaRankN" + autoTest 7 27 "AutoThetaRankN" autoTest 6 10 "AutoThetaGADT" autoTest 6 8 "AutoThetaGADTDestruct" autoTest 4 8 "AutoThetaEqCtx" diff --git a/plugins/hls-tactics-plugin/test/golden/AutoThetaRankN.expected.hs b/plugins/hls-tactics-plugin/test/golden/AutoThetaRankN.expected.hs index 3f0d534fe3..23d96223f3 100644 --- a/plugins/hls-tactics-plugin/test/golden/AutoThetaRankN.expected.hs +++ b/plugins/hls-tactics-plugin/test/golden/AutoThetaRankN.expected.hs @@ -4,5 +4,5 @@ showMe :: (forall x. Show x => x -> String) -> Int -> String showMe f = f showedYou :: Int -> String -showedYou = showMe show +showedYou = showMe (\x -> show x) diff --git a/plugins/hls-tactics-plugin/test/golden/AutoThetaRankN.hs b/plugins/hls-tactics-plugin/test/golden/AutoThetaRankN.hs index 8385d1ebcd..0e92ac35f3 100644 --- a/plugins/hls-tactics-plugin/test/golden/AutoThetaRankN.hs +++ b/plugins/hls-tactics-plugin/test/golden/AutoThetaRankN.hs @@ -4,5 +4,5 @@ showMe :: (forall x. Show x => x -> String) -> Int -> String showMe f = f showedYou :: Int -> String -showedYou = showMe _ +showedYou = showMe (\x -> _) From a208dda4363d281897ffeb1e266e84adf056286b Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Wed, 12 Jan 2022 15:22:04 -0800 Subject: [PATCH 11/31] Fix FmapJoin and FmapJoinInLet --- plugins/hls-tactics-plugin/test/Utils.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-tactics-plugin/test/Utils.hs b/plugins/hls-tactics-plugin/test/Utils.hs index 86f7438362..1e69eb7943 100644 --- a/plugins/hls-tactics-plugin/test/Utils.hs +++ b/plugins/hls-tactics-plugin/test/Utils.hs @@ -64,7 +64,7 @@ runSessionForTactics = runSessionWithServer' [plugin] def - (def { messageTimeout = 5 } ) + (def { messageTimeout = 8 } ) fullCaps tacticPath From 67ddf23e974091c8ad4496246a5efd3253910546 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Wed, 12 Jan 2022 15:37:42 -0800 Subject: [PATCH 12/31] Fix MetaBegin --- plugins/hls-tactics-plugin/src/Wingman/AbstractLSP.hs | 3 ++- plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/hls-tactics-plugin/src/Wingman/AbstractLSP.hs b/plugins/hls-tactics-plugin/src/Wingman/AbstractLSP.hs index 4e8200042a..c5d9ee6077 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/AbstractLSP.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/AbstractLSP.hs @@ -29,6 +29,7 @@ import Language.LSP.Types hiding (CodeLens, CodeAction) import Wingman.AbstractLSP.Types import Wingman.EmptyCase (fromMaybeT) import Wingman.LanguageServer (getTacticConfig, getIdeDynflags, mkWorkspaceEdits, runStaleIde, showLspMessage, mkShowMessageParams) +import Wingman.StaticPlugin (enableQuasiQuotes) import Wingman.Types @@ -109,7 +110,7 @@ runContinuation plId cont state (fc, b) = do GraftEdit gr -> do ccs <- lift getClientCapabilities TrackedStale pm _ <- mapMaybeT liftIO $ stale GetAnnotatedParsedSource - case mkWorkspaceEdits le_dflags ccs (fc_uri le_fileContext) (unTrack pm) gr of + case mkWorkspaceEdits (enableQuasiQuotes le_dflags) ccs (fc_uri le_fileContext) (unTrack pm) gr of Left errs -> pure $ Just $ ResponseError { _code = InternalError diff --git a/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs b/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs index ec84580fd4..ce7fb8863b 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs @@ -3,6 +3,7 @@ module Wingman.StaticPlugin ( staticPlugin , metaprogramHoleName + , enableQuasiQuotes , pattern WingmanMetaprogram , pattern MetaprogramSyntax ) where From 86d63ff5d7636dd33b5c747d7df32c735c102684 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Wed, 12 Jan 2022 15:44:59 -0800 Subject: [PATCH 13/31] Cleanup --- .../hls-tactics-plugin/src/Wingman/CodeGen.hs | 3 +-- .../hls-tactics-plugin/src/Wingman/Context.hs | 1 - .../src/Wingman/EmptyCase.hs | 2 +- plugins/hls-tactics-plugin/src/Wingman/GHC.hs | 2 -- .../hls-tactics-plugin/src/Wingman/Naming.hs | 1 - .../hls-tactics-plugin/src/Wingman/Tactics.hs | 2 +- .../test/UnificationSpec.hs | 1 - plugins/hls-tactics-plugin/test/Utils.hs | 19 +------------------ stack-9.0.1.yaml | 2 +- 9 files changed, 5 insertions(+), 28 deletions(-) diff --git a/plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs b/plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs index 5de84117ac..3b143d96ae 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs @@ -140,7 +140,6 @@ mkDestructPat already_in_scope con names in (names', ) $ ConPatIn (noLoc $ Unqual $ occName $ conLikeName con) - -- $ ConPat NoExtField (noLoc $ Unqual $ occName $ conLikeName con) $ RecCon $ HsRecFields rec_fields Nothing | otherwise = @@ -186,7 +185,7 @@ conLikeInstOrigArgTys' -- ^ Types of arguments to the ConLike with returned type is instantiated with the second argument. conLikeInstOrigArgTys' con uniTys = let exvars = conLikeExTys con - in map scaledThing $ conLikeInstOrigArgTys con $ + in fmap scaledThing $ conLikeInstOrigArgTys con $ uniTys ++ fmap mkTyVarTy exvars -- Rationale: At least in GHC <= 8.10, 'dataConInstOrigArgTys' -- unifies the second argument with DataCon's universals followed by existentials. diff --git a/plugins/hls-tactics-plugin/src/Wingman/Context.hs b/plugins/hls-tactics-plugin/src/Wingman/Context.hs index 2e3880893a..9aea0bf5eb 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Context.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Context.hs @@ -11,7 +11,6 @@ import Development.IDE.GHC.Compat.Util import Wingman.GHC (normalizeType) import Wingman.Judgements.Theta import Wingman.Types --- import GHC.Tc.Utils.TcType (tcSplitPhiTy, tcSplitTyConApp) mkContext diff --git a/plugins/hls-tactics-plugin/src/Wingman/EmptyCase.hs b/plugins/hls-tactics-plugin/src/Wingman/EmptyCase.hs index 15d8888c97..66f4847e93 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/EmptyCase.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/EmptyCase.hs @@ -87,7 +87,7 @@ scrutinzedType :: EmptyCaseSort Type -> Maybe Type scrutinzedType (EmptyCase ty) = pure ty scrutinzedType (EmptyLamCase ty) = case tacticsSplitFunTy ty of - (_, _, tys, _) -> listToMaybe $ map scaledThing tys + (_, _, tys, _) -> listToMaybe $ fmap scaledThing tys ------------------------------------------------------------------------------ diff --git a/plugins/hls-tactics-plugin/src/Wingman/GHC.hs b/plugins/hls-tactics-plugin/src/Wingman/GHC.hs index e837b77da1..66c65cdc6f 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/GHC.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/GHC.hs @@ -17,7 +17,6 @@ import Data.Traversable import Development.IDE.GHC.Compat import Development.IDE.GHC.Compat.Util import GHC.SourceGen (lambda) --- import GHC.Tc.Utils.TcType (tcSplitSigmaTy, tcSplitNestedSigmaTys, tcSplitFunTys, tyCoVarsOfTypeList) import Generics.SYB (Data, everything, everywhere, listify, mkQ, mkT) import Wingman.StaticPlugin (pattern MetaprogramSyntax) import Wingman.Types @@ -197,7 +196,6 @@ pattern SingleLet bind pats val expr <- HsLet _ (L _ (HsValBinds _ (ValBinds _ (bagToList -> - -- [L _ (FunBind _ (L _ bind) (MG _ (L _ [L _ (AMatch _ pats val)]) _) _ _)]) _))) [L _ (FunBind {fun_id = (L _ bind), fun_matches = (MG _ (L _ [L _ (AMatch _ pats val)]) _)})]) _))) (L _ expr) diff --git a/plugins/hls-tactics-plugin/src/Wingman/Naming.hs b/plugins/hls-tactics-plugin/src/Wingman/Naming.hs index 30062a2761..d664d30013 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Naming.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Naming.hs @@ -17,7 +17,6 @@ import Data.Traversable import Development.IDE.GHC.Compat.Core hiding (IsFunction) import Text.Hyphenation (hyphenate, english_US) import Wingman.GHC (tcTyVar_maybe) --- import GHC.Tc.Utils.TcType (tcSplitFunTys, isBoolTy, isIntegerTy, isIntTy, isFloatingTy, isStringTy, tcSplitAppTys) ------------------------------------------------------------------------------ diff --git a/plugins/hls-tactics-plugin/src/Wingman/Tactics.hs b/plugins/hls-tactics-plugin/src/Wingman/Tactics.hs index a1d2ab4bb7..6e27b05cd4 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Tactics.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Tactics.hs @@ -131,7 +131,7 @@ intros' params = rule $ \jdg -> do case tacticsSplitFunTy $ unCType g of (_, _, [], _) -> cut -- failure $ GoalMismatch "intros" g (_, _, scaledArgs, res) -> do - let args = map scaledThing scaledArgs + let args = fmap scaledThing scaledArgs ctx <- ask let gen_names = mkManyGoodNames (hyNamesInScope $ jEntireHypothesis jdg) args occs = case params of diff --git a/plugins/hls-tactics-plugin/test/UnificationSpec.hs b/plugins/hls-tactics-plugin/test/UnificationSpec.hs index 69ea9c2459..ba59e5ad63 100644 --- a/plugins/hls-tactics-plugin/test/UnificationSpec.hs +++ b/plugins/hls-tactics-plugin/test/UnificationSpec.hs @@ -18,7 +18,6 @@ import Test.QuickCheck import Wingman.GHC import Wingman.Machinery (newUnivar) import Wingman.Types --- import GHC.Tc.Utils.TcType (tcGetTyVar_maybe) spec :: Spec diff --git a/plugins/hls-tactics-plugin/test/Utils.hs b/plugins/hls-tactics-plugin/test/Utils.hs index 1e69eb7943..9c7bcd5133 100644 --- a/plugins/hls-tactics-plugin/test/Utils.hs +++ b/plugins/hls-tactics-plugin/test/Utils.hs @@ -118,7 +118,6 @@ mkGoldenTest eq tc occ line col input = -- use stale data will get uptodate stuff void $ waitForTypecheck doc actions <- getCodeActions doc $ pointRange line col --- <<<<<<< HEAD case find ((== Just (tacticTitle tc occ)) . codeActionTitle) actions of Just (InR CodeAction {_command = Just c}) -> do executeCommand c @@ -131,23 +130,7 @@ mkGoldenTest eq tc occ line col input = expected <- liftIO $ T.readFile expected_name liftIO $ edited `eq` expected _ -> error $ show actions --- ======= --- Just (InR CodeAction {_command = Just c}) --- <- pure $ find ((== Just (tacticTitle tc occ)) . codeActionTitle) actions --- executeCommand c --- resp <- skipManyTill anyMessage (Right <$> message SWorkspaceApplyEdit <|> Left <$> message SWindowShowMessage) --- case resp of --- Left nm -> liftIO $ expectationFailure $ "Expected WorkspaceApplyEdit.\nInstead got message:\n " ++ show (nm ^. params . J.message) --- Right _ -> pure () --- edited <- documentContents doc --- let expected_name = input <.> "expected" <.> "hs" --- -- Write golden tests if they don't already exist --- liftIO $ (doesFileExist expected_name >>=) $ flip unless $ do --- T.writeFile expected_name edited --- expected <- liftIO $ T.readFile expected_name --- liftIO $ edited `eq` expected - --- >>>>>>> 75a7d853084c8e83a3f8ea4d92799b5ade8ede3f + mkCodeLensTest :: FilePath diff --git a/stack-9.0.1.yaml b/stack-9.0.1.yaml index 80151b5382..53ac8f03df 100644 --- a/stack-9.0.1.yaml +++ b/stack-9.0.1.yaml @@ -93,6 +93,6 @@ flags: embed: true nix: - packages: [ icu libcxx zlib darwin.apple_sdk.frameworks.CoreServices darwin.apple_sdk.frameworks.Cocoa ] + packages: [ icu libcxx zlib ] concurrent-tests: false From ec8e439e6dfa06b1aefc366877e114fe89f4dec8 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Wed, 12 Jan 2022 15:50:04 -0800 Subject: [PATCH 14/31] Fix merge More fixing the merge No, seriously fix the merge Fix a broken merge --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 12 ++++++------ plugins/hls-tactics-plugin/src/Wingman/GHC.hs | 6 +----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index dec59f5d5c..18849e5e30 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -131,9 +131,8 @@ module Development.IDE.GHC.Compat.Core ( ), pattern FunTy, pattern ConPatIn, -#if !MIN_VERSION_ghc(9,2,0) Development.IDE.GHC.Compat.Core.splitForAllTyCoVars, -#endif +#if !MIN_VERSION_ghc(9,0,0) Development.IDE.GHC.Compat.Core.mkVisFunTys, Development.IDE.GHC.Compat.Core.mkInfForAllTys, #endif @@ -385,7 +384,7 @@ module Development.IDE.GHC.Compat.Core ( module GHC.Types.Var, module GHC.Unit.Module, module GHC.Utils.Error, - module TcType, + module TcType #else module BasicTypes, module Class, @@ -885,6 +884,7 @@ scaledThing = id unrestricted :: a -> Scaled a unrestricted = id +#endif mkVisFunTys :: [Scaled Type] -> Type -> Type mkVisFunTys = @@ -896,6 +896,9 @@ mkVisFunTys = mkInfForAllTys :: [TyVar] -> Type -> Type mkInfForAllTys = +#if MIN_VERSION_ghc(9,0,0) + TcType.mkInfForAllTys +#else mkInfForAllTys #endif @@ -957,14 +960,12 @@ type PlainGhcException = Plain.PlainGhcException type PlainGhcException = Plain.GhcException #endif -<<<<<<< HEAD #if MIN_VERSION_ghc(9,0,0) -- This is from the old api, but it still simplifies pattern ConPatIn :: SrcLoc.Located (ConLikeP GhcPs) -> HsConPatDetails GhcPs -> Pat GhcPs pattern ConPatIn con args = ConPat NoExtField con args #endif -======= initDynLinker, initObjLinker :: HscEnv -> IO () initDynLinker = #if !MIN_VERSION_ghc(9,0,0) @@ -1061,4 +1062,3 @@ collectHsBindsBinders x = GHC.collectHsBindsBinders CollNoDictBinders x pattern HsLet xlet localBinds expr <- GHC.HsLet xlet (SrcLoc.unLoc -> localBinds) expr pattern LetStmt xlet localBinds <- GHC.LetStmt xlet (SrcLoc.unLoc -> localBinds) #endif ->>>>>>> master diff --git a/plugins/hls-tactics-plugin/src/Wingman/GHC.hs b/plugins/hls-tactics-plugin/src/Wingman/GHC.hs index 0b366f92ae..d0423b8904 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/GHC.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/GHC.hs @@ -196,11 +196,7 @@ pattern SingleLet bind pats val expr <- HsLet _ (HsValBinds _ (ValBinds _ (bagToList -> -<<<<<<< HEAD - [L _ (FunBind {fun_id = (L _ bind), fun_matches = (MG _ (L _ [L _ (AMatch _ pats val)]) _)})]) _))) -======= - [(L _ (FunBind _ (L _ bind) (MG _ (L _ [L _ (AMatch _ pats val)]) _) _ _))]) _)) ->>>>>>> master + [L _ (FunBind {fun_id = (L _ bind), fun_matches = (MG _ (L _ [L _ (AMatch _ pats val)]) _)})]) _)) (L _ expr) From 21779f90f5b36af6b40df3ad5efc081cab87305d Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Thu, 13 Jan 2022 10:24:37 -0800 Subject: [PATCH 15/31] Need a comma --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 18849e5e30..43cd236996 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -384,7 +384,7 @@ module Development.IDE.GHC.Compat.Core ( module GHC.Types.Var, module GHC.Unit.Module, module GHC.Utils.Error, - module TcType + module TcType, #else module BasicTypes, module Class, From a812243413bc2f0125c828dba64bbe329f5ea6ea Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Sun, 16 Jan 2022 11:52:23 -0800 Subject: [PATCH 16/31] Try a better ConPatIn --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 43cd236996..06e4f11b99 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -541,6 +541,7 @@ import GHC.Parser.Header hiding (getImports) import qualified GHC.Linker.Loader as Linker import GHC.Linker.Types import GHC.Parser.Lexer hiding (initParserState) +import GHC.Parser.Annotation (EpAnn (..)) import GHC.Platform.Ways import GHC.Runtime.Context (InteractiveImport (..)) #else @@ -963,7 +964,13 @@ type PlainGhcException = Plain.GhcException #if MIN_VERSION_ghc(9,0,0) -- This is from the old api, but it still simplifies pattern ConPatIn :: SrcLoc.Located (ConLikeP GhcPs) -> HsConPatDetails GhcPs -> Pat GhcPs -pattern ConPatIn con args = ConPat NoExtField con args +pattern ConPatIn con args = ConPat +#if MIN_VERSION_ghc(9,0,2) + EpAnnNotUsed +#else + NoExtField +#endif + con args #endif initDynLinker, initObjLinker :: HscEnv -> IO () From 1440350dea5c21c5d01db785f90167669b3afb5e Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Sun, 16 Jan 2022 12:04:04 -0800 Subject: [PATCH 17/31] Oops --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 06e4f11b99..0d25239aa3 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -965,7 +965,7 @@ type PlainGhcException = Plain.GhcException -- This is from the old api, but it still simplifies pattern ConPatIn :: SrcLoc.Located (ConLikeP GhcPs) -> HsConPatDetails GhcPs -> Pat GhcPs pattern ConPatIn con args = ConPat -#if MIN_VERSION_ghc(9,0,2) +#if MIN_VERSION_ghc(9,2,0) EpAnnNotUsed #else NoExtField From fe01a29dc018a49a42e1b632a1513f8bf29a0e95 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Sun, 16 Jan 2022 14:00:22 -0800 Subject: [PATCH 18/31] its a nightmare --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 0d25239aa3..0723e442fd 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -964,13 +964,13 @@ type PlainGhcException = Plain.GhcException #if MIN_VERSION_ghc(9,0,0) -- This is from the old api, but it still simplifies pattern ConPatIn :: SrcLoc.Located (ConLikeP GhcPs) -> HsConPatDetails GhcPs -> Pat GhcPs -pattern ConPatIn con args = ConPat #if MIN_VERSION_ghc(9,2,0) - EpAnnNotUsed +pattern ConPatIn con args <- ConPat EpAnnNotUsed (L _ (noLoc -> e)) con args + where + ConPatIn con args = ConPat EpAnnNotUsed (noLocA $ unLoc con) #else - NoExtField +pattern ConPatIn con args = ConPat NoExtField con args #endif - con args #endif initDynLinker, initObjLinker :: HscEnv -> IO () From b72ee1abdf59f89570bbde27317ba8649950e1b6 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Sun, 16 Jan 2022 14:40:14 -0800 Subject: [PATCH 19/31] i hate ci --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 0723e442fd..44e597f0b3 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -965,7 +965,7 @@ type PlainGhcException = Plain.GhcException -- This is from the old api, but it still simplifies pattern ConPatIn :: SrcLoc.Located (ConLikeP GhcPs) -> HsConPatDetails GhcPs -> Pat GhcPs #if MIN_VERSION_ghc(9,2,0) -pattern ConPatIn con args <- ConPat EpAnnNotUsed (L _ (noLoc -> e)) con args +pattern ConPatIn con args <- ConPat EpAnnNotUsed (L _ (noLoc -> con)) args where ConPatIn con args = ConPat EpAnnNotUsed (noLocA $ unLoc con) #else From 8d1a05209da44b83dcea7b69fac443b2f718b618 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Mon, 17 Jan 2022 11:20:46 -0800 Subject: [PATCH 20/31] ok that fixes the conpat --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 44e597f0b3..e024508662 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -965,9 +965,9 @@ type PlainGhcException = Plain.GhcException -- This is from the old api, but it still simplifies pattern ConPatIn :: SrcLoc.Located (ConLikeP GhcPs) -> HsConPatDetails GhcPs -> Pat GhcPs #if MIN_VERSION_ghc(9,2,0) -pattern ConPatIn con args <- ConPat EpAnnNotUsed (L _ (noLoc -> con)) args +pattern ConPatIn con args <- ConPat EpAnnNotUsed (L _ (SrcLoc.noLoc -> con)) args where - ConPatIn con args = ConPat EpAnnNotUsed (noLocA $ unLoc con) + ConPatIn con args = ConPat EpAnnNotUsed (GHC.noLocA $ SrcLoc.unLoc con) args #else pattern ConPatIn con args = ConPat NoExtField con args #endif From c0082bc56e9654ca3562bc9e2f0074d0c5606405 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Mon, 17 Jan 2022 11:25:04 -0800 Subject: [PATCH 21/31] Maybe this is the end of it --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index e024508662..b3db602504 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -131,8 +131,8 @@ module Development.IDE.GHC.Compat.Core ( ), pattern FunTy, pattern ConPatIn, - Development.IDE.GHC.Compat.Core.splitForAllTyCoVars, #if !MIN_VERSION_ghc(9,0,0) + Development.IDE.GHC.Compat.Core.splitForAllTyCoVars, Development.IDE.GHC.Compat.Core.mkVisFunTys, Development.IDE.GHC.Compat.Core.mkInfForAllTys, #endif @@ -379,12 +379,13 @@ module Development.IDE.GHC.Compat.Core ( module GHC.Types.SourceText, module GHC.Types.TyThing, module GHC.Types.TyThing.Ppr, +#else + module TcType, #endif module GHC.Types.Unique.Supply, module GHC.Types.Var, module GHC.Unit.Module, module GHC.Utils.Error, - module TcType, #else module BasicTypes, module Class, From 254f8e460c81d63930ccdfa88314f5bc62f242cf Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Mon, 17 Jan 2022 11:29:21 -0800 Subject: [PATCH 22/31] ci --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index b3db602504..5de2ab45cb 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -131,8 +131,10 @@ module Development.IDE.GHC.Compat.Core ( ), pattern FunTy, pattern ConPatIn, -#if !MIN_VERSION_ghc(9,0,0) +#if !MIN_VERSION_ghc(9,2,0) Development.IDE.GHC.Compat.Core.splitForAllTyCoVars, +#endif +#if !MIN_VERSION_ghc(9,0,0) Development.IDE.GHC.Compat.Core.mkVisFunTys, Development.IDE.GHC.Compat.Core.mkInfForAllTys, #endif From c0e67f232e94733f9418c87a4abd4dae093fd34a Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Mon, 17 Jan 2022 11:31:35 -0800 Subject: [PATCH 23/31] refinery --- stack-9.0.1.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/stack-9.0.1.yaml b/stack-9.0.1.yaml index 8cac58d6a9..bda42f3e00 100644 --- a/stack-9.0.1.yaml +++ b/stack-9.0.1.yaml @@ -49,6 +49,7 @@ extra-deps: - monad-dijkstra-0.1.1.3 - multistate-0.8.0.3 - retrie-1.1.0.0 +- refinery-0.4.0.0 # shake-bench dependencies - Chart-1.9.3 From 8d285a6d91d9f86a18f8d25f290de48cc32b09f4 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Mon, 17 Jan 2022 11:34:22 -0800 Subject: [PATCH 24/31] undo some changes --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 5de2ab45cb..dd9f205565 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -134,10 +134,8 @@ module Development.IDE.GHC.Compat.Core ( #if !MIN_VERSION_ghc(9,2,0) Development.IDE.GHC.Compat.Core.splitForAllTyCoVars, #endif -#if !MIN_VERSION_ghc(9,0,0) Development.IDE.GHC.Compat.Core.mkVisFunTys, Development.IDE.GHC.Compat.Core.mkInfForAllTys, -#endif -- * Specs ImpDeclSpec(..), ImportSpec(..), @@ -903,7 +901,7 @@ mkInfForAllTys = #if MIN_VERSION_ghc(9,0,0) TcType.mkInfForAllTys #else - mkInfForAllTys + mkInvForAllTys #endif #if !MIN_VERSION_ghc(9,2,0) From 1700d9b3349b3a8f796c54184b9b9b92558146f2 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Mon, 17 Jan 2022 11:37:38 -0800 Subject: [PATCH 25/31] no more tctypes? --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index dd9f205565..c16bf177ed 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -379,8 +379,6 @@ module Development.IDE.GHC.Compat.Core ( module GHC.Types.SourceText, module GHC.Types.TyThing, module GHC.Types.TyThing.Ppr, -#else - module TcType, #endif module GHC.Types.Unique.Supply, module GHC.Types.Var, From 168d9189fb1fbd422cb213d90c466d4c62e68a70 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Mon, 17 Jan 2022 14:00:37 -0800 Subject: [PATCH 26/31] maybe it builds now --- plugins/hls-tactics-plugin/src/Wingman/Context.hs | 6 ++++++ plugins/hls-tactics-plugin/src/Wingman/GHC.hs | 4 ++++ plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs | 4 ++++ plugins/hls-tactics-plugin/src/Wingman/Naming.hs | 6 ++++++ 4 files changed, 20 insertions(+) diff --git a/plugins/hls-tactics-plugin/src/Wingman/Context.hs b/plugins/hls-tactics-plugin/src/Wingman/Context.hs index 9aea0bf5eb..3c1b40ba1f 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Context.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Context.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + module Wingman.Context where import Control.Arrow @@ -12,6 +14,10 @@ import Wingman.GHC (normalizeType) import Wingman.Judgements.Theta import Wingman.Types +#if __GLASGOW_HASKELL__ >= 900 +import GHC.Tc.Utils.TcType +#endif + mkContext :: Config diff --git a/plugins/hls-tactics-plugin/src/Wingman/GHC.hs b/plugins/hls-tactics-plugin/src/Wingman/GHC.hs index d0423b8904..8a2da92770 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/GHC.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/GHC.hs @@ -21,6 +21,10 @@ import Generics.SYB (Data, everything, everywhere, listify, mkQ, mkT) import Wingman.StaticPlugin (pattern MetaprogramSyntax) import Wingman.Types +#if __GLASGOW_HASKELL__ >= 900 +import GHC.Tc.Utils.TcType +#endif + tcTyVar_maybe :: Type -> Maybe Var tcTyVar_maybe ty | Just ty' <- tcView ty = tcTyVar_maybe ty' diff --git a/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs b/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs index 9682c6e078..f1731a8a33 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs @@ -26,6 +26,10 @@ import GHC.Generics import Wingman.GHC import Wingman.Types +#if __GLASGOW_HASKELL__ >= 900 +import GHC.Tc.Utils.TcType +#endif + ------------------------------------------------------------------------------ -- | Something we've learned about the type environment. diff --git a/plugins/hls-tactics-plugin/src/Wingman/Naming.hs b/plugins/hls-tactics-plugin/src/Wingman/Naming.hs index d664d30013..ab0c0e23d9 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Naming.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Naming.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + module Wingman.Naming where import Control.Arrow @@ -18,6 +20,10 @@ import Development.IDE.GHC.Compat.Core hiding (IsFunction) import Text.Hyphenation (hyphenate, english_US) import Wingman.GHC (tcTyVar_maybe) +#if __GLASGOW_HASKELL__ >= 900 +import GHC.Tc.Utils.TcType +#endif + ------------------------------------------------------------------------------ -- | A classification of a variable, for which we have specific naming rules. From df025eac8847eb3793f1ac2951883cbe16df1b7e Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Mon, 17 Jan 2022 14:20:55 -0800 Subject: [PATCH 27/31] omg --- plugins/hls-tactics-plugin/test/UnificationSpec.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/hls-tactics-plugin/test/UnificationSpec.hs b/plugins/hls-tactics-plugin/test/UnificationSpec.hs index ba59e5ad63..a4ccc4b887 100644 --- a/plugins/hls-tactics-plugin/test/UnificationSpec.hs +++ b/plugins/hls-tactics-plugin/test/UnificationSpec.hs @@ -12,13 +12,19 @@ import Data.Maybe (mapMaybe) import qualified Data.Set as S import Data.Traversable import Data.Tuple (swap) -import Development.IDE.GHC.Compat.Core (substTy, tcGetTyVar_maybe, mkBoxedTupleTy) +import Development.IDE.GHC.Compat.Core (substTy, mkBoxedTupleTy) import Test.Hspec import Test.QuickCheck import Wingman.GHC import Wingman.Machinery (newUnivar) import Wingman.Types +#if __GLASGOW_HASKELL__ >= 900 +import GHC.Tc.Utils.TcType (tcGetTyVar_maybe) +#else +import TcType (tcGetTyVar_maybe) +#endif + spec :: Spec spec = describe "unification" $ do From 449a4512076bb7f06e936e8f34de7f8faf449140 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Mon, 17 Jan 2022 15:19:38 -0800 Subject: [PATCH 28/31] om F g --- plugins/hls-tactics-plugin/test/UnificationSpec.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/hls-tactics-plugin/test/UnificationSpec.hs b/plugins/hls-tactics-plugin/test/UnificationSpec.hs index a4ccc4b887..148a40eaaa 100644 --- a/plugins/hls-tactics-plugin/test/UnificationSpec.hs +++ b/plugins/hls-tactics-plugin/test/UnificationSpec.hs @@ -1,4 +1,6 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE ViewPatterns #-} + {-# OPTIONS_GHC -fno-warn-orphans #-} module UnificationSpec where From 688d94697cc7db2f457caf900ce23a10cd8b63bb Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Tue, 18 Jan 2022 02:04:51 -0800 Subject: [PATCH 29/31] expect fail on 9.2 --- test/functional/FunctionalCodeAction.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index d5fca07afc..854dc41187 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -231,7 +231,8 @@ typedHoleTests = testGroup "typed hole code actions" [ , "foo x = maxBound" ] - , testCase "doesn't work when wingman is active" $ + , 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" @@ -265,7 +266,8 @@ typedHoleTests = testGroup "typed hole code actions" [ , " stuff (A a) = A (a + 1)" ] - , testCase "doesnt show more suggestions when wingman is active" $ + , expectFailIfGhc92 "The wingman plugin doesn't yet compile in GHC92" $ + testCase "doesnt show more suggestions when wingman is active" $ runSession hlsCommand fullCaps "test/testdata" $ do doc <- openDoc "TypedHoles2.hs" "haskell" _ <- waitForDiagnosticsFromSource doc "typecheck" @@ -353,6 +355,12 @@ unusedTermTests = testGroup "unused term code actions" [ $ Just CodeActionQuickFix `notElem` kinds ] +expectFailIfGhc92 :: String -> TestTree -> TestTree +expectFailIfGhc92 reason = + case ghcVersion of + GHC92 -> expectFailBecause reason + _ -> id + disableWingman :: Session () disableWingman = sendConfigurationChanged $ toJSON $ def From a22dd48ef5904db5c0f997528230fc900739aa54 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Tue, 18 Jan 2022 19:17:59 -0800 Subject: [PATCH 30/31] fix --- plugins/hls-tactics-plugin/test/Utils.hs | 2 +- test/functional/FunctionalCodeAction.hs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/hls-tactics-plugin/test/Utils.hs b/plugins/hls-tactics-plugin/test/Utils.hs index c1bb308b01..08ecb83c2e 100644 --- a/plugins/hls-tactics-plugin/test/Utils.hs +++ b/plugins/hls-tactics-plugin/test/Utils.hs @@ -65,7 +65,7 @@ runSessionForTactics = runSessionWithServer' [plugin] def - (def { messageTimeout = 8 } ) + (def { messageTimeout = 20 } ) fullCaps tacticPath diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index 854dc41187..bde29dd75d 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -356,10 +356,7 @@ unusedTermTests = testGroup "unused term code actions" [ ] expectFailIfGhc92 :: String -> TestTree -> TestTree -expectFailIfGhc92 reason = - case ghcVersion of - GHC92 -> expectFailBecause reason - _ -> id +expectFailIfGhc92 _ = knownBrokenForGhcVersions [GHC92] disableWingman :: Session () disableWingman = From 30723f716e3e49a5f6f9c5bfa7ad97364acdfa30 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Tue, 18 Jan 2022 19:59:54 -0800 Subject: [PATCH 31/31] fix again --- test/functional/FunctionalCodeAction.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index bde29dd75d..fd12fe39d1 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -356,7 +356,7 @@ unusedTermTests = testGroup "unused term code actions" [ ] expectFailIfGhc92 :: String -> TestTree -> TestTree -expectFailIfGhc92 _ = knownBrokenForGhcVersions [GHC92] +expectFailIfGhc92 = knownBrokenForGhcVersions [GHC92] disableWingman :: Session () disableWingman =