Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GHC 9.12 support #8

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 59 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,64 @@ jobs:
strategy:
matrix:
cfg:
- { os: ubuntu-latest , ghc: "9.6.2" }
- { os: ubuntu-latest , ghc: "9.4.7" }
- { os: ubuntu-latest , ghc: "9.2.8" }
- { os: ubuntu-latest , ghc: "9.2.3" }
- { os: ubuntu-latest , ghc: "9.0.2" }
- { os: ubuntu-latest , ghc: "8.10.7" }
- { os: ubuntu-latest , ghc: "8.8.4" }
- { os: macOS-latest , ghc: "9.6.2" }
- { os: windows-latest , ghc: "9.6.2" }
- { os: ubuntu-latest , ghc: "9.10.1" }
- { os: ubuntu-latest , ghc: "9.8.2" }
- { os: ubuntu-latest , ghc: "9.6.2" }
- { os: ubuntu-latest , ghc: "9.4.7" }
- { os: ubuntu-latest , ghc: "9.2.8" }
- { os: ubuntu-latest , ghc: "9.0.2" }
- { os: ubuntu-latest , ghc: "8.10.7" }
- { os: ubuntu-latest , ghc: "8.8.4" }
- { os: macOS-latest , ghc: "9.10.1" }
- { os: windows-latest , ghc: "9.10.1" }

steps:
- name: Checkout commit
uses: actions/checkout@v3
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main'

- name: Set up GHC & cabal
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.cfg.ghc }}
cabal-version: ${{ matrix.cfg.cabal }}

- name: Build ghc-tcplugin-api
run: cabal build ghc-tcplugin-api

- name: Build and lint System F example
# Skip this test on GHC 8.8.4: we need StandaloneKindSignatures.
if: matrix.cfg.ghc != '8.8.4'
working-directory: ./examples/SystemF
run: cabal build system-f
- uses: actions/checkout@v4

- name: Set up GHC ${{ matrix.cfg.ghc }}
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.cfg.ghc }}
# Defaults, added for clarity:
cabal-version: 'latest'
cabal-update: true

- name: Configure the build
run: |
cabal configure --disable-documentation
cabal build all --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.

- name: Restore cached dependencies
uses: actions/cache/restore@v4
id: cache
env:
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-

- name: Install dependencies
# If we had an exact cache hit, the dependencies will be up to date.
if: steps.cache.outputs.cache-hit != 'true'
run: cabal build all --only-dependencies

# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: Save cached dependencies
uses: actions/cache/save@v4
# If we had an exact cache hit, trying to save the cache would error because of key clash.
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build ghc-tcplugin-api
run: cabal build ghc-tcplugin-api

- name: Build and lint System F example
# Skip this test on GHC 8.8.4: we need StandaloneKindSignatures.
if: matrix.cfg.ghc != '8.8.4'
working-directory: ./examples/SystemF
run: cabal build system-f
15 changes: 15 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Version 0.12.0.0 (2024-22-10)

- Add support for GHC 9.12.

- `mkPluginUnivCo`, `mkPluginUnivEvTerm` and `mkTyFamAppReduction` now all take
an additional `DVarSet` argument which allows specifying evidence that we
depend on. This stops evidence terms being floated out past used enclosing
Givens (see [GHC issue #23923](https://gitlab.haskell.org/ghc/ghc/-/issues/23923)).

- Re-export `DVarSet`, `emptyDVarSet`, `extendDVarSet`, `unionDVarSet`
`unitDVarSet`, and `mkDVarSet`, as well as `ctEvId`, in order to facilitate
construction and manipulation of `DVarSet`s.

- Re-export `GHC.Types.Unique.Set`, `GHC.Types.Unique.DSet`.

# Version 0.11.0.0 (2023-08-29)

- Add support for GHC 9.8.
Expand Down
6 changes: 3 additions & 3 deletions examples/RewriterPlugin/plugin/RewriterPlugin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ rewrite_add pluginDefs@( PluginDefs { .. } ) _givens tys
-> do
wanted <- mkCancellableWanted pluginDefs b
pure $ API.TcPluginRewriteTo
( API.mkTyFamAppReduction "RewriterPlugin" API.Nominal addTyCon tys b )
( API.mkTyFamAppReduction "RewriterPlugin" API.Nominal API.emptyVarSet addTyCon tys b )
[ wanted ]
-- "Add a Zero = a", emitting a "Cancellable a" Wanted constraint.
| Just ( zero, [] ) <- API.splitTyConApp_maybe b
, zero == zeroTyCon
-> do
wanted <- mkCancellableWanted pluginDefs a
pure $ API.TcPluginRewriteTo
( API.mkTyFamAppReduction "RewriterPlugin" API.Nominal addTyCon tys a )
( API.mkTyFamAppReduction "RewriterPlugin" API.Nominal API.emptyVarSet addTyCon tys a )
[ wanted ]

-- Erroring on 'BadNat'.
Expand All @@ -137,7 +137,7 @@ rewrite_add pluginDefs@( PluginDefs { .. } ) _givens tys
= pure API.TcPluginNoRewrite
where
badRedn :: API.Reduction
badRedn = API.mkTyFamAppReduction "RewriterPlugin" API.Nominal
badRedn = API.mkTyFamAppReduction "RewriterPlugin" API.emptyVarSet API.Nominal
addTyCon tys (API.mkTyConApp badNatTyCon [])

-- Given the type "a", constructs a "Cancellable a" constraint
Expand Down
11 changes: 10 additions & 1 deletion examples/SystemF/src/SystemF/Examples.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE Haskell2010 #-}

{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
Expand All @@ -8,6 +9,10 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

#if MIN_VERSION_ghc(9,9,0)
{-# LANGUAGE TypeAbstractions #-}
#endif

module SystemF.Examples where

-- base
Expand Down Expand Up @@ -47,7 +52,11 @@ type ChurchKind :: Kind -> Kind
type ChurchKind k = Fun (Fun k k) (Fun k k)

type ChurchType :: forall (k :: Kind). Type KEmpty (ChurchKind k)
type ChurchType = Forall ( (VarTy KZ :-> VarTy KZ) :-> (VarTy KZ :-> VarTy KZ) )
type ChurchType
#if MIN_VERSION_ghc(9,9,0)
@k
#endif
= Forall ( (VarTy KZ :-> VarTy KZ) :-> (VarTy KZ :-> VarTy KZ) )

church :: forall (k :: Kind). Hs.Int -> Term Empty (ChurchType @k)
church i = TyLam $ LamE ( SVarTy SKZ :%-> SVarTy SKZ ) $ LamE ( SVarTy SKZ ) ( go i )
Expand Down
Loading
Loading