support GHC 9.6

This commit is contained in:
Torsten Schmits 2023-04-06 20:22:42 +02:00 committed by Torsten Schmits
parent 87d7439561
commit 9ec6e337d0
9 changed files with 71 additions and 43 deletions

View File

@ -57,11 +57,11 @@
},
"unstable": {
"locked": {
"lastModified": 1672057183,
"narHash": "sha256-GN7/10DNNvs1FPj9tlZA2qgNdFuYKKuS3qlHTqAxasQ=",
"lastModified": 1680728981,
"narHash": "sha256-ZhsViPJJvET7iLyD9ey63q6GwPKquDqIbOn2letvb/A=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b139e44d78c36c69bcbb825b20dbfa51e7738347",
"rev": "38263d02cf3a22e011e137b8f67cdf8419f28015",
"type": "github"
},
"original": {

View File

@ -17,10 +17,11 @@
ghcs = {
"865" = hsPkgs nixpkgs_2009 "ghc865";
"884" = hsPkgs nixpkgs_2105 "ghc884";
"8107" = hsPkgs unstable "ghc8107";
"902" = hsPkgs unstable "ghc902";
"925" = hsPkgs unstable "ghc925";
"943" = hsPkgs unstable "ghc943";
"810" = hsPkgs unstable "ghc810";
"90" = hsPkgs unstable "ghc90";
"92" = hsPkgs unstable "ghc92";
"94" = hsPkgs unstable "ghc94";
"96" = hsPkgs unstable "ghc96";
};
mkPackages = version: {
@ -29,27 +30,28 @@
};
defaultPackages = {
inherit (ghcs."902") polysemy polysemy-plugin;
default = ghcs."902".polysemy;
inherit (ghcs."92") polysemy polysemy-plugin;
default = ghcs."92".polysemy;
};
packages = foldl' (l: r: l // r) defaultPackages (map mkPackages (attrNames ghcs));
mkDevShell = ghc: ghc.shellFor {
mkDevShell = name: ghc: ghc.shellFor {
packages = p: [p.polysemy p.polysemy-plugin];
buildInputs = with ghc; [
cabal-install
] ++ unstable.lib.optionals (name != "96") [
(ghc.pkgs.haskell.lib.dontCheck ghcid)
haskell-language-server
];
};
devShells = mapAttrs' (n: g: nameValuePair "ghc${n}" (mkDevShell g)) ghcs;
devShells = mapAttrs' (n: g: nameValuePair "ghc${n}" (mkDevShell n g)) ghcs;
in {
inherit packages;
devShells = devShells // { default = devShells.ghc902; };
devShells = devShells // { default = devShells.ghc92; };
checks = packages;
});

View File

@ -4,16 +4,23 @@
compiler,
}:
let
overrides = pkgs: self: super:
pkgs = import nixpkgs { inherit system; };
overrides = self: super:
let
filter = pkgs.nix-gitignore.gitignoreSourcePure [./source-filter];
c2n = name: src: pkgs.haskell.lib.disableLibraryProfiling (self.callCabal2nix name (filter src) {});
in {
polysemy = c2n "polysemy" ../.;
polysemy-plugin = c2n "polysemy-plugin" ../polysemy-plugin;
} // pkgs.lib.optionalAttrs (compiler == "ghc96") {
type-errors = self.callHackageDirect {
pkg = "type-errors";
ver = "0.2.0.2";
sha256 = "sha256-z/QANg5jUhSc02IBVQEsg7QemiyV3XdwxN9K1CH2Myc=";
} {};
};
pkgs = import nixpkgs { inherit system; };
in
pkgs.haskell.packages.${compiler}.override { overrides = overrides pkgs; } // { inherit pkgs; }
pkgs.haskell.packages.${compiler}.override { inherit overrides; } // { inherit pkgs; }

View File

@ -23,8 +23,8 @@ dependencies:
- syb >= 0.7 && < 0.8
- stm >= 2 && < 3
- template-haskell >= 2.12.0.0 && < 3
- th-abstraction >= 0.3.1.0 && < 0.5
- transformers >= 0.5.2.0 && < 0.6
- th-abstraction >= 0.3.1.0 && < 0.6
- transformers >= 0.5.2.0 && < 0.7
- first-class-families >= 0.5.0.0 && < 0.9
- unagi-chan >= 0.4.0.0 && < 0.5
- async >= 2.2 && < 3
@ -82,7 +82,7 @@ tests:
- polysemy
- inspection-testing >= 0.4.2 && < 0.6
- hspec >= 2.6.0 && < 3
- doctest >= 0.16.0.1 && < 0.21
- doctest >= 0.16.0.1 && < 0.22
- hspec-discover >= 2.0
generated-other-modules:
- Build_doctests

