Skip to content

Commit

Permalink
Support GHC 9.8 and 9.10
Browse files Browse the repository at this point in the history
GHC 9.8 and 9.10 give a lot of Haddock warnings. We used to check the
Haddock for all GHC versions, but this is overkill. Just check it on GHC
9.6 only.

We used to first invoke `cabal build` and then
`cabal build --enable-documentation`. But this rebuilds all
dependencies, effectively doubling running time.

The `allow-newer` on `circuit-notation` is superfluous.

Further details: Haddock for GHC 9.8 and up generate more information
about type family instances. However, this also leads to "could not find
link destinations for" warnings. Given an `instance C A`, it would seem
that when it lists the instance under the Haddock of the definition of
`C`, it tries to create a link to the listing of the instance under the
Haddock of the definition of `A`, and fails somehow. I suspect a bug in
Haddock rather than something we can fix.
  • Loading branch information
DigitalBrains1 committed Jan 28, 2025
1 parent 2f33cf2 commit 94e6c31
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 26 deletions.
8 changes: 8 additions & 0 deletions .ci/apply_settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [[ "$check_haddock" != @(True|False) ]]; then
echo "check_haddock: Expected True or False, got \"$check_haddock\"" >&2
exit 1
fi
sed <.ci/cabal.project.local.in >cabal.project.local "
s/__CHECK_HADDOCK__/$check_haddock/"
13 changes: 0 additions & 13 deletions .ci/build_docs.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
#!/bin/bash
set -xeou pipefail

# Build dependencies first, so they don't end up in logs
cabal v2-build \
--constraint=clash-prelude==$clash_version \
--enable-documentation \
--allow-newer=circuit-notation:ghc \
clash-protocols

# circuit-notation currently _compiles on 8.10, but isn't usable. The only
# other GHC version it supports is 8.6.5, but this GHC bundles a Haddock that
# cannot generate documentation for clash-prelude. Hence, we build docs with
# 8.10 and relax circuit-notation's ghc bounds
cabal v2-haddock \
--constraint=clash-prelude==$clash_version \
--enable-documentation \
--allow-newer=circuit-notation:ghc \
clash-protocols \
|& tee haddock_log

Expand Down
2 changes: 0 additions & 2 deletions .ci/cabal.project.local

This file was deleted.

6 changes: 6 additions & 0 deletions .ci/cabal.project.local.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package *
documentation: __CHECK_HADDOCK__

package clash-protocols
documentation: False
ghc-options: -Werror
1 change: 0 additions & 1 deletion .ci/test_cabal.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash
set -xeou pipefail

cabal v2-build all --constraint=clash-prelude==$clash_version -fci
cabal v2-run unittests --constraint=clash-prelude==$clash_version -fci --enable-tests
cabal v2-run doctests --constraint=clash-prelude==$clash_version -fci --enable-tests
cabal v2-sdist clash-protocols
18 changes: 14 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,32 @@ jobs:
.ci/test_stack.sh
cabal:
name: Cabal tests - ghc ${{ matrix.ghc }} / clash ${{ matrix.clash }}
name: Cabal tests - ghc ${{ matrix.ghc }} / clash ${{ matrix.clash }} / doc ${{ matrix.check_haddock }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
clash:
- "1.8.1"
- "1.8.2"
cabal:
- "3.10"
ghc:
- "9.0.2"
- "9.2.8"
- "9.4.8"
- "9.6.4"
- "9.8.4"
- "9.10.1"
include:
- check_haddock: "False"
- ghc: "9.6.4"
check_haddock: "True"
os: "ubuntu-latest"
clash: "1.8.2"
cabal: "3.10"

env:
check_haddock: ${{ matrix.check_haddock }}
clash_version: ${{ matrix.clash }}

steps:
Expand All @@ -79,7 +88,7 @@ jobs:

- name: Use CI specific settings
run: |
cp .ci/cabal.project.local .
.ci/apply_settings.sh
- name: Setup CI
run: |
Expand All @@ -105,6 +114,7 @@ jobs:
.ci/test_cabal.sh
- name: Documentation
if: ${{ matrix.check_haddock == 'True' }}
run: |
.ci/build_docs.sh
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package clash-prelude
source-repository-package
type: git
location: https://github.com/cchalmers/circuit-notation.git
tag: 19b386c4aa3ff690758ae089c7754303f3500cc9
tag: 564769c52aa05b90f81bbc898b7af7087d96613d

package clash-protocols-base
-- Reduces compile times by ~20%
Expand Down
8 changes: 6 additions & 2 deletions clash-protocols/src/Protocols/Df.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ import Prelude hiding (
import qualified Data.Bifunctor as B
import Data.Bool (bool)
import qualified Data.Coerce as Coerce
#if MIN_VERSION_base(4,19,0)
import qualified Data.Functor as Functor (unzip)
#else
import qualified Data.List.NonEmpty as Functor (unzip)
#endif
import Data.Kind (Type)
import Data.List ((\\))
import qualified Data.List.NonEmpty
import qualified Data.Maybe as Maybe
import Data.Proxy
import qualified Prelude as P
Expand Down Expand Up @@ -862,7 +866,7 @@ roundrobinCollect Parallel =
nacks = C.repeat (Ack False)
acks = Maybe.fromMaybe nacks ((\i -> C.replace i ack nacks) <$> iM)
dat1 = Maybe.fromMaybe NoData dat0
(iM, dat0) = Data.List.NonEmpty.unzip dats1
(iM, dat0) = Functor.unzip dats1
dats1 = C.fold @(n C.- 1) (<|>) (C.zipWith goDat C.indicesI dats0)

goDat i dat
Expand Down
2 changes: 0 additions & 2 deletions clash-protocols/src/Protocols/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fconstraint-solver-iterations=20 #-}
#if !MIN_VERSION_clash_prelude(1, 8, 2)
{-# OPTIONS_GHC -fno-warn-orphans #-}
#endif

-- TODO: Hide internal documentation
-- {-# OPTIONS_HADDOCK hide #-}
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ packages:

extra-deps:
- git: https://github.com/cchalmers/circuit-notation.git
commit: 19b386c4aa3ff690758ae089c7754303f3500cc9
commit: 564769c52aa05b90f81bbc898b7af7087d96613d
- clash-prelude-1.8.1
- clash-prelude-hedgehog-1.8.1

0 comments on commit 94e6c31

Please sign in to comment.