From 11f04ca6780b4c42a4552db4ba84719b714df990 Mon Sep 17 00:00:00 2001 From: Martijn Bastiaan Date: Thu, 15 Feb 2024 10:08:38 +0100 Subject: [PATCH] Support GHC 9.2, 9.4, and 9.6 --- .github/workflows/ci.yml | 5 ++++- cabal.project | 2 +- clash-protocols.cabal | 2 +- src/Protocols/Df.hs | 3 +++ src/Protocols/Plugin.hs | 13 +++++++++++++ src/Protocols/Wishbone/Standard/Hedgehog.hs | 3 +++ stack.yaml | 2 +- tests/Tests/Protocols/Df.hs | 3 +++ tests/Tests/Protocols/DfConv.hs | 3 +++ 9 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 769a422c..d7dd1345 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,10 +56,13 @@ jobs: - "1.6.1" - "1.8.1" cabal: - - "3.6" + - "3.10" ghc: - "8.10.7" - "9.0.2" + - "9.2.8" + - "9.4.8" + - "9.6.4" env: clash_version: ${{ matrix.clash }} diff --git a/cabal.project b/cabal.project index 07bb0f6f..d9aefb84 100644 --- a/cabal.project +++ b/cabal.project @@ -13,7 +13,7 @@ package clash-prelude source-repository-package type: git location: https://github.com/cchalmers/circuit-notation.git - tag: 565d4811cff6a597ee577dabd81b460e941fcb14 + tag: f0c3c678326abf4907e875175632e826ad8fc866 package clash-protocols -- Reduces compile times by ~20% diff --git a/clash-protocols.cabal b/clash-protocols.cabal index 120a7b20..f5695265 100644 --- a/clash-protocols.cabal +++ b/clash-protocols.cabal @@ -140,7 +140,7 @@ library , data-default , deepseq , extra - , ghc >= 8.7 + , ghc >= 8.7 && < 9.7 , hashable , hedgehog >= 1.0.2 , mtl diff --git a/src/Protocols/Df.hs b/src/Protocols/Df.hs index dbfdc458..0d7971c8 100644 --- a/src/Protocols/Df.hs +++ b/src/Protocols/Df.hs @@ -15,6 +15,9 @@ carries data, no metadata. For documentation see: {-# OPTIONS_GHC -fno-warn-orphans #-} +-- TODO: Fix warnings introduced by GHC 9.2 w.r.t. incomplete lazy pattern matches +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + module Protocols.Df ( -- * Types Df, Data(..) diff --git a/src/Protocols/Plugin.hs b/src/Protocols/Plugin.hs index 0d331642..a0b2bd73 100644 --- a/src/Protocols/Plugin.hs +++ b/src/Protocols/Plugin.hs @@ -29,6 +29,10 @@ import Prelude -- clash-protocols import Protocols +-- clash-prelude +import Clash.Prelude (type (+)) +import qualified Clash.Prelude as C + -- circuit-notation import qualified CircuitNotation as CN @@ -66,6 +70,14 @@ pattern TaggedCircuit :: TaggedCircuitT a b -> Circuit a b pattern TaggedCircuit f <- (taggedCircuit -> f) where TaggedCircuit f = unTaggedCircuit f +-- | Unsafe version of ':>'. Will fail if applied to empty vectors. This is used to +-- work around spurious incomplete pattern match warnings generated in newer GHC +-- versions. +pattern (:>!) :: a -> C.Vec n a -> C.Vec (n + 1) a +pattern (:>!) x xs <- (\ys -> (C.head ys, C.tail ys) -> (x,xs)) +{-# COMPLETE (:>!) #-} +infixr 5 :>! + -- | @circuit-notation@ plugin repurposed for "Protocols". plugin :: GHC.Plugin plugin = CN.mkPlugin $ CN.ExternalNames @@ -79,4 +91,5 @@ plugin = CN.mkPlugin $ CN.ExternalNames , CN.tagName = CN.thName 'Tagged , CN.tagTName = CN.thName ''Tagged , CN.trivialBwd = CN.thName 'units + , CN.unsafeConsPat = CN.thName '(:>!) } diff --git a/src/Protocols/Wishbone/Standard/Hedgehog.hs b/src/Protocols/Wishbone/Standard/Hedgehog.hs index 4a66d71c..aaf7a508 100644 --- a/src/Protocols/Wishbone/Standard/Hedgehog.hs +++ b/src/Protocols/Wishbone/Standard/Hedgehog.hs @@ -3,6 +3,9 @@ {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE MultiWayIf #-} +-- TODO: Fix warnings introduced by GHC 9.2 w.r.t. incomplete lazy pattern matches +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + -- | -- Types and functions to aid with testing Wishbone circuits. -- diff --git a/stack.yaml b/stack.yaml index 21001dab..cdff48d0 100644 --- a/stack.yaml +++ b/stack.yaml @@ -5,7 +5,7 @@ packages: extra-deps: - git: https://github.com/cchalmers/circuit-notation.git - commit: 565d4811cff6a597ee577dabd81b460e941fcb14 + commit: f0c3c678326abf4907e875175632e826ad8fc866 - tasty-hedgehog-1.2.0.0 - clash-prelude-1.6.3 - clash-prelude-hedgehog-1.6.3 diff --git a/tests/Tests/Protocols/Df.hs b/tests/Tests/Protocols/Df.hs index 004c8567..77d33ae0 100644 --- a/tests/Tests/Protocols/Df.hs +++ b/tests/Tests/Protocols/Df.hs @@ -2,6 +2,9 @@ {-# LANGUAGE MonomorphismRestriction #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- Hashable (Index n) +-- TODO: Fix warnings introduced by GHC 9.2 w.r.t. incomplete lazy pattern matches +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + module Tests.Protocols.Df where -- base diff --git a/tests/Tests/Protocols/DfConv.hs b/tests/Tests/Protocols/DfConv.hs index cdd46e61..6931b3a9 100644 --- a/tests/Tests/Protocols/DfConv.hs +++ b/tests/Tests/Protocols/DfConv.hs @@ -1,5 +1,8 @@ {-# LANGUAGE NumericUnderscores #-} +-- TODO: Fix warnings introduced by GHC 9.2 w.r.t. incomplete lazy pattern matches +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + module Tests.Protocols.DfConv where -- base