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

Require building with GHC 9.10 #587

Merged
merged 7 commits into from
May 12, 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
142 changes: 52 additions & 90 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.18.1
# version: 0.19.20240512
#
# REGENDATA ("0.18.1",["github","cabal.project"])
# REGENDATA ("0.19.20240512",["github","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -23,29 +23,29 @@ jobs:
timeout-minutes:
60
container:
image: buildpack-deps:bionic
image: buildpack-deps:jammy
continue-on-error: ${{ matrix.allow-failure }}
strategy:
matrix:
include:
- compiler: ghcjs-8.4
compilerKind: ghcjs
compilerVersion: "8.4"
setup-method: hvr-ppa
- compiler: ghc-9.10.1
compilerKind: ghc
compilerVersion: 9.10.1
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.8.1
- compiler: ghc-9.8.2
compilerKind: ghc
compilerVersion: 9.8.1
compilerVersion: 9.8.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.6.2
- compiler: ghc-9.6.5
compilerKind: ghc
compilerVersion: 9.6.2
compilerVersion: 9.6.5
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.5
- compiler: ghc-9.4.8
compilerKind: ghc
compilerVersion: 9.4.5
compilerVersion: 9.4.8
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.7
Expand All @@ -66,99 +66,64 @@ jobs:
- compiler: ghc-8.8.4
compilerKind: ghc
compilerVersion: 8.8.4
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.6.5
compilerKind: ghc
compilerVersion: 8.6.5
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.4.4
compilerKind: ghc
compilerVersion: 8.4.4
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.2.2
compilerKind: ghc
compilerVersion: 8.2.2
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.0.2
compilerKind: ghc
compilerVersion: 8.0.2
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
fail-fast: false
steps:
- name: Set GHCJS environment variables
run: |
if [ $HCKIND = ghcjs ]; then
echo "GHCJS=true" >> "$GITHUB_ENV"
echo "GHCJSARITH=1" >> "$GITHUB_ENV"
else
echo "GHCJS=false" >> "$GITHUB_ENV"
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
fi
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
HCVER: ${{ matrix.compilerVersion }}
- name: apt
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
else
apt-add-repository -y 'ppa:hvr/ghc'
if [ $((GHCJSARITH)) -ne 0 ] ; then apt-add-repository -y 'ppa:hvr/ghcjs' ; fi
if [ $((GHCJSARITH)) -ne 0 ] ; then curl -sSL "https://deb.nodesource.com/gpgkey/nodesource.gpg.key" | apt-key add - ; fi
if [ $((GHCJSARITH)) -ne 0 ] ; then apt-add-repository -y 'deb https://deb.nodesource.com/node_10.x bionic main' ; fi
apt-get update
if [ $((GHCJSARITH)) -ne 0 ] ; then apt-get install -y "$HCNAME" ghc-8.4.4 nodejs ; else apt-get install -y "$HCNAME" ; fi
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
HCVER: ${{ matrix.compilerVersion }}
- name: Set PATH and environment variables
run: |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
if [ $((GHCJSARITH)) -ne 0 ] ; then echo "/opt/ghc/8.4.4/bin" >> $GITHUB_PATH ; fi
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.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.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi

HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
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"
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi
if [ $((HCNUMVER >= 91000)) -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:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand Down Expand Up @@ -194,7 +159,6 @@ jobs:
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
key-threshold: 3
active-repositories: hackage.haskell.org, head.hackage.ghc.haskell.org:override
EOF
fi
cat >> $CABAL_CONFIG <<EOF
Expand All @@ -207,8 +171,6 @@ jobs:
$HC --version || true
$HC --print-project-git-commit-id || true
$CABAL --version || true
if [ $((GHCJSARITH)) -ne 0 ] ; then node --version ; fi
if [ $((GHCJSARITH)) -ne 0 ] ; then echo $GHCJS ; fi
- name: update cabal index
run: |
$CABAL v2-update -v
Expand All @@ -222,15 +184,15 @@ jobs:
chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: source
- name: initial cabal.project for sdist
run: |
touch cabal.project
echo "packages: $GITHUB_WORKSPACE/source/./singletons" >> cabal.project
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/./singletons-th" >> cabal.project ; fi
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/./singletons-base" >> cabal.project ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/./singletons-th" >> cabal.project ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/./singletons-base" >> cabal.project ; fi
cat cabal.project
- name: sdist
run: |
Expand All @@ -252,14 +214,14 @@ jobs:
touch cabal.project
touch cabal.project.local
echo "packages: ${PKGDIR_singletons}" >> cabal.project
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then echo "packages: ${PKGDIR_singletons_th}" >> cabal.project ; fi
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then echo "packages: ${PKGDIR_singletons_base}" >> cabal.project ; fi
if [ $((GHCJSARITH || ! GHCJSARITH && HCNUMVER >= 80200)) -ne 0 ] ; then echo "package singletons" >> cabal.project ; fi
if [ $((GHCJSARITH || ! GHCJSARITH && HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then echo "package singletons-th" >> cabal.project ; fi
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then echo "package singletons-base" >> cabal.project ; fi
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then echo "packages: ${PKGDIR_singletons_th}" >> cabal.project ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then echo "packages: ${PKGDIR_singletons_base}" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package singletons" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then echo "package singletons-th" >> cabal.project ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then echo "package singletons-base" >> cabal.project ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
cat >> cabal.project <<EOF
source-repository-package
type: git
Expand All @@ -277,7 +239,7 @@ jobs:
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan
- name: restore cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
Expand All @@ -291,20 +253,20 @@ jobs:
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
- name: tests
run: |
if [ $((! GHCJSARITH)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct ; fi
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
- name: cabal check
run: |
cd ${PKGDIR_singletons} || false
${CABAL} -vnormal check
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then cd ${PKGDIR_singletons_th} || false ; fi
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then ${CABAL} -vnormal check ; fi
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then cd ${PKGDIR_singletons_base} || false ; fi
if [ $((! GHCJSARITH && HCNUMVER >= 90800)) -ne 0 ] ; then ${CABAL} -vnormal check ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then cd ${PKGDIR_singletons_th} || false ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then ${CABAL} -vnormal check ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then cd ${PKGDIR_singletons_base} || false ; fi
if [ $((HCNUMVER >= 91000)) -ne 0 ] ; then ${CABAL} -vnormal check ; fi
- name: haddock
run: |
if [ $((! GHCJSARITH)) -ne 0 ] ; then $CABAL v2-haddock --disable-documentation $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all ; fi
$CABAL v2-haddock --disable-documentation $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
- name: save cache
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: always()
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
Expand Down
77 changes: 71 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,14 @@ Compatibility
windows for requirements on the compiler version needed to build each library:

* `singletons` is a minimal library, and as such, it has a relatively
wide support window. `singletons` must be built with one of the following
compilers:

* GHC 8.0 or greater
* GHCJS
wide support window. `singletons` must be built with GHC 8.0 or later.
`singletons` aims to support cross-compilers as well (e.g., GHC's JavaScript
backend).
* `singletons-th` and `singletons-base` require use of many bleeding-edge
GHC language extensions, even more so than `singletons` itself. As such, it
is difficult to maintain support for multiple GHC versions in any given
release of either library, so they only support the latest major GHC version
(currently GHC 9.8).
(currently GHC 9.10).

Any code that uses the singleton-generation functionality from `singletons-th`
or `singletons-base` needs to enable a long list of GHC extensions. This list
Expand Down Expand Up @@ -850,6 +848,7 @@ The following constructs are partially supported:
* type families
* `TypeApplications`
* wildcard types
* inferred type variable binders

See the following sections for more details.

Expand Down Expand Up @@ -1229,6 +1228,72 @@ any other context. Ultimately, this is due to a GHC restriction, as GHC itself
will forbid using wildcards in most kind-level contexts. For example, GHC will
permit `f :: _` but reject `type F :: _`.

## Inferred type variable binders

`singletons-th` supports promoting inferred type variable binders in most
circumstances. For example, `singletons-th` can promote this definition:

```hs
konst :: forall a {b}. a -> b -> a
konst x _ = x
```

To this type family:

```hs
type Konst :: forall a {b}. a -> b -> a
type family Konst @a x y where
Konst @a (x :: a) (_ :: b) = x
```

There is one (somewhat obscure) corner case that `singletons-th` cannot handle,
which requires both of the following criteria to be met:

* A definition must not have any visible arguments.
* A definition must have an inferred type variable binder as the last type
variable in an outermost `forall`.

For instance, `singletons-th` cannot promote this definition:

```hs
bad :: forall {a}. Either a Bool
bad = Right True
```

This is because `singletons-th` will attempt to generate this type family:

```hs
type Bad :: forall {a}. Either a Bool
type family Bad where
Bad = Right True
```

GHC will not kind-check `Bad`, however. GHC will kind-check the standalone kind
signature and conclude that `Bad` has arity 0, i.e., that it does not bind any
arguments (visible or invisible). However, the definition of `Bad` requires an
arity of 1, as it implicitly binds an argument:

```hs
Bad @{a} = Right @{a} @Bool True
```

In order to make this kind-check, we would need to be able to generate something
like this:

```hs
type Bad :: forall {a}. Either a Bool
type family Bad @{a} where
Bad = Right True
```

However, GHC does not allow users to things like `@{a}`, and this is by design.
(See [this
part](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0425-decl-invis-binders.rst#alternatives)
of the relevant GHC proposal about invisible binders in type declarations.) As
such, there is no way for `singletons-th` to promote this definition exactly as
written. As a workaround, you can change the `forall {a}` to `forall a`, or you
can remove the standalone kind signature.

## Support for promotion, but not singling

The following constructs are supported for promotion but not singleton generation:
Expand Down
7 changes: 4 additions & 3 deletions cabal.haskell-ci
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
distribution: bionic
distribution: jammy
no-tests-no-benchmarks: False
unconstrained: False
jobs-selection: any
-- Needed to avoid https://github.com/haskell/cabal/issues/5423
haddock-components: libs
-- Temporarily use head.hackage for GHC 9.8 until the ecosystem catches up
head-hackage: >= 9.8
-- Using `active-repositories: ..., head.hackage.ghc.haskell.org:override`
-- tends not to work well with singletons-base's custom Setup script.
head-hackage-override: False
4 changes: 4 additions & 0 deletions singletons-base/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog for the `singletons-base` project
===========================================

3.4 [????.??.??]
----------------
* Require building with GHC 9.10.

3.3 [2023.10.13]
----------------
* Require building with GHC 9.8.
Expand Down
Loading