View File

@ -22,7 +22,7 @@ dependencies:
- ghc-tcplugins-extra >= 0.3 && < 0.5
- polysemy >= 1.7
- syb >= 0.7 && < 0.8
- transformers >= 0.5.2.0 && < 0.6
- transformers >= 0.5.2.0 && < 0.7
- containers >= 0.5 && < 0.7
custom-setup:
@ -63,7 +63,7 @@ tests:
- hspec >= 2.6.0 && < 3
- should-not-typecheck >= 2.1.0 && < 3
- inspection-testing >= 0.4.2 && < 0.6
- doctest >= 0.16.0.1 && < 0.21
- doctest >= 0.16.0.1 && < 0.22
generated-other-modules:
- Build_doctests

View File

@ -1,6 +1,6 @@
cabal-version: 2.0
-- This file has been generated from package.yaml by hpack version 0.35.0.
-- This file has been generated from package.yaml by hpack version 0.35.1.
--
-- see: https://github.com/sol/hpack
@ -70,7 +70,7 @@ library
, ghc-tcplugins-extra >=0.3 && <0.5
, polysemy >=1.7
, syb ==0.7.*
, transformers >=0.5.2.0 && <0.6
, transformers >=0.5.2.0 && <0.7
default-language: Haskell2010
test-suite polysemy-plugin-test
@ -111,7 +111,7 @@ test-suite polysemy-plugin-test
build-depends:
base >=4.9 && <5
, containers >=0.5 && <0.7
, doctest >=0.16.0.1 && <0.21
, doctest >=0.16.0.1 && <0.22
, ghc >=8.6.5 && <10
, ghc-tcplugins-extra >=0.3 && <0.5
, hspec >=2.6.0 && <3
@ -121,7 +121,7 @@ test-suite polysemy-plugin-test
, polysemy-plugin
, should-not-typecheck >=2.1.0 && <3
, syb ==0.7.*
, transformers >=0.5.2.0 && <0.6
, transformers >=0.5.2.0 && <0.7
default-language: Haskell2010
if flag(corelint)
ghc-options: -dcore-lint -dsuppress-all

View File

@ -52,6 +52,16 @@ import Polysemy.Plugin.Fundep.Stuff
import Polysemy.Plugin.Fundep.Unification
import Polysemy.Plugin.Fundep.Utils
#if __GLASGOW_HASKELL__ >= 906
#define SUBST Subst
#define GET_TYVAR getTyVar_maybe
import GHC.Core.TyCo.Subst (SUBST)
import GHC.Core.TyCo.Compare (eqType, nonDetCmpType)
#else
#define SUBST TCvSubst
#define GET_TYVAR tcGetTyVar_maybe
#endif
#if __GLASGOW_HASKELL__ >= 900
import GHC.Builtin.Types.Prim (alphaTys)
import GHC.Plugins (idType, tyConClass_maybe, ppr, Outputable, sep, text, (<+>), parens, emptyUFM)
@ -60,7 +70,7 @@ import GHC.Tc.Plugin (TcPluginM, tcPluginIO)
import GHC.Tc.Types
import GHC.Tc.Types.Constraint
import GHC.Tc.Utils.Env (tcGetInstEnvs)
import GHC.Tc.Utils.TcType (tcSplitPhiTy, tcSplitTyConApp, tcGetTyVar_maybe, tcSplitAppTy_maybe)
import GHC.Tc.Utils.TcType (tcSplitPhiTy, tcSplitTyConApp, GET_TYVAR, tcSplitAppTy_maybe)
import GHC.Tc.Solver.Monad hiding (tcLookupClass)
import GHC.Core.Class (classTyCon)
import GHC.Core.InstEnv (lookupInstEnv, is_dfun)
@ -80,14 +90,12 @@ import MonadUtils (allM, anyM)
import TcEvidence
import TcPluginM (tcPluginIO)
import TcRnTypes
import TcType (tcSplitPhiTy, tcSplitTyConApp, tcGetTyVar_maybe, tcSplitAppTy_maybe)
import TcType (tcSplitPhiTy, tcSplitTyConApp, GET_TYVAR, tcSplitAppTy_maybe)
import TcSMonad hiding (tcLookupClass)
import Type
import TysPrim (alphaTys)
#endif
fundepPlugin :: TcPlugin
fundepPlugin = TcPlugin
{ tcPluginInit =
@ -193,12 +201,15 @@ findMatchingEffectIfSingular
True -> pure $ Just eff
False -> pure Nothing
------------------------------------------------------------------------------
-- | @checkExtraEvidence givens subst c@ returns 'True' iff we can prove that
-- the constraint @c@ holds under the substitution @subst@ in the context of
-- @givens@.
checkExtraEvidence :: Set PredType' -> TCvSubst -> PredType -> TcM Bool
checkExtraEvidence ::
Set PredType' ->
SUBST ->
PredType ->
TcM Bool
checkExtraEvidence givens subst = flip evalStateT givens . getInstance . substTy subst
@ -240,8 +251,8 @@ mkWantedForce fc given = do
skolemsForInterpreter :: Type -> Set TyVar
skolemsForInterpreter ty =
case tcSplitAppTy_maybe ty of
Just (tcGetTyVar_maybe -> Just skolem, _) -> S.singleton skolem
_ -> maybe mempty S.singleton $ tcGetTyVar_maybe ty
Just (GET_TYVAR -> Just skolem, _) -> S.singleton skolem
_ -> maybe mempty S.singleton $ GET_TYVAR ty
------------------------------------------------------------------------------

View File

@ -25,6 +25,14 @@ import Unify
import GhcPlugins (Outputable, ppr, parens, text, (<+>))
#endif
#if __GLASGOW_HASKELL__ >= 906
#define SUBST Subst
import GHC.Core.TyCo.Subst (SUBST)
import GHC.Core.TyCo.Compare (eqType, nonDetCmpType)
#else
#define SUBST TCvSubst
#endif
------------------------------------------------------------------------------
-- | The context in which we're attempting to solve a constraint.
@ -64,7 +72,7 @@ unify
:: SolveContext
-> Type -- ^ wanted
-> Type -- ^ given
-> Maybe TCvSubst
-> Maybe SUBST
unify solve_ctx = tryUnifyUnivarsButNotSkolems skolems
where
skolems :: Set TyVar
@ -81,7 +89,7 @@ unify solve_ctx = tryUnifyUnivarsButNotSkolems skolems
#define APART Skolem
#endif
tryUnifyUnivarsButNotSkolems :: Set TyVar -> Type -> Type -> Maybe TCvSubst
tryUnifyUnivarsButNotSkolems :: Set TyVar -> Type -> Type -> Maybe SUBST
tryUnifyUnivarsButNotSkolems skolems goal inst =
case tcUnifyTysFG
(bool BINDME APART . flip S.member skolems)

View File

@ -1,6 +1,6 @@
cabal-version: 2.0
-- This file has been generated from package.yaml by hpack version 0.34.7.
-- This file has been generated from package.yaml by hpack version 0.35.1.
--
-- see: https://github.com/sol/hpack
@ -106,10 +106,11 @@ library
, stm ==2.*
, syb ==0.7.*
, template-haskell >=2.12.0.0 && <3
, th-abstraction >=0.3.1.0 && <0.5
, transformers >=0.5.2.0 && <0.6
, th-abstraction >=0.3.1.0 && <0.6
, transformers >=0.5.2.0 && <0.7
, type-errors >=0.2.0.0
, unagi-chan >=0.4.0.0 && <0.5
default-language: Haskell2010
if impl(ghc < 8.6)
default-extensions:
MonadFailDesugaring
@ -117,7 +118,6 @@ library
if impl(ghc < 8.2.2)
build-depends:
unsupported-ghc-version >1 && <1
default-language: Haskell2010
test-suite polysemy-test
type: exitcode-stdio-1.0
@ -167,7 +167,7 @@ test-suite polysemy-test
async >=2.2 && <3
, base >=4.9 && <5
, containers >=0.5 && <0.7
, doctest >=0.16.0.1 && <0.21
, doctest >=0.16.0.1 && <0.22
, first-class-families >=0.5.0.0 && <0.9
, hspec >=2.6.0 && <3
, hspec-discover >=2.0
@ -177,12 +177,12 @@ test-suite polysemy-test
, stm ==2.*
, syb ==0.7.*
, template-haskell >=2.12.0.0 && <3
, th-abstraction >=0.3.1.0 && <0.5
, transformers >=0.5.2.0 && <0.6
, th-abstraction >=0.3.1.0 && <0.6
, transformers >=0.5.2.0 && <0.7
, type-errors >=0.2.0.0
, unagi-chan >=0.4.0.0 && <0.5
default-language: Haskell2010
if impl(ghc < 8.6)
default-extensions:
MonadFailDesugaring
TypeInType
default-language: Haskell2010