Skip to content

Commit

Permalink
Merge pull request #72 from Mikolaj/update-to-GHC-9.6
Browse files Browse the repository at this point in the history
Update to ghc 9.6
  • Loading branch information
christiaanb authored Feb 20, 2023
2 parents 127c525 + 13e5073 commit f089f6b
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 26 deletions.
60 changes: 43 additions & 17 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.15.20220826
# version: 0.15.20230217
#
# REGENDATA ("0.15.20220826",["github","ghc-typelits-natnormalise.cabal"])
# REGENDATA ("0.15.20230217",["github","ghc-typelits-natnormalise.cabal"])
#
name: Haskell-CI
on:
Expand All @@ -28,14 +28,19 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.4.2
- compiler: ghc-9.6.0.20230210
compilerKind: ghc
compilerVersion: 9.4.2
compilerVersion: 9.6.0.20230210
setup-method: ghcup
allow-failure: true
- compiler: ghc-9.4.4
compilerKind: ghc
compilerVersion: 9.4.4
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.4
- compiler: ghc-9.2.6
compilerKind: ghc
compilerVersion: 9.2.4
compilerVersion: 9.2.6
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.2
Expand Down Expand Up @@ -83,16 +88,18 @@ jobs:
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml;
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.9.0.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml;
"$HOME/.ghcup/bin/ghcup" install cabal 3.9.0.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
env:
HCKIND: ${{ matrix.compilerKind }}
Expand All @@ -110,20 +117,20 @@ jobs:
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.9.0.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.9.0.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
env:
Expand Down Expand Up @@ -152,6 +159,18 @@ jobs:
repository hackage.haskell.org
url: http://hackage.haskell.org/
EOF
if $HEADHACKAGE; then
cat >> $CABAL_CONFIG <<EOF
repository head.hackage.ghc.haskell.org
url: https://ghc.gitlab.haskell.org/head.hackage/
secure: True
root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
key-threshold: 3
active-repositories: hackage.haskell.org, head.hackage.ghc.haskell.org:override
EOF
fi
cat >> $CABAL_CONFIG <<EOF
program-default-options
ghc-options: $GHCJOBS +RTS -M3G -RTS
Expand All @@ -175,7 +194,7 @@ jobs:
chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: source
- name: initial cabal.project for sdist
Expand All @@ -199,21 +218,22 @@ jobs:
touch cabal.project
touch cabal.project.local
echo "packages: ${PKGDIR_ghc_typelits_natnormalise}" >> cabal.project
echo "package ghc-typelits-natnormalise" >> cabal.project
echo " flags: +deverror" >> cabal.project
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package ghc-typelits-natnormalise" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
cat >> cabal.project <<EOF
EOF
if $HEADHACKAGE; then
echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1,/g')" >> cabal.project
fi
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(ghc-typelits-natnormalise)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan
- name: cache
uses: actions/cache@v2
- name: restore cache
uses: actions/cache/restore@v3
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
Expand All @@ -237,8 +257,14 @@ jobs:
${CABAL} -vnormal check
- name: haddock
run: |
if [ $((HCNUMVER == 80605)) -ne 0 ] ; then $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all; else $CABAL v2-haddock --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all ; fi
if [ $((HCNUMVER == 80605)) -ne 0 ] ; then $CABAL v2-haddock --disable-documentation $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all; else $CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all; fi
- name: unconstrained build
run: |
rm -f cabal.project.local
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: save cache
uses: actions/cache/save@v3
if: always()
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog for the [`ghc-typelits-natnormalise`](http://hackage.haskell.org/package/ghc-typelits-natnormalise) package

## Unreleased
## 0.7.8 *February 20th 2023*
* Try and outright solve substituted constraints, the same as is done with the unsubstituted constraint. Partially Fixes [#65](https://github.com/clash-lang/ghc-typelits-natnormalise/issues/65).
* Support for GHC-9.6.0.20230210

## 0.7.7 *October 10th 2022*
* Solve unflattened wanteds instead of the wanteds passed to the plugin. Fixes [#1901]https://github.com/clash-lang/clash-compiler/issues/1901.
Expand Down
12 changes: 6 additions & 6 deletions ghc-typelits-natnormalise.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ghc-typelits-natnormalise
version: 0.7.7
version: 0.7.8
synopsis: GHC typechecker plugin for types of kind GHC.TypeLits.Nat
description:
A type checker plugin for GHC that can solve /equalities/ and /inequalities/
Expand Down Expand Up @@ -49,8 +49,8 @@ extra-source-files: README.md
CHANGELOG.md
cabal-version: >=1.10
tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5,
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.4,
GHC == 9.4.2
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.6,
GHC == 9.4.4, GHC == 9.6.1

source-repository head
type: git
Expand All @@ -68,17 +68,17 @@ library
GHC.TypeLits.Normalise.Unify
build-depends: base >=4.9 && <5,
containers >=0.5.7.1 && <0.7,
ghc >=8.0.1 && <9.6,
ghc >=8.0.1 && <9.8,
ghc-tcplugins-extra >=0.3.1,
transformers >=0.5.2.0 && < 0.6
transformers >=0.5.2.0 && < 0.7
if impl(ghc >= 9.0.0)
build-depends: ghc-bignum >=1.0 && <1.4
else
build-depends: integer-gmp >=1.0 && <1.1
hs-source-dirs: src
if impl(ghc >= 8.0) && impl(ghc < 9.4)
hs-source-dirs: src-pre-ghc-9.4
if impl(ghc >= 9.4) && impl(ghc < 9.6)
if impl(ghc >= 9.4) && impl(ghc < 9.8)
hs-source-dirs: src-ghc-9.4
default-language: Haskell2010
other-extensions: CPP
Expand Down
8 changes: 8 additions & 0 deletions src-ghc-9.4/GHC/TypeLits/Normalise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ xs :: OptVector t (n-l)
where /n-l/ is a negative number.
-}

{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
Expand Down Expand Up @@ -185,8 +186,15 @@ import GHC.Core.Predicate
mkPrimEqPred, isEqPred, isEqPrimPred, getClassPredTys_maybe)
import GHC.Core.TyCo.Rep (Type (..), UnivCoProvenance (..))
import GHC.Core.TyCon (TyCon)
#if MIN_VERSION_ghc(9,6,0)
import GHC.Core.Type
(Kind, PredType, mkTyVarTy, tyConAppTyCon_maybe, typeKind, mkTyConApp)
import GHC.Core.TyCo.Compare
(eqType)
#else
import GHC.Core.Type
(Kind, PredType, eqType, mkTyVarTy, tyConAppTyCon_maybe, typeKind, mkTyConApp)
#endif
import GHC.Driver.Plugins (Plugin (..), defaultPlugin, purePlugin)
import GHC.Tc.Plugin
(TcPluginM, tcLookupClass, tcPluginTrace, tcPluginIO, newEvVar)
Expand Down
7 changes: 7 additions & 0 deletions src/GHC/TypeLits/Normalise/Unify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ import GHC.Builtin.Types.Literals (typeNatLeqTyCon)
#endif
import GHC.Core.Predicate (EqRel (NomEq), Pred (EqPred), classifyPredType, mkPrimEqPred)
import GHC.Core.TyCon (TyCon)
#if MIN_VERSION_ghc(9,6,0)
import GHC.Core.Type
(PredType, TyVar, coreView, mkNumLitTy, mkTyConApp, mkTyVarTy, typeKind)
import GHC.Core.TyCo.Compare
(eqType, nonDetCmpType)
#else
import GHC.Core.Type
(PredType, TyVar, coreView, eqType, mkNumLitTy, mkTyConApp, mkTyVarTy, nonDetCmpType, typeKind)
#endif
import GHC.Core.TyCo.Rep (Kind, Type (..), TyLit (..))
import GHC.Tc.Plugin (TcPluginM, tcPluginTrace)
import GHC.Tc.Types.Constraint (Ct, ctEvidence, ctEvId, ctEvPred, isGiven)
Expand Down
43 changes: 41 additions & 2 deletions tests/ErrorTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,24 @@ testProxy10 :: Proxy (a :: Nat) -> Proxy (a + 2) -> ()
testProxy10 = proxyInEq'

testProxy10Errors =
#if __GLASGOW_HASKELL__ >= 902
#if __GLASGOW_HASKELL__ >= 906
[$(do localeEncoding <- runIO (getLocaleEncoding)
if textEncodingName localeEncoding == textEncodingName utf8
then litE $ stringL "Couldn't match type ‘Data.Type.Ord.OrdCond"
else litE $ stringL "Couldn't match type `Data.Type.Ord.OrdCond"
)
,$(do localeEncoding <- runIO (getLocaleEncoding)
if textEncodingName localeEncoding == textEncodingName utf8
then litE $ stringL "(CmpNat a (a + 2)) True True False’"
else litE $ stringL "(CmpNat a (a + 2)) True True False'"
)
,$(do localeEncoding <- runIO (getLocaleEncoding)
if textEncodingName localeEncoding == textEncodingName utf8
then litE $ stringL "with ‘False"
else litE $ stringL "with False"
)
]
#elif __GLASGOW_HASKELL__ >= 902
[$(do localeEncoding <- runIO (getLocaleEncoding)
if textEncodingName localeEncoding == textEncodingName utf8
then litE $ stringL "Couldn't match type ‘Data.Type.Ord.OrdCond"
Expand Down Expand Up @@ -222,8 +239,13 @@ testProxy11 = proxyInEq'
testProxy11Errors =
[$(do localeEncoding <- runIO (getLocaleEncoding)
if textEncodingName localeEncoding == textEncodingName utf8
#if __GLASGOW_HASKELL__ >= 906
then litE $ stringL "Couldn't match type ‘True’ with ‘False’"
else litE $ stringL "Couldn't match type True with False"
#else
then litE $ stringL "Couldn't match type ‘'True’ with ‘'False’"
else litE $ stringL "Couldn't match type 'True with 'False"
#endif
)]

testProxy12 :: Proxy (a + b) -> Proxy (a + c) -> ()
Expand Down Expand Up @@ -292,7 +314,24 @@ testProxy14 :: Proxy (2*a) -> Proxy (4*a) -> ()
testProxy14 = proxyInEq'

testProxy14Errors =
#if __GLASGOW_HASKELL__ >= 902
#if __GLASGOW_HASKELL__ >= 906
[$(do localeEncoding <- runIO (getLocaleEncoding)
if textEncodingName localeEncoding == textEncodingName utf8
then litE $ stringL "Couldn't match type ‘Data.Type.Ord.OrdCond"
else litE $ stringL "Couldn't match type `Data.Type.Ord.OrdCond"
)
,$(do localeEncoding <- runIO (getLocaleEncoding)
if textEncodingName localeEncoding == textEncodingName utf8
then litE $ stringL "(CmpNat (2 * a) (4 * a)) True True False’"
else litE $ stringL "(CmpNat (2 * a) (4 * a)) True True False'"
)
,$(do localeEncoding <- runIO (getLocaleEncoding)
if textEncodingName localeEncoding == textEncodingName utf8
then litE $ stringL "with ‘False"
else litE $ stringL "with False"
)
]
#elif __GLASGOW_HASKELL__ >= 902
[$(do localeEncoding <- runIO (getLocaleEncoding)
if textEncodingName localeEncoding == textEncodingName utf8
then litE $ stringL "Couldn't match type ‘Data.Type.Ord.OrdCond"
Expand Down
4 changes: 4 additions & 0 deletions tests/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
{-# OPTIONS_GHC -dcore-lint #-}

import GHC.TypeLits
#if MIN_VERSION_base(4,18,0)
hiding (type SNat)
#endif

import Unsafe.Coerce
import Prelude hiding (head,tail,init,(++),splitAt,concat,drop)
import qualified Prelude as P
Expand Down

0 comments on commit f089f6b

Please sign in to comment.