Skip to content

Commit

Permalink
support GHC 9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
tek committed Apr 9, 2023
1 parent 87d7439 commit 9ec6e33
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 43 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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;
});
Expand Down
15 changes: 11 additions & 4 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
6 changes: 3 additions & 3 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions polysemy-plugin/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions polysemy-plugin/polysemy-plugin.cabal
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
27 changes: 19 additions & 8 deletions polysemy-plugin/src/Polysemy/Plugin/Fundep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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 =
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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


------------------------------------------------------------------------------
Expand Down
12 changes: 10 additions & 2 deletions polysemy-plugin/src/Polysemy/Plugin/Fundep/Unification.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -64,7 +72,7 @@ unify
:: SolveContext
-> Type -- ^ wanted
-> Type -- ^ given
-> Maybe TCvSubst
-> Maybe SUBST
unify solve_ctx = tryUnifyUnivarsButNotSkolems skolems
where
skolems :: Set TyVar
Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions polysemy.cabal
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -106,18 +106,18 @@ 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
TypeInType
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
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit 9ec6e33

Please sign in to comment.