From 38dfa1b74467d3340f77e0ef82c4e275026204a7 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Wed, 5 Nov 2025 17:37:50 +1100 Subject: [PATCH 1/2] cabal.project: Update index-states --- cabal.project | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cabal.project b/cabal.project index a956fa34ee5..8db23db08f8 100644 --- a/cabal.project +++ b/cabal.project @@ -27,8 +27,8 @@ source-repository-package -- NOTE: If you would like to update the above, -- see CONTRIBUTING.md#to-update-the-referenced-agda-ledger-spec index-state: - , hackage.haskell.org 2025-09-30T00:00:00Z - , cardano-haskell-packages 2025-10-01T14:54:47Z + , hackage.haskell.org 2025-11-02T18:37:41Z + , cardano-haskell-packages 2025-10-29T16:43:43Z packages: -- == Byron era == From d186d46e5394f84f76b5a768f0ee626bbf4a848e Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 6 Nov 2025 14:27:28 +1100 Subject: [PATCH 2/2] Preliminary ghc 9.14 support Currently using ghc-9.14.0.20251028 (-rc1). --- cabal.project | 215 +++++++++++++++++- .../src/Cardano/Ledger/Allegra/Scripts.hs | 12 + .../Test/Cardano/Ledger/Allegra/Arbitrary.hs | 18 ++ .../Test/Cardano/Ledger/Allegra/ImpTest.hs | 13 ++ eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs | 6 + .../impl/src/Cardano/Ledger/Alonzo/Core.hs | 16 ++ .../Cardano/Ledger/Alonzo/Plutus/Evaluate.hs | 13 ++ .../Cardano/Ledger/Alonzo/Plutus/TxInfo.hs | 5 + .../src/Cardano/Ledger/Alonzo/Rules/Utxo.hs | 9 + .../src/Cardano/Ledger/Alonzo/Rules/Utxos.hs | 13 +- .../src/Cardano/Ledger/Alonzo/Rules/Utxow.hs | 17 +- .../impl/src/Cardano/Ledger/Alonzo/Scripts.hs | 8 + .../impl/src/Cardano/Ledger/Alonzo/Tx.hs | 9 +- .../impl/src/Cardano/Ledger/Alonzo/TxOut.hs | 10 +- .../impl/src/Cardano/Ledger/Alonzo/TxWits.hs | 9 + .../Test/Cardano/Ledger/Alonzo/Arbitrary.hs | 9 +- .../Cardano/Ledger/Alonzo/Binary/Annotator.hs | 5 + .../Ledger/Alonzo/Imp/UtxowSpec/Valid.hs | 10 + .../Alonzo/Translation/TranslationInstance.hs | 7 + .../Test/Cardano/Ledger/Alonzo/TreeDiff.hs | 35 ++- .../Cardano/Ledger/Alonzo/AlonzoEraGen.hs | 6 + .../src/Cardano/Ledger/Babbage/Rules/Utxo.hs | 25 +- .../src/Cardano/Ledger/Babbage/Rules/Utxow.hs | 23 +- .../impl/src/Cardano/Ledger/Babbage/TxInfo.hs | 21 +- .../Test/Cardano/Ledger/Babbage/Arbitrary.hs | 5 + .../Cardano/Ledger/Babbage/Imp/UtxosSpec.hs | 6 + .../Test/Cardano/Ledger/Babbage/TreeDiff.hs | 11 +- .../impl/src/Cardano/Ledger/Conway/Core.hs | 35 ++- .../Ledger/Conway/Governance/DRepPulser.hs | 9 +- .../Ledger/Conway/Governance/Internal.hs | 11 +- .../Ledger/Conway/Governance/Proposals.hs | 8 +- .../impl/src/Cardano/Ledger/Conway/PParams.hs | 33 ++- .../Cardano/Ledger/Conway/Rules/GovCert.hs | 5 + .../Cardano/Ledger/Conway/Rules/NewEpoch.hs | 9 + .../src/Cardano/Ledger/Conway/Rules/Utxo.hs | 13 +- .../src/Cardano/Ledger/Conway/Rules/Utxos.hs | 13 +- .../src/Cardano/Ledger/Conway/Rules/Utxow.hs | 5 + .../impl/src/Cardano/Ledger/Conway/Scripts.hs | 6 + .../Cardano/Ledger/Conway/State/Account.hs | 19 +- .../impl/src/Cardano/Ledger/Conway/TxCert.hs | 20 +- .../impl/src/Cardano/Ledger/Conway/TxInfo.hs | 13 +- .../Test/Cardano/Ledger/Conway/Arbitrary.hs | 33 ++- .../Cardano/Ledger/Conway/Binary/Golden.hs | 10 +- .../Cardano/Ledger/Conway/Binary/RoundTrip.hs | 5 + .../Cardano/Ledger/Conway/Imp/BbodySpec.hs | 6 + .../Test/Cardano/Ledger/Conway/Imp/GovSpec.hs | 8 + .../Cardano/Ledger/Conway/Imp/UtxoSpec.hs | 5 + .../Cardano/Ledger/Conway/Imp/UtxosSpec.hs | 6 + .../Test/Cardano/Ledger/Conway/TreeDiff.hs | 5 + .../src/Cardano/Ledger/Dijkstra/Scripts.hs | 6 + .../src/Cardano/Ledger/Dijkstra/TxCert.hs | 29 ++- .../impl/src/Cardano/Ledger/Dijkstra/UTxO.hs | 5 + .../Test/Cardano/Ledger/Dijkstra/Arbitrary.hs | 11 + .../Cardano/Ledger/Dijkstra/Binary/Golden.hs | 6 + .../Test/Cardano/Ledger/Dijkstra/ImpTest.hs | 17 ++ .../impl/src/Cardano/Ledger/Mary/TxCert.hs | 6 + .../Test/Cardano/Ledger/Mary/Imp/UtxoSpec.hs | 5 + .../src/Test/Cardano/Ledger/AllegraEraGen.hs | 21 ++ .../src/Test/Cardano/Ledger/Mary/Golden.hs | 7 + .../src/Test/Cardano/Ledger/MaryEraGen.hs | 6 + .../Ledger/Allegra/ScriptTranslation.hs | 6 + .../Ledger/Mary/Examples/MultiAssets.hs | 12 + .../Serialisation/Golden/Encoding.hs | 22 ++ .../ShelleyMA/Serialisation/Timelocks.hs | 10 + .../impl/src/Cardano/Ledger/Shelley/Core.hs | 22 ++ .../Cardano/Ledger/Shelley/RewardUpdate.hs | 19 +- .../src/Cardano/Ledger/Shelley/Rules/Deleg.hs | 10 +- .../Cardano/Ledger/Shelley/Rules/Delegs.hs | 7 + .../src/Cardano/Ledger/Shelley/Rules/Delpl.hs | 7 + .../src/Cardano/Ledger/Shelley/Rules/Epoch.hs | 5 + .../src/Cardano/Ledger/Shelley/Rules/Mir.hs | 5 + .../src/Cardano/Ledger/Shelley/Rules/Upec.hs | 7 + .../src/Cardano/Ledger/Shelley/Rules/Utxow.hs | 14 +- .../src/Cardano/Ledger/Shelley/Scripts.hs | 12 + .../Cardano/Ledger/Shelley/State/Account.hs | 19 +- .../src/Cardano/Ledger/Shelley/Transition.hs | 5 + .../impl/src/Cardano/Ledger/Shelley/TxCert.hs | 13 ++ .../impl/src/Cardano/Ledger/Shelley/TxWits.hs | 21 +- .../Test/Cardano/Ledger/Shelley/Arbitrary.hs | 29 ++- .../Ledger/Shelley/Binary/RoundTrip.hs | 5 + .../Cardano/Ledger/Shelley/Imp/UtxowSpec.hs | 6 + .../Test/Cardano/Ledger/Shelley/ImpTest.hs | 7 + .../Cardano/Ledger/Shelley/Generator/Core.hs | 12 + .../Ledger/Shelley/Generator/ShelleyEraGen.hs | 8 + .../Cardano/Ledger/Shelley/Rules/Chain.hs | 19 ++ .../Ledger/Shelley/Rules/ClassifyTraces.hs | 6 + .../src/Test/Cardano/Ledger/Shelley/Utils.hs | 5 + .../test/Test/Cardano/Ledger/Shelley/Fees.hs | 12 + .../Ledger/Shelley/MultiSigExamples.hs | 14 ++ .../Test/Cardano/Ledger/Shelley/RulesTests.hs | 5 + .../Shelley/Serialisation/Golden/Encoding.hs | 14 ++ .../Test/Cardano/Ledger/Shelley/UnitTests.hs | 5 + libs/cardano-data/src/Data/ListMap.hs | 17 +- libs/cardano-data/src/Data/OMap/Strict.hs | 9 +- libs/cardano-data/src/Data/OSet/Strict.hs | 9 +- libs/cardano-data/src/Data/Universe.hs | 4 + .../cardano-data/testlib/Test/Cardano/Data.hs | 12 +- .../src/Cardano/Ledger/Api/Scripts.hs | 46 +++- .../src/Cardano/Ledger/Api/Tx/Cert.hs | 69 +++++- .../Test/Cardano/Ledger/Binary/Twiddle.hs | 9 +- .../Conformance/ExecSpecRule/Conway/Utxow.hs | 9 + .../Conformance/SpecTranslate/Conway/Base.hs | 13 ++ .../src/Cardano/Ledger/BaseTypes.hs | 16 +- .../src/Cardano/Ledger/Core/TxCert.hs | 6 + .../src/Cardano/Ledger/Hashes.hs | 9 +- .../src/Cardano/Ledger/Keys/WitVKey.hs | 9 +- .../src/Cardano/Ledger/State/CertState.hs | 9 +- .../Test/Cardano/Ledger/Core/Arbitrary.hs | 9 +- .../Test/Cardano/Ledger/Core/KeyPair.hs | 11 +- .../cardano-ledger-test.cabal | 4 +- .../Constrained/Conway/Instances/Ledger.hs | 4 + .../Constrained/Conway/LedgerTypes/Tests.hs | 7 + .../Conway/LedgerTypes/WellFormed.hs | 56 ++++- .../Constrained/Conway/WitnessUniverse.hs | 14 +- .../Test/Cardano/Ledger/Examples/AlonzoAPI.hs | 9 + .../Cardano/Ledger/Examples/AlonzoBBODY.hs | 10 + .../Ledger/Examples/AlonzoCollectInputs.hs | 5 + .../Cardano/Ledger/Examples/STSTestUtils.hs | 11 + .../Test/Cardano/Ledger/Generic/Functions.hs | 5 + .../Test/Cardano/Ledger/Generic/GenState.hs | 13 ++ .../Test/Cardano/Ledger/Generic/Instances.hs | 6 + .../Test/Cardano/Ledger/Generic/MockChain.hs | 5 + .../src/Test/Cardano/Ledger/Generic/TxGen.hs | 15 +- .../Cardano/Protocol/Binary/BinarySpec.hs | 5 + .../Test/Cardano/Protocol/TPraos/Arbitrary.hs | 5 + .../test/Tests/Cardano/Ledger/NonIntegral.hs | 17 +- 126 files changed, 1654 insertions(+), 98 deletions(-) diff --git a/cabal.project b/cabal.project index 8db23db08f8..3a288f4b0a1 100644 --- a/cabal.project +++ b/cabal.project @@ -92,7 +92,216 @@ benchmarks: true -- The only sensible test display option test-show-details: streaming -if impl(ghc >=9.12) +allow-newer: + -- https://github.com/phadej/vec/issues/121 + , ral:QuickCheck + , fin:QuickCheck + , bin:QuickCheck + +if impl(ghc >=9.14) + source-repository-package + type: git + -- https://github.com/snowleopard/alga/issues/322 + location: https://github.com/snowleopard/alga/ + tag: d4e43fb42db05413459fb2df493361d5a666588a + + source-repository-package + type: git + location: https://github.com/IntersectMBO/plutus + tag: 47398999ae9660ae288b70165ac846d243c68748 + subdir: + plutus-core + plutus-tx + plutus-ledger-api + +if impl (ghc >= 9.14) + constraints: + , containers > 0.7 + , foldl >= 1.4.18 + , nothunks ^>= 0.2 + , microlens ^>= 0.4 + , microlens-th < 0.4.3.18 + -- Newest version causes Arbitrary instance clashes in quickcheck-instances. + , QuickCheck < 2.17.0.0 + +-- cabal-allow-newer +if impl (ghc >= 9.14) allow-newer: - -- Unique: https://github.com/kapralVV/Unique/issues/11 - , Unique:hashable + , OneTuple:base + , aeson:base + , aeson:bytestring + , aeson:containers + , aeson:deepseq + , aeson:ghc-prim + , aeson:template-haskell + , aeson:text-short + , aeson:time + , aeson:witherable + , assoc:base + , async:base + , base64-bytestring-type:base + , base64-bytestring-type:http-api-data + , bifunctors:containers + , bifunctors:template-haskell + , bin:base + , binary-orphans:base + , boring:base + , boring:tagged + , brick:base + , canonical-json:containers + , cborg:base + , cborg:containers + , concurrent-output:process + , config-ini:containers + , config-ini:megaparsec + , constraints:boring + , constraints:hashable + , constraints-extras:base + , constraints-extras:template-haskell + , containers:base + , containers:template-haskell + , cuddle:foldable1-classes-compat + , cuddle:megaparsec + , data-default:containers + , data-default-class:data-default + , data-fix:base + , dec:base + , deepseq:base + , deepseq:ghc-prim + , dependent-map:constraints-extras + , dependent-map:containers + , deriving-compat:containers + , deriving-compat:template-haskell + , dictionary-sharing:containers + , directory:base + , directory:time + , dom-lt:containers + , filepath:bytestring + , filepath:template-haskell + , fin:base + , fin:universe-base + , foldable1-classes-compat:base + , foldl:containers + , free:containers + , free:template-haskell + , free:transformers + , generically:base + , ghc-heap:containers + , ghc-heap:ghc-internal + , hashable:base + , hashable:bytestring + , hashable:containers + , hashable:ghc-bignum + , hashable:ghc-prim + , hedgehog:async + , hedgehog:containers + , hedgehog:template-haskell + , hedgehog:time + , hsc2hs:base + , http-api-data:base + , http-api-data:containers + , indexed-traversable:base + , indexed-traversable:containers + , indexed-traversable-instances:base + , integer-conversion:base + , integer-logarithms:base + , integer-logarithms:ghc-bignum + , io-classes:base + , io-classes:time + , ledger-state:persistent + , lens:containers + , lens:parallel + , lens:template-haskell + , megaparsec:containers + , microlens-th:containers + , microlens-th:template-haskell + , microstache:base + , microstache:containers + , monoidal-containers:base + , monoidal-containers:containers + , nonempty-vector:base + , nothunks:containers + , nothunks:time + , nothunks:wherefrom-compat + , optics-core:containers + , ordered-containers:containers + , parallel:base + , persistent:template-haskell + , persistent-sqlite:persistent + , plutus-core:dependent-map + , primitive:base + , process:base + , process:directory + , quickcheck-instances:OneTuple + , quickcheck-instances:base + , quickcheck-instances:containers + , quickcheck-instances:data-fix + , quickcheck-instances:time-compat + , ral:base + , recursion-schemes:containers + , recursion-schemes:template-haskell + , scientific:base + , scientific:containers + , scientific:template-haskell + , semialign:base + , semialign:containers + , semialign:indexed-traversable + , semialign:indexed-traversable-instances + , semigroupoids:bifunctors + , serialise:base + , serialise:containers + , serialise:ghc-prim + , serialise:these + , serialise:time + , singletons:base + , singletons-th:base + , singletons-th:singletons + , singletons-th:template-haskell + , singletons-th:th-desugar + , singletons-th:th-orphans + , size-based:template-haskell + , some:base + , splitmix:base + , tagged:template-haskell + , tasty-hedgehog:base + , text:bytestring + , text-iso8601:time + , text-short:base + , text-short:ghc-prim + , text-short:template-haskell + , th-abstraction:containers + , th-abstraction:template-haskell + , th-compat:template-haskell + , th-desugar:template-haskell + , th-expand-syns:base + , th-expand-syns:containers + , th-expand-syns:template-haskell + , th-lift:template-haskell + , th-lift-instances:th-lift + , th-orphans:template-haskell + , these:assoc + , these:base + , time-compat:base + , time-compat:time + , transformers:base + , tree-diff:aeson + , tree-diff:base + , tree-diff:containers + , tree-diff:scientific + , tree-diff:semialign + , tree-diff:time + , tree-diff:unordered-containers + , universe-base:base + , universe-base:containers + , unordered-containers:base + , unordered-containers:template-haskell + , uuid-types:deepseq + , uuid-types:template-haskell + , validation-selective:base + , vault:base + , vault:containers + , vector-th-unbox:base + , vector-th-unbox:template-haskell + , wherefrom-compat:base + , wherefrom-compat:ghc-heap + , witherable:containers diff --git a/eras/allegra/impl/src/Cardano/Ledger/Allegra/Scripts.hs b/eras/allegra/impl/src/Cardano/Ledger/Allegra/Scripts.hs index 767441b9a17..2597c5acf15 100644 --- a/eras/allegra/impl/src/Cardano/Ledger/Allegra/Scripts.hs +++ b/eras/allegra/impl/src/Cardano/Ledger/Allegra/Scripts.hs @@ -41,8 +41,13 @@ module Cardano.Ledger.Allegra.Scripts ( mkTimeExpireTimelock, getTimeExpireTimelock, Timelock (MkTimelock), +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif TimelockRaw (..), inInterval, showTimelock, @@ -94,10 +99,17 @@ import Cardano.Ledger.MemoBytes.Internal (mkMemoBytes) import Cardano.Ledger.Shelley.Scripts ( ShelleyEraScript (..), nativeMultiSigTag, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import Cardano.Slotting.Slot (SlotNo (..)) import Control.DeepSeq (NFData (..)) diff --git a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Arbitrary.hs b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Arbitrary.hs index a65de14b582..e59cc14ae06 100644 --- a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Arbitrary.hs +++ b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Arbitrary.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} @@ -25,16 +26,29 @@ import Cardano.Ledger.Allegra.Scripts ( AllegraEraScript (..), Timelock (..), ValidityInterval (..), +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Allegra.Transition import Cardano.Ledger.Allegra.TxAuxData (AllegraTxAuxData (..)) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Allegra.TxBody (data AllegraTxBody) +#else import Cardano.Ledger.Allegra.TxBody (pattern AllegraTxBody) +#endif import Cardano.Ledger.Core import Cardano.Ledger.Shelley.API (ShelleyTxAuxData (ShelleyTxAuxData)) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireSignature, +#else pattern RequireSignature, +#endif ) import Data.Sequence.Strict (StrictSeq, fromList) import Generic.Random (genericArbitraryU) @@ -69,7 +83,11 @@ instance forall era. ( AllegraEraScript era , Arbitrary (NativeScript era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Arbitrary (Script era) +#endif , Era era ) => Arbitrary (AllegraTxAuxData era) diff --git a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/ImpTest.hs b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/ImpTest.hs index 2c95184ef39..87eef562108 100644 --- a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/ImpTest.hs +++ b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/ImpTest.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE LambdaCase #-} @@ -18,14 +19,26 @@ import Cardano.Ledger.Allegra.Scripts ( AllegraEraScript, Timelock, evalTimelock, +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import qualified Data.Map.Strict as Map import qualified Data.Set as Set diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs index 1b4fa7cfe55..1aeb4228983 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs @@ -1,9 +1,11 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -11,7 +13,11 @@ module Cardano.Ledger.Alonzo ( AlonzoEra, AlonzoTxOut, MaryValue, +#if __GLASGOW_HASKELL__ >= 914 + data AlonzoTxBody, +#else pattern AlonzoTxBody, +#endif AlonzoScript, AlonzoTxAuxData, Tx (..), diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Core.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Core.hs index edb45919d80..6c456f7979c 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Core.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Core.hs @@ -1,4 +1,6 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE TypeFamilies #-} module Cardano.Ledger.Alonzo.Core ( AlonzoEraTx (..), @@ -8,10 +10,17 @@ module Cardano.Ledger.Alonzo.Core ( AsIx (..), AsItem (..), AsIxItem (..), +#if __GLASGOW_HASKELL__ >= 914 + data SpendingPurpose, + data MintingPurpose, + data CertifyingPurpose, + data RewardingPurpose, +#else pattern SpendingPurpose, pattern MintingPurpose, pattern CertifyingPurpose, pattern RewardingPurpose, +#endif ScriptIntegrityHash, AlonzoEraTxBody (..), AlonzoEraTxWits (..), @@ -62,10 +71,17 @@ import Cardano.Ledger.Alonzo.Scripts ( AsItem (..), AsIx (..), AsIxItem (..), +#if __GLASGOW_HASKELL__ >= 914 + data CertifyingPurpose, + data MintingPurpose, + data RewardingPurpose, + data SpendingPurpose, +#else pattern CertifyingPurpose, pattern MintingPurpose, pattern RewardingPurpose, pattern SpendingPurpose, +#endif ) import Cardano.Ledger.Alonzo.Tx (AlonzoEraTx (..), IsValid (..)) import Cardano.Ledger.Alonzo.TxAuxData (AlonzoEraTxAuxData (..)) diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/Evaluate.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/Evaluate.hs index 501621f65bb..5ab393c5d66 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/Evaluate.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/Evaluate.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -54,7 +55,11 @@ import Cardano.Ledger.TxIn (TxIn) import Cardano.Slotting.EpochInfo (EpochInfo) import Cardano.Slotting.Time (SystemStart) import Control.DeepSeq (NFData) +#if __GLASGOW_HASKELL__ >= 914 +import Data.Aeson (ToJSON (..), (.=), data String) +#else import Data.Aeson (ToJSON (..), (.=), pattern String) +#endif import Data.Bifunctor (first) import Data.List (intercalate) import Data.Map.Strict (Map) @@ -272,7 +277,11 @@ data TransactionScriptFailure era deriving instance ( Era era +#if __GLASGOW_HASKELL__ < 914 + -- This constraint is REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (TxCert era) +#endif , Eq (PlutusScript era) , Eq (ContextError era) , Eq (PlutusPurpose AsIx era) @@ -282,7 +291,11 @@ deriving instance deriving instance ( Era era +#if __GLASGOW_HASKELL__ < 914 + -- This constraint is REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Show (TxCert era) +#endif , Show (ContextError era) , Show (PlutusScript era) , Show (PlutusPurpose AsIx era) diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/TxInfo.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/TxInfo.hs index 45b49962de5..26feb30101c 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/TxInfo.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/TxInfo.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -84,7 +85,11 @@ import Cardano.Slotting.Time (SystemStart) import Control.Arrow (left) import Control.DeepSeq (NFData) import Control.Monad (forM, guard) +#if __GLASGOW_HASKELL__ >= 914 +import Data.Aeson (ToJSON (..), data String) +#else import Data.Aeson (ToJSON (..), pattern String) +#endif import Data.ByteString.Short as SBS (fromShort) import Data.Foldable as F (Foldable (..)) import qualified Data.Map.Strict as Map diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxo.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxo.hs index 51c71dec208..940c0b81c68 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxo.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxo.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -193,7 +194,11 @@ deriving stock instance ( Era era , Show (Value era) , Show (TxOut era) +#if __GLASGOW_HASKELL__ < 914 + -- This constraint is REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Show (TxBody TopTx era) +#endif , Show (PredicateFailure (EraRule "UTXOS" era)) ) => Show (AlonzoUtxoPredFailure era) @@ -697,7 +702,11 @@ instance ( Era era , DecCBOR (TxOut era) , DecCBOR (Value era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , EncCBOR (Value era) +#endif , DecCBOR (PredicateFailure (EraRule "UTXOS" era)) ) => DecCBOR (AlonzoUtxoPredFailure era) diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxos.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxos.hs index 49d5b558034..d6d3b588363 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxos.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxos.hs @@ -1,5 +1,6 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -444,18 +445,26 @@ instance deriving stock instance ( AlonzoEraScript era +#if __GLASGOW_HASKELL__ < 914 + -- This constraint is REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Show (TxCert era) - , Show (ContextError era) , Show (Shelley.UTxOState era) +#endif + , Show (ContextError era) , Show (EraRuleFailure "PPUP" era) ) => Show (AlonzoUtxosPredFailure era) deriving stock instance ( AlonzoEraScript era +#if __GLASGOW_HASKELL__ < 914 + -- This constraint is REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (TxCert era) - , Eq (ContextError era) , Eq (Shelley.UTxOState era) +#endif + , Eq (ContextError era) , Eq (EraRuleFailure "PPUP" era) ) => Eq (AlonzoUtxosPredFailure era) diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs index dd8f3487234..1e18c817ee7 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -84,7 +85,9 @@ import Data.Foldable (sequenceA_) import qualified Data.Map.Strict as Map import Data.Set (Set) import qualified Data.Set as Set +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable (Typeable) +#endif import GHC.Generics (Generic) import Lens.Micro import NoThunks.Class @@ -152,14 +155,22 @@ instance InjectRuleFailure "UTXOW" AllegraUtxoPredFailure AlonzoEra where deriving instance ( AlonzoEraScript era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Show (TxCert era) +#endif , Show (PredicateFailure (EraRule "UTXO" era)) ) => Show (AlonzoUtxowPredFailure era) deriving instance ( AlonzoEraScript era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (TxCert era) +#endif , Eq (PredicateFailure (EraRule "UTXO" era)) ) => Eq (AlonzoUtxowPredFailure era) @@ -205,9 +216,13 @@ instance NFData (Event (EraRule "UTXO" era)) => NFData (AlonzoUtxowEvent era) instance ( AlonzoEraScript era - , DecCBOR (TxCert era) , DecCBOR (PredicateFailure (EraRule "UTXO" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , DecCBOR (TxCert era) , Typeable (TxAuxData era) +#endif ) => DecCBOR (AlonzoUtxowPredFailure era) where diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Scripts.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Scripts.hs index 08aac2fbf13..e2256ca7215 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Scripts.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Scripts.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveGeneric #-} @@ -44,10 +45,17 @@ module Cardano.Ledger.Alonzo.Scripts ( lookupPlutusScript, -- ** Plutus Purpose +#if __GLASGOW_HASKELL__ >= 914 + data SpendingPurpose, + data MintingPurpose, + data CertifyingPurpose, + data RewardingPurpose, +#else pattern SpendingPurpose, pattern MintingPurpose, pattern CertifyingPurpose, pattern RewardingPurpose, +#endif AlonzoPlutusPurpose (..), AsItem (..), AsIx (..), diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs index 4b534b19bb3..dd12c8aaecc 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -265,7 +266,13 @@ deriving instance (Era era, Eq (TxBody l era), Eq (TxWits era), Eq (TxAuxData era)) => Eq (AlonzoTx l era) deriving instance - (Era era, Show (TxBody l era), Show (TxAuxData era), Show (Script era), Show (TxWits era)) => + (Era era, Show (TxBody l era), Show (TxAuxData era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Show (Script era) +#endif + , Show (TxWits era)) => Show (AlonzoTx l era) deriving via diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxOut.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxOut.hs index 505223bec82..caeec7fb564 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxOut.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxOut.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -198,7 +199,14 @@ instance (Era era, MemPack (CompactForm (Value era))) => MemPack (AlonzoTxOut er n -> unknownTagM @(AlonzoTxOut era) n {-# INLINE unpackM #-} -deriving stock instance (Eq (Value era), Compactible (Value era)) => Eq (AlonzoTxOut era) +deriving stock instance ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + + Eq (Value era), +#endif + Compactible (Value era)) => Eq (AlonzoTxOut era) deriving instance Generic (AlonzoTxOut era) diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxWits.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxWits.hs index bd94cc842c6..4d1cbd98d64 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxWits.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxWits.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -248,7 +249,11 @@ data AlonzoTxWitsRaw era = AlonzoTxWitsRaw instance ( Era era , NFData (Script era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , NFData (TxDats era) +#endif , NFData (Redeemers era) ) => NFData (AlonzoTxWitsRaw era) @@ -274,7 +279,11 @@ instance AlonzoEraScript era => Monoid (AlonzoTxWits era) where deriving instance ( Era era , NFData (Script era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , NFData (TxDats era) +#endif , NFData (Redeemers era) ) => NFData (AlonzoTxWits era) diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Arbitrary.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Arbitrary.hs index bd839d408ac..e5369072fdb 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Arbitrary.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Arbitrary.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} @@ -347,11 +348,15 @@ instance instance ( Era era - , Arbitrary (PredicateFailure (EraRule "UTXO" era)) , Arbitrary (ShelleyUtxowPredFailure era) - , Arbitrary (TxCert era) , Arbitrary (PlutusPurpose AsItem era) , Arbitrary (PlutusPurpose AsIx era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Arbitrary (PredicateFailure (EraRule "UTXO" era)) + , Arbitrary (TxCert era) +#endif ) => Arbitrary (AlonzoUtxowPredFailure era) where diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Binary/Annotator.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Binary/Annotator.hs index 6c9c4b56dbf..e62986d3151 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Binary/Annotator.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Binary/Annotator.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingVia #-} {-# LANGUAGE FlexibleContexts #-} @@ -48,7 +49,11 @@ instance , DecCBOR (TxBody TopTx era) , DecCBOR (TxAuxData era) , DecCBOR (TxWits era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , DecCBOR (NativeScript era) +#endif ) => DecCBOR (AlonzoBlockBody era) where diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec/Valid.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec/Valid.hs index a6a464b60d9..8928a030f27 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec/Valid.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec/Valid.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NumericUnderscores #-} @@ -12,7 +13,11 @@ module Test.Cardano.Ledger.Alonzo.Imp.UtxowSpec.Valid (spec, alonzoEraSpecificSp import Cardano.Ledger.Address import Cardano.Ledger.Allegra.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, +#else pattern RequireTimeExpire, +#endif ) import Cardano.Ledger.Alonzo.Core import Cardano.Ledger.Alonzo.Scripts (eraLanguages) @@ -29,8 +34,13 @@ import Cardano.Ledger.Plutus ( ) import Cardano.Ledger.Shelley.Rules (ShelleyDelegPredFailure (..)) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireSignature, +#endif ) import qualified Data.Map.Strict as Map import qualified Data.Sequence.Strict as SSeq diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Translation/TranslationInstance.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Translation/TranslationInstance.hs index f61a47e2d2d..11be5f7b3d1 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Translation/TranslationInstance.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Translation/TranslationInstance.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -11,6 +12,12 @@ {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} +#if __GLASGOW_HASKELL__ >= 914 +-- The `ghc-9.14` alpha release has what looks like a bug; +-- https://gitlab.haskell.org/ghc/ghc/-/issues/26381 +{-# OPTIONS_GHC -Wno-redundant-constraints #-} +#endif + module Test.Cardano.Ledger.Alonzo.Translation.TranslationInstance ( TranslationInstance (..), deserializeTranslationInstances, diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/TreeDiff.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/TreeDiff.hs index cae010e5ab4..331a4426af2 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/TreeDiff.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/TreeDiff.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} @@ -75,7 +76,11 @@ instance ToExpr (PlutusPurpose AsIx era) => ToExpr (Redeemers era) instance ( Era era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , ToExpr (TxDats era) +#endif , ToExpr (Redeemers era) , ToExpr (Script era) ) => @@ -83,16 +88,32 @@ instance instance ( Era era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , ToExpr (TxDats era) +#endif , ToExpr (Redeemers era) , ToExpr (Script era) ) => ToExpr (AlonzoTxWits era) -instance ToExpr (Data era) => ToExpr (TxDatsRaw era) - -instance ToExpr (Data era) => ToExpr (TxDats era) +instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + ToExpr (Data era) => +#endif + ToExpr (TxDatsRaw era) +instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + ToExpr (Data era) => +#endif + ToExpr (TxDats era) + -- TxOut instance ToExpr Addr28Extra @@ -186,12 +207,20 @@ instance ToExpr (Event (EraRule "UTXOS" era)) => ToExpr (AlonzoUtxoEvent era) instance ( ToExpr (EraRuleEvent "PPUP" era) , ToExpr (TxOut era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , ToExpr PlutusWithContext +#endif ) => ToExpr (AlonzoUtxosEvent era) instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 ToExpr ScriptHash => +#endif ToExpr PlutusWithContext where toExpr PlutusWithContext {..} = diff --git a/eras/alonzo/test-suite/src/Test/Cardano/Ledger/Alonzo/AlonzoEraGen.hs b/eras/alonzo/test-suite/src/Test/Cardano/Ledger/Alonzo/AlonzoEraGen.hs index e2b21bbf161..f06e469bc02 100644 --- a/eras/alonzo/test-suite/src/Test/Cardano/Ledger/Alonzo/AlonzoEraGen.hs +++ b/eras/alonzo/test-suite/src/Test/Cardano/Ledger/Alonzo/AlonzoEraGen.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} @@ -18,8 +19,13 @@ import Cardano.Ledger.Allegra.Scripts ( AllegraEraScript, Timelock (..), translateTimelock, +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Allegra.TxAuxData (AllegraTxAuxData (..)) import Cardano.Ledger.Alonzo (AlonzoEra, Tx (..)) diff --git a/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs b/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs index c249273f6bb..bf5b36b3d82 100644 --- a/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs +++ b/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -98,7 +99,9 @@ import qualified Data.Map.Strict as Map import Data.Maybe.Strict (StrictMaybe (..)) import Data.Set (Set) import qualified Data.Set as Set +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable (Typeable) +#endif import GHC.Generics (Generic) import Lens.Micro import NoThunks.Class (InspectHeapNamed (..), NoThunks (..)) @@ -149,20 +152,28 @@ instance InjectRuleFailure "UTXO" AlonzoUtxosPredFailure BabbageEra where deriving instance ( Era era , Show (AlonzoUtxoPredFailure era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Show (PredicateFailure (EraRule "UTXO" era)) - , Show (TxOut era) , Show (Script era) , Show TxIn +#endif + , Show (TxOut era) ) => Show (BabbageUtxoPredFailure era) deriving instance ( Era era , Eq (AlonzoUtxoPredFailure era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (PredicateFailure (EraRule "UTXO" era)) - , Eq (TxOut era) , Eq (Script era) , Eq TxIn +#endif + , Eq (TxOut era) ) => Eq (BabbageUtxoPredFailure era) @@ -498,7 +509,11 @@ instance , EncCBOR (TxOut era) , EncCBOR (Value era) , EncCBOR (PredicateFailure (EraRule "UTXOS" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , EncCBOR TxIn +#endif ) => EncCBOR (BabbageUtxoPredFailure era) where @@ -512,12 +527,16 @@ instance instance ( Era era , DecCBOR (TxOut era) - , EncCBOR (Value era) , DecCBOR (Value era) , DecCBOR (PredicateFailure (EraRule "UTXOS" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , DecCBOR (PredicateFailure (EraRule "UTXO" era)) + , EncCBOR (Value era) , Typeable (Script era) , Typeable (TxAuxData era) +#endif ) => DecCBOR (BabbageUtxoPredFailure era) where diff --git a/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxow.hs b/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxow.hs index c873a7298a2..38ee8b6f21d 100644 --- a/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxow.hs +++ b/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxow.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -83,7 +84,9 @@ import Data.Maybe (mapMaybe) import Data.Maybe.Strict (StrictMaybe (..)) import Data.Set (Set) import qualified Data.Set as Set +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable +#endif import GHC.Generics (Generic) import Lens.Micro import Lens.Micro.Extras (view) @@ -136,22 +139,30 @@ instance InjectRuleFailure "UTXOW" AllegraUtxoPredFailure BabbageEra where deriving instance ( AlonzoEraScript era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Show (ShelleyUtxowPredFailure era) - , Show (PredicateFailure (EraRule "UTXO" era)) , Show (PredicateFailure (EraRule "UTXOS" era)) , Show (TxOut era) , Show (TxCert era) , Show (Value era) +#endif + , Show (PredicateFailure (EraRule "UTXO" era)) ) => Show (BabbageUtxowPredFailure era) deriving instance ( AlonzoEraScript era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (ShelleyUtxowPredFailure era) - , Eq (PredicateFailure (EraRule "UTXO" era)) , Eq (PredicateFailure (EraRule "UTXOS" era)) - , Eq (TxOut era) , Eq (TxCert era) + , Eq (TxOut era) +#endif + , Eq (PredicateFailure (EraRule "UTXO" era)) ) => Eq (BabbageUtxowPredFailure era) @@ -171,12 +182,16 @@ instance instance ( AlonzoEraScript era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , DecCBOR (TxOut era) , DecCBOR (TxCert era) , DecCBOR (Value era) , DecCBOR (PredicateFailure (EraRule "UTXOS" era)) - , DecCBOR (PredicateFailure (EraRule "UTXO" era)) , Typeable (TxAuxData era) +#endif + , DecCBOR (PredicateFailure (EraRule "UTXO" era)) ) => DecCBOR (BabbageUtxowPredFailure era) where diff --git a/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxInfo.hs b/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxInfo.hs index 9f1568f911b..7886a8240f4 100644 --- a/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxInfo.hs +++ b/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxInfo.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -83,7 +84,11 @@ import Cardano.Ledger.TxIn (TxIn (..), txInToText) import Control.Arrow (left) import Control.DeepSeq (NFData) import Control.Monad (unless, when, zipWithM) +#if __GLASGOW_HASKELL__ < 914 import Data.Aeson (ToJSON (..), (.=), pattern String) +#else +import Data.Aeson (ToJSON (..), (.=), data String) +#endif import Data.Foldable as F (Foldable (..)) import qualified Data.Map.Strict as Map import qualified Data.Set as Set @@ -254,11 +259,23 @@ data BabbageContextError era deriving (Generic) deriving instance - (Eq (AlonzoContextError era), Eq (PlutusPurpose AsIx era)) => + ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Eq (AlonzoContextError era), +#endif + Eq (PlutusPurpose AsIx era)) => Eq (BabbageContextError era) deriving instance - (Show (AlonzoContextError era), Show (PlutusPurpose AsIx era)) => + ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Show (AlonzoContextError era), +#endif + Show (PlutusPurpose AsIx era)) => Show (BabbageContextError era) instance NoThunks (PlutusPurpose AsIx era) => NoThunks (BabbageContextError era) diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Arbitrary.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Arbitrary.hs index fb27a98fa05..ae5168cee95 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Arbitrary.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Arbitrary.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} @@ -105,7 +106,11 @@ instance instance ( Era era , Arbitrary (PredicateFailure (EraRule "UTXO" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Arbitrary (TxCert era) +#endif , Arbitrary (PlutusPurpose AsItem era) , Arbitrary (PlutusPurpose AsIx era) ) => diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp/UtxosSpec.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp/UtxosSpec.hs index a6e5aa097f0..b2acbbc47b1 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp/UtxosSpec.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp/UtxosSpec.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NumericUnderscores #-} @@ -5,6 +6,7 @@ {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} module Test.Cardano.Ledger.Babbage.Imp.UtxosSpec (spec) where @@ -48,7 +50,11 @@ import Cardano.Ledger.Core ( ) import Cardano.Ledger.Credential (StakeReference (..)) import Cardano.Ledger.Plutus (Language (..), hashPlutusScript, mkInlineDatum, withSLanguage) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Shelley.Scripts (data RequireAllOf) +#else import Cardano.Ledger.Shelley.Scripts (pattern RequireAllOf) +#endif import Lens.Micro import qualified PlutusLedgerApi.V1 as PV1 import Test.Cardano.Ledger.Alonzo.ImpTest diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/TreeDiff.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/TreeDiff.hs index f77836f6970..bdbbb5bebc4 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/TreeDiff.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/TreeDiff.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} @@ -13,7 +14,9 @@ module Test.Cardano.Ledger.Babbage.TreeDiff ( module Test.Cardano.Ledger.Alonzo.TreeDiff, ) where +#if __GLASGOW_HASKELL__ < 914 import Cardano.Ledger.Address +#endif import Cardano.Ledger.Alonzo.Rules import Cardano.Ledger.Babbage (BabbageEra) import Cardano.Ledger.Babbage.Core @@ -43,9 +46,13 @@ instance ToExpr (BabbagePParams Identity era) -- TxOut instance - ( ToExpr CompactAddr - , ToExpr (CompactForm (Value era)) + ( ToExpr (CompactForm (Value era)) , ToExpr (Script era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , ToExpr CompactAddr +#endif ) => ToExpr (BabbageTxOut era) diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Core.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Core.hs index 547f60cfda7..06c9e96ab09 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Core.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Core.hs @@ -1,4 +1,6 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE TypeFamilies #-} module Cardano.Ledger.Conway.Core ( ConwayEraTxBody (..), @@ -27,9 +29,22 @@ module Cardano.Ledger.Conway.Core ( dvtPPEconomicGroupL, dvtUpdateToConstitutionL, ConwayEraScript (..), + ConwayEraTxCert, +#if __GLASGOW_HASKELL__ >= 914 + data VotingPurpose, + data ProposingPurpose, + data RegDepositTxCert, + data UnRegDepositTxCert, + data DelegTxCert, + data RegDepositDelegTxCert, + data AuthCommitteeHotKeyTxCert, + data ResignCommitteeColdTxCert, + data RegDRepTxCert, + data UnRegDRepTxCert, + data UpdateDRepTxCert, +#else pattern VotingPurpose, pattern ProposingPurpose, - ConwayEraTxCert, pattern RegDepositTxCert, pattern UnRegDepositTxCert, pattern DelegTxCert, @@ -39,6 +54,7 @@ module Cardano.Ledger.Conway.Core ( pattern RegDRepTxCert, pattern UnRegDRepTxCert, pattern UpdateDRepTxCert, +#endif module Cardano.Ledger.Babbage.Core, ) where @@ -71,13 +87,29 @@ import Cardano.Ledger.Conway.PParams ( ) import Cardano.Ledger.Conway.Scripts ( ConwayEraScript (..), +#if __GLASGOW_HASKELL__ >= 914 + data ProposingPurpose, + data VotingPurpose, +#else pattern ProposingPurpose, pattern VotingPurpose, +#endif ) import Cardano.Ledger.Conway.Tx () import Cardano.Ledger.Conway.TxBody (ConwayEraTxBody (..)) import Cardano.Ledger.Conway.TxCert ( ConwayEraTxCert, +#if __GLASGOW_HASKELL__ >= 914 + data AuthCommitteeHotKeyTxCert, + data DelegTxCert, + data RegDRepTxCert, + data RegDepositDelegTxCert, + data RegDepositTxCert, + data ResignCommitteeColdTxCert, + data UnRegDRepTxCert, + data UnRegDepositTxCert, + data UpdateDRepTxCert, +#else pattern AuthCommitteeHotKeyTxCert, pattern DelegTxCert, pattern RegDRepTxCert, @@ -87,4 +119,5 @@ import Cardano.Ledger.Conway.TxCert ( pattern UnRegDRepTxCert, pattern UnRegDepositTxCert, pattern UpdateDRepTxCert, +#endif ) diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/DRepPulser.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/DRepPulser.hs index 6b5a96fb288..800fedd40f8 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/DRepPulser.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/DRepPulser.hs @@ -1,5 +1,6 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -315,7 +316,13 @@ instance (EraStake era, ConwayEraAccounts era) => Pulsable (DRepPulser era) wher completeM x@(DRepPulser {}) = pure (snd $ finishDRepPulser @era (DRPulsing x)) deriving instance - (EraPParams era, Show (InstantStake era), Show (Accounts era), Show ans) => + (EraPParams era, Show (InstantStake era), Show (Accounts era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Show ans +#endif + ) => Show (DRepPulser era m ans) instance diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Internal.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Internal.hs index 8aa8968b123..926798f54ec 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Internal.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Internal.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -123,7 +124,9 @@ import Data.Sequence.Strict (StrictSeq (..)) import qualified Data.Sequence.Strict as SS import Data.Set (Set) import qualified Data.Set as Set +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable +#endif import GHC.Generics (Generic) import Lens.Micro import NoThunks.Class (NoThunks (..), allNoThunks) @@ -609,7 +612,13 @@ instance (Default (InstantStake era), Default (Accounts era)) => Default (Ratify Map.empty instance - (Typeable era, NoThunks (InstantStake era), NoThunks (Accounts era)) => + ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable era, +#endif + NoThunks (InstantStake era), NoThunks (Accounts era)) => NoThunks (RatifyEnv era) where showTypeOf _ = "RatifyEnv" diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Proposals.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Proposals.hs index 95e28bdde8a..6900911251f 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Proposals.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Proposals.hs @@ -716,11 +716,11 @@ toPTree (ChildParent childParent) root (PGraph fullGraph) = do childToTree parent child (!graph, !acc) = case Map.lookup child graph of Nothing -> Left $ "Cannot find the node: " ++ show child - Just edges -> do - unless (peParent edges == parent) $ + Just es -> do + unless (peParent es == parent) $ Left $ "Incorrect parent: " - ++ show (peParent edges) + ++ show (peParent es) ++ " listed for the node: " ++ show child case Map.lookup child childParent of @@ -738,7 +738,7 @@ toPTree (ChildParent childParent) root (PGraph fullGraph) = do (graph', !subTree) <- -- Deleting the child from the graph ensures that every node except the root -- appears exactly once in the graph. - nodeToTree (SJust child) (peChildren edges) (Map.delete child graph) + nodeToTree (SJust child) (peChildren es) (Map.delete child graph) pure (graph', subTree : acc) -- | Verify invariant after addition of GovActionState to Proposals. Will print the state diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/PParams.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/PParams.hs index f1122291d93..ac9b6bde50c 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/PParams.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/PParams.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveGeneric #-} @@ -598,16 +599,40 @@ instance EncCBOR a => EncCBOR (THKD t StrictMaybe a) where instance (Typeable t, DecCBOR a) => DecCBOR (THKD t StrictMaybe a) where decCBOR = THKD <$> decCBOR -instance (Typeable t, ToJSON a) => ToJSON (THKD t Identity a) where +instance ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable t, +#endif + ToJSON a) => ToJSON (THKD t Identity a) where toJSON = toJSON . unTHKD -instance (Typeable t, FromJSON a) => FromJSON (THKD t Identity a) where +instance ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable t, +#endif + FromJSON a) => FromJSON (THKD t Identity a) where parseJSON = fmap THKD . parseJSON -instance (Typeable t, ToJSON a) => ToJSON (THKD t StrictMaybe a) where +instance ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable t, +#endif + ToJSON a) => ToJSON (THKD t StrictMaybe a) where toJSON = toJSON . unTHKD -instance (Typeable t, FromJSON a) => FromJSON (THKD t StrictMaybe a) where +instance ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable t, +#endif + FromJSON a) => FromJSON (THKD t StrictMaybe a) where parseJSON = fmap THKD . parseJSON ppGroup :: diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/GovCert.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/GovCert.hs index 3850a78e54f..5e5518c5979 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/GovCert.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/GovCert.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE EmptyDataDeriving #-} @@ -153,8 +154,12 @@ instance , Signal (EraRule "GOVCERT" era) ~ ConwayGovCert , Environment (EraRule "GOVCERT" era) ~ ConwayGovCertEnv era , EraRule "GOVCERT" era ~ ConwayGOVCERT era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (PredicateFailure (EraRule "GOVCERT" era)) , Show (PredicateFailure (EraRule "GOVCERT" era)) +#endif , ConwayEraCertState era ) => STS (ConwayGOVCERT era) diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/NewEpoch.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/NewEpoch.hs index 96e5e0a2390..787cb90a6fe 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/NewEpoch.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/NewEpoch.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -107,8 +108,12 @@ instance , GovState era ~ ConwayGovState era , Eq (PredicateFailure (EraRule "RATIFY" era)) , Show (PredicateFailure (EraRule "RATIFY" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (PredicateFailure (ConwayNEWEPOCH era)) , Show (PredicateFailure (ConwayNEWEPOCH era)) +#endif ) => STS (ConwayNEWEPOCH era) where @@ -150,8 +155,12 @@ newEpochTransition :: , GovState era ~ ConwayGovState era , Eq (PredicateFailure (EraRule "RATIFY" era)) , Show (PredicateFailure (EraRule "RATIFY" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (PredicateFailure (ConwayNEWEPOCH era)) , Show (PredicateFailure (ConwayNEWEPOCH era)) +#endif ) => TransitionRule (ConwayNEWEPOCH era) newEpochTransition = do diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs index cfda453090a..2e33bfad176 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -187,8 +188,12 @@ deriving instance , Show (Value era) , Show (PredicateFailure (EraRule "UTXOS" era)) , Show (TxOut era) - , Show (Script era) - , Show TxIn +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Eq (Script era) + , Eq TxIn +#endif ) => Show (ConwayUtxoPredFailure era) @@ -197,8 +202,12 @@ deriving instance , Eq (Value era) , Eq (PredicateFailure (EraRule "UTXOS" era)) , Eq (TxOut era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (Script era) , Eq TxIn +#endif ) => Eq (ConwayUtxoPredFailure era) diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxos.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxos.hs index d4fbe786501..3e864a6c73f 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxos.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxos.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -164,17 +165,25 @@ instance deriving stock instance ( ConwayEraScript era - , Show (TxCert era) , Show (ContextError era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Show (TxCert era) , Show (UTxOState era) +#endif ) => Show (ConwayUtxosPredFailure era) deriving stock instance ( ConwayEraScript era - , Eq (TxCert era) , Eq (ContextError era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Eq (TxCert era) , Eq (UTxOState era) +#endif ) => Eq (ConwayUtxosPredFailure era) diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs index f60ff27393a..9442d7a93f7 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -212,8 +213,12 @@ instance , Environment (EraRule "UTXO" era) ~ Shelley.UtxoEnv era , State (EraRule "UTXO" era) ~ Shelley.UTxOState era , Signal (EraRule "UTXO" era) ~ Tx TopTx era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (PredicateFailure (EraRule "UTXOS" era)) , Show (PredicateFailure (EraRule "UTXOS" era)) +#endif ) => STS (ConwayUTXOW era) where diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Scripts.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Scripts.hs index 71f49af77c0..6e50094b2f3 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Scripts.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Scripts.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -21,8 +22,13 @@ module Cardano.Ledger.Conway.Scripts ( PlutusScript (..), isPlutusScript, ConwayPlutusPurpose (..), +#if __GLASGOW_HASKELL__ >= 914 + data VotingPurpose, + data ProposingPurpose, +#else pattern VotingPurpose, pattern ProposingPurpose, +#endif ) where import Cardano.Ledger.Address (RewardAccount) diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/State/Account.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/State/Account.hs index cc25a9cad8d..a008d5d6d51 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/State/Account.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/State/Account.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveGeneric #-} @@ -37,7 +38,9 @@ import Data.Default import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import qualified Data.MapExtras as Map (extract) +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable +#endif import GHC.Generics import Lens.Micro import NoThunks.Class (NoThunks (..)) @@ -69,7 +72,13 @@ instance EncCBOR (ConwayAccountState era) where <> encodeNullStrictMaybe encCBOR casStakePoolDelegation <> encodeNullStrictMaybe encCBOR casDRepDelegation -instance Typeable era => DecShareCBOR (ConwayAccountState era) where +instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable era => +#endif + DecShareCBOR (ConwayAccountState era) where type Share (ConwayAccountState era) = (Interns (KeyHash 'StakePool), Interns (Credential 'DRepRole)) @@ -99,7 +108,13 @@ newtype ConwayAccounts era = ConwayAccounts } deriving (Show, Eq, Generic, EncCBOR, NoThunks, NFData, Default, ToJSON) -instance Typeable era => DecShareCBOR (ConwayAccounts era) where +instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable era => +#endif + DecShareCBOR (ConwayAccounts era) where type Share (ConwayAccounts era) = (Interns (Credential 'Staking), Interns (KeyHash 'StakePool), Interns (Credential 'DRepRole)) diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/TxCert.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/TxCert.hs index ff1584a72da..3a1c7f23b05 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/TxCert.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/TxCert.hs @@ -40,6 +40,17 @@ module Cardano.Ledger.Conway.TxCert ( conwayDRepRefundsTxCerts, conwayTotalDepositsTxCerts, conwayTotalRefundsTxCerts, +#if __GLASGOW_HASKELL__ >= 914 + data RegDepositTxCert, + data UnRegDepositTxCert, + data DelegTxCert, + data RegDepositDelegTxCert, + data AuthCommitteeHotKeyTxCert, + data ResignCommitteeColdTxCert, + data RegDRepTxCert, + data UnRegDRepTxCert, + data UpdateDRepTxCert, +#else pattern RegDepositTxCert, pattern UnRegDepositTxCert, pattern DelegTxCert, @@ -49,6 +60,7 @@ module Cardano.Ledger.Conway.TxCert ( pattern RegDRepTxCert, pattern UnRegDRepTxCert, pattern UpdateDRepTxCert, +#endif ) where import Cardano.Ledger.Babbage.Core @@ -705,7 +717,13 @@ conwayTxCertDelegDecoder = \case {-# INLINE regDelegCertDecoder #-} {-# INLINE conwayTxCertDelegDecoder #-} -instance (Era era, Val (Value era)) => ToCBOR (ConwayTxCert era) where +instance (Era era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Val (Value era) +#endif + ) => ToCBOR (ConwayTxCert era) where toCBOR = toPlainEncoding (eraProtVerLow @era) . encCBOR instance Era era => EncCBOR (ConwayTxCert era) where diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs index 3a5ae3bfa9f..c28e7f7e99b 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -184,7 +185,12 @@ deriving instance ( Eq (BabbageContextError era) , Eq (TxCert era) , Eq (PlutusPurpose AsItem era) - , Eq (PlutusPurpose AsIx era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + + , Show (PlutusPurpose AsIx era) +#endif , EraPParams era ) => Eq (ConwayContextError era) @@ -193,7 +199,12 @@ deriving instance ( Show (BabbageContextError era) , Show (TxCert era) , Show (PlutusPurpose AsItem era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Show (PlutusPurpose AsIx era) +#endif , EraPParams era ) => Show (ConwayContextError era) diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Arbitrary.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Arbitrary.hs index ac13fb02e1f..2f4b85c311e 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Arbitrary.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Arbitrary.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} @@ -85,7 +86,13 @@ instance arbitrary = PulsingSnapshot <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary instance - (Arbitrary (InstantStake era), Arbitrary (PParams era), Arbitrary (PParamsUpdate era), Era era) => + ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Arbitrary (InstantStake era), +#endif + Arbitrary (PParams era), Arbitrary (PParamsUpdate era), Era era) => Arbitrary (DRepPulsingState era) where arbitrary = DRComplete <$> arbitrary <*> arbitrary @@ -180,7 +187,11 @@ deriving instance Arbitrary (ConwayInstantStake era) instance ( EraPParams era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Arbitrary (InstantStake era) +#endif , Arbitrary (PParams era) , Arbitrary (PParamsHKD StrictMaybe era) ) => @@ -269,7 +280,11 @@ instance instance ( Era era , Arbitrary (PredicateFailure (EraRule "UTXO" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Arbitrary (TxCert era) +#endif , Arbitrary (PlutusPurpose AsItem era) , Arbitrary (PlutusPurpose AsIx era) ) => @@ -299,7 +314,13 @@ data ProposalsForEnactment era deriving (Show, Eq) instance - (EraPParams era, Arbitrary (PParamsUpdate era), Arbitrary (PParamsHKD StrictMaybe era)) => + (EraPParams era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Arbitrary (PParamsUpdate era) +#endif + , Arbitrary (PParamsHKD StrictMaybe era)) => Arbitrary (ProposalsForEnactment era) where arbitrary = do @@ -374,7 +395,13 @@ data ProposalsNewActions era = ProposalsNewActions (Proposals era) [GovActionSta deriving (Show, Eq) instance - (EraPParams era, Arbitrary (PParamsUpdate era), Arbitrary (PParamsHKD StrictMaybe era)) => + (EraPParams era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Arbitrary (PParamsUpdate era) +#endif + , Arbitrary (PParamsHKD StrictMaybe era)) => Arbitrary (ProposalsNewActions era) where arbitrary = do diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Binary/Golden.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Binary/Golden.hs index 9d936bc3fe3..0e01492a878 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Binary/Golden.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Binary/Golden.hs @@ -1,10 +1,12 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wno-unused-foralls #-} @@ -18,7 +20,11 @@ module Test.Cardano.Ledger.Conway.Binary.Golden ( import Cardano.Ledger.Alonzo.Core ( AsIx (..), eraProtVerLow, +#if __GLASGOW_HASKELL__ < 914 pattern SpendingPurpose, +#else + data SpendingPurpose, +#endif ) import Cardano.Ledger.Alonzo.Scripts (ExUnits (..)) import Cardano.Ledger.Alonzo.TxWits (Redeemers (..), unRedeemers) @@ -33,7 +39,7 @@ import Cardano.Ledger.Binary ( import Cardano.Ledger.Binary.Plain (DecoderError (..), Tokens (..)) import Cardano.Ledger.Plutus (Data (..)) import qualified Data.Map as Map -import Data.Typeable (Proxy (..), Typeable) +import Data.Typeable (Proxy (..)) import PlutusLedgerApi.Common (Data (..)) import Test.Cardano.Ledger.Binary.Plain.Golden (Enc (..)) import Test.Cardano.Ledger.Binary.RoundTrip (embedTripAnnExpectation) @@ -52,7 +58,7 @@ import Test.Cardano.Ledger.Conway.Era (ConwayEraTest) expectDecoderFailureAnn :: forall a. - (ToExpr a, DecCBOR (Annotator a), Typeable a, HasCallStack) => + (ToExpr a, DecCBOR (Annotator a), HasCallStack) => Version -> Enc -> DecoderError -> diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Binary/RoundTrip.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Binary/RoundTrip.hs index 15ad0778aec..1ff61f6c6e3 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Binary/RoundTrip.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Binary/RoundTrip.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -39,7 +40,11 @@ roundTripConwayEraTypesSpec :: ( Arbitrary (PParams era) , Arbitrary (PParamsUpdate era) , Arbitrary (PParamsHKD StrictMaybe era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Arbitrary (InstantStake era) +#endif , EraPParams era , EraStake era , ConwayEraAccounts era diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs index 923479bfbbb..b1265071db4 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NamedFieldPuns #-} @@ -7,6 +8,7 @@ {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} module Test.Cardano.Ledger.Conway.Imp.BbodySpec ( spec, @@ -30,7 +32,11 @@ import Cardano.Ledger.Shelley.Rules ( ShelleyBbodyState (..), ) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireSignature, +#else pattern RequireSignature, +#endif ) import Cardano.Ledger.TxIn import Control.Monad (forM) diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovSpec.hs index 83f1331af1c..e3c11887fc0 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovSpec.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NumericUnderscores #-} @@ -22,10 +23,17 @@ import Cardano.Ledger.Credential (Credential (KeyHashObj)) import Cardano.Ledger.Plutus.CostModels (updateCostModels) import Cardano.Ledger.Shelley.LedgerState import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.Val (zero, (<->)) import Data.Default (Default (..)) diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs index 8d3b24ca289..7bdd3bc169f 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLists #-} @@ -24,7 +25,11 @@ import Cardano.Ledger.Credential import Cardano.Ledger.Plutus.Language (SLanguage (..)) import Cardano.Ledger.Shelley.LedgerState import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireSignature, +#else pattern RequireSignature, +#endif ) import Cardano.Ledger.Shelley.UTxO (getShelleyMinFeeTxUtxo) import Cardano.Ledger.State diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxosSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxosSpec.hs index 1f4694bba58..7b44f9f2c36 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxosSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxosSpec.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} @@ -7,12 +8,17 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} module Test.Cardano.Ledger.Conway.Imp.UtxosSpec (spec) where import Cardano.Ledger.Address (Addr (..)) import Cardano.Ledger.Allegra.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeStart, +#else pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Alonzo.Plutus.Context (EraPlutusContext (..)) import Cardano.Ledger.Alonzo.Plutus.Evaluate (CollectError (..)) diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/TreeDiff.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/TreeDiff.hs index 0344e603470..97d9804979e 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/TreeDiff.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/TreeDiff.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -149,7 +150,11 @@ instance ( EraStake era , EraPParams era , ConwayEraAccounts era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , ToExpr (DRepPulsingState era) +#endif , ToExpr (RatifyState era) , ToExpr (PParamsHKD StrictMaybe era) ) => diff --git a/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Scripts.hs b/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Scripts.hs index cfac37ddc98..700d36e1ffe 100644 --- a/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Scripts.hs +++ b/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Scripts.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -27,8 +28,13 @@ module Cardano.Ledger.Dijkstra.Scripts ( DijkstraEraScript (..), DijkstraNativeScript (MkDijkstraNativeScript), DijkstraNativeScriptRaw (..), +#if __GLASGOW_HASKELL__ >= 914 + data GuardingPurpose, + data RequireGuard, +#else pattern GuardingPurpose, pattern RequireGuard, +#endif evalDijkstraNativeScript, upgradeTimelock, ) where diff --git a/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/TxCert.hs b/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/TxCert.hs index 4c4a5b8c7fc..a8c6ef26a75 100644 --- a/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/TxCert.hs +++ b/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/TxCert.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -34,6 +35,7 @@ import Cardano.Ledger.Coin (Coin) import Cardano.Ledger.Conway.Core ( ConwayEraTxCert, poolCertKeyHashWitness, +#if __GLASGOW_HASKELL__ < 914 pattern AuthCommitteeHotKeyTxCert, pattern DelegTxCert, pattern RegDRepTxCert, @@ -47,6 +49,21 @@ import Cardano.Ledger.Conway.Core ( pattern UnRegDepositTxCert, pattern UnRegTxCert, pattern UpdateDRepTxCert, +#else + data AuthCommitteeHotKeyTxCert, + data DelegTxCert, + data RegDRepTxCert, + data RegDepositDelegTxCert, + data RegDepositTxCert, + data RegPoolTxCert, + data RegTxCert, + data ResignCommitteeColdTxCert, + data RetirePoolTxCert, + data UnRegDRepTxCert, + data UnRegDepositTxCert, + data UnRegTxCert, + data UpdateDRepTxCert, +#endif ) import Cardano.Ledger.Conway.TxCert ( ConwayEraTxCert (..), @@ -64,7 +81,9 @@ import Cardano.Ledger.Core ( KeyRole (..), PoolCert (..), ScriptHash, +#if __GLASGOW_HASKELL__ < 914 Value, +#endif eraProtVerLow, fromEraCBOR, ) @@ -77,7 +96,9 @@ import Cardano.Ledger.Shelley.TxCert ( encodeShelleyDelegCert, poolTxCertDecoder, ) +#if __GLASGOW_HASKELL__ < 914 import Cardano.Ledger.Val (Val) +#endif import Control.DeepSeq (NFData) import Data.Aeson (KeyValue ((.=)), ToJSON (..)) import GHC.Generics (Generic) @@ -214,7 +235,13 @@ instance | 7 <= t -> conwayTxCertDelegDecoder t t -> invalidKey t -instance (Era era, Val (Value era)) => ToCBOR (DijkstraTxCert era) where +instance (Era era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Val (Value era) +#endif + ) => ToCBOR (DijkstraTxCert era) where toCBOR = toPlainEncoding (eraProtVerLow @era) . encCBOR instance Era era => EncCBOR (DijkstraTxCert era) where diff --git a/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/UTxO.hs b/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/UTxO.hs index e50696f44f0..f03e87121bd 100644 --- a/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/UTxO.hs +++ b/eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/UTxO.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE TypeFamilies #-} @@ -30,7 +31,11 @@ import Cardano.Ledger.Conway.UTxO ( import Cardano.Ledger.Credential (credScriptHash) import Cardano.Ledger.Dijkstra.Core import Cardano.Ledger.Dijkstra.Era (DijkstraEra) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Dijkstra.Scripts (DijkstraEraScript (..), data GuardingPurpose) +#else import Cardano.Ledger.Dijkstra.Scripts (DijkstraEraScript (..), pattern GuardingPurpose) +#endif import Cardano.Ledger.Dijkstra.State import Cardano.Ledger.Dijkstra.Tx () import Cardano.Ledger.Dijkstra.TxBody (DijkstraEraTxBody (..)) diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Arbitrary.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Arbitrary.hs index 0be7178a430..af1bc4a6a28 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Arbitrary.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Arbitrary.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -10,14 +11,20 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} module Test.Cardano.Ledger.Dijkstra.Arbitrary () where import Cardano.Ledger.Allegra.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.BaseTypes (StrictMaybe) import Cardano.Ledger.Dijkstra (DijkstraEra) @@ -30,7 +37,11 @@ import Cardano.Ledger.Dijkstra.Tx (DijkstraTx (..), Tx (..)) import Cardano.Ledger.Dijkstra.TxBody (TxBody (..)) import Cardano.Ledger.Dijkstra.TxCert import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireSignature, +#else pattern RequireSignature, +#endif ) import Data.Functor.Identity (Identity) import Data.Typeable (Typeable) diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Binary/Golden.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Binary/Golden.hs index fe850f5557e..af384e16e96 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Binary/Golden.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Binary/Golden.hs @@ -1,9 +1,11 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} module Test.Cardano.Ledger.Dijkstra.Binary.Golden ( spec, @@ -20,7 +22,11 @@ import Cardano.Ledger.Dijkstra.Core ( EraTxOut (..), TxLevel (..), eraProtVerLow, +#if __GLASGOW_HASKELL__ < 914 pattern DelegTxCert, +#else + data DelegTxCert, +#endif ) import Cardano.Ledger.TxIn (TxIn (..)) import qualified Data.Set as Set diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs index 7216814cd10..59ce30aaec9 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NumericUnderscores #-} @@ -17,8 +18,13 @@ module Test.Cardano.Ledger.Dijkstra.ImpTest ( ) where import Cardano.Ledger.Allegra.Scripts ( +#if __GLASGOW_HASKELL__ < 914 pattern RequireTimeExpire, pattern RequireTimeStart, +#else + data RequireTimeExpire, + data RequireTimeStart, +#endif ) import Cardano.Ledger.BaseTypes import Cardano.Ledger.Compactible @@ -38,7 +44,11 @@ import Cardano.Ledger.Dijkstra.PParams (UpgradeDijkstraPParams (..)) import Cardano.Ledger.Dijkstra.Scripts ( DijkstraNativeScript, evalDijkstraNativeScript, +#if __GLASGOW_HASKELL__ < 914 pattern RequireGuard, +#else + data RequireGuard, +#endif ) import Cardano.Ledger.Dijkstra.TxBody (DijkstraEraTxBody (..)) import Cardano.Ledger.Plutus (SLanguage (..)) @@ -46,10 +56,17 @@ import Cardano.Ledger.Shelley.LedgerState import Cardano.Ledger.Shelley.Rules (ShelleyDelegPredFailure) import qualified Cardano.Ledger.Shelley.Rules as Shelley import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ < 914 pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#else + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#endif ) import Cardano.Ledger.State import qualified Data.Map.Strict as Map diff --git a/eras/mary/impl/src/Cardano/Ledger/Mary/TxCert.hs b/eras/mary/impl/src/Cardano/Ledger/Mary/TxCert.hs index 71c8955a297..7c98064837d 100644 --- a/eras/mary/impl/src/Cardano/Ledger/Mary/TxCert.hs +++ b/eras/mary/impl/src/Cardano/Ledger/Mary/TxCert.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE TypeFamilies #-} @@ -18,8 +19,13 @@ import Cardano.Ledger.Shelley.TxCert ( shelleyTotalDepositsTxCerts, shelleyTotalRefundsTxCerts, upgradeShelleyTxCert, +#if __GLASGOW_HASKELL__ >= 914 + data RegTxCert, + data UnRegTxCert, +#else pattern RegTxCert, pattern UnRegTxCert, +#endif ) instance EraTxCert MaryEra where diff --git a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp/UtxoSpec.hs b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp/UtxoSpec.hs index 2736a126299..a55eeca62dd 100644 --- a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp/UtxoSpec.hs +++ b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp/UtxoSpec.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLists #-} @@ -12,7 +13,11 @@ import Cardano.Ledger.Mary.Core import Cardano.Ledger.Mary.Value import Cardano.Ledger.Shelley.Rules (ShelleyUtxoPredFailure (..)) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireSignature, +#else pattern RequireSignature, +#endif ) import qualified Data.Map.Strict as Map import Data.Sequence.Strict (StrictSeq (..)) diff --git a/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/AllegraEraGen.hs b/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/AllegraEraGen.hs index 6d75a1b7661..dfb389e42e2 100644 --- a/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/AllegraEraGen.hs +++ b/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/AllegraEraGen.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -24,8 +25,13 @@ import Cardano.Ledger.Allegra.Core import Cardano.Ledger.Allegra.Scripts ( AllegraEraScript, Timelock (..), +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Allegra.TxBody (TxBody (AllegraTxBody)) import Cardano.Ledger.BaseTypes (StrictMaybe (..)) @@ -33,14 +39,29 @@ import Cardano.Ledger.Binary (encCBOR, serialize') import Cardano.Ledger.Coin (Coin) import Cardano.Ledger.Shelley.PParams (Update) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Shelley.Tx (data ShelleyTx) +#else import Cardano.Ledger.Shelley.Tx (pattern ShelleyTx) +#endif import Cardano.Ledger.Shelley.TxOut (ShelleyTxOut (..)) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Shelley.TxWits (data ShelleyTxWits) +#else import Cardano.Ledger.Shelley.TxWits (pattern ShelleyTxWits) +#endif import Cardano.Ledger.TxIn (TxIn) import Cardano.Ledger.Val ((<+>)) import Cardano.Slotting.Slot (SlotNo (SlotNo)) diff --git a/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/Mary/Golden.hs b/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/Mary/Golden.hs index f400b83d299..1ddd6fbb87a 100644 --- a/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/Mary/Golden.hs +++ b/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/Mary/Golden.hs @@ -1,6 +1,8 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} -- | -- Module : Test.Cardano.Ledger.Mary.Golden @@ -18,8 +20,13 @@ module Test.Cardano.Ledger.Mary.Golden ( ) where import Cardano.Ledger.Allegra.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Core (hashScript) diff --git a/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/MaryEraGen.hs b/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/MaryEraGen.hs index 5114f63a9d7..0ead5bda4da 100644 --- a/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/MaryEraGen.hs +++ b/eras/shelley-ma/test-suite/src/Test/Cardano/Ledger/MaryEraGen.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -34,8 +35,13 @@ import Cardano.Ledger.Mary.Value ( ) import Cardano.Ledger.Shelley.PParams (Update) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.Shelley.TxBody (Withdrawals) import Cardano.Ledger.Shelley.TxOut (ShelleyTxOut (..)) diff --git a/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/Allegra/ScriptTranslation.hs b/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/Allegra/ScriptTranslation.hs index 28a2ad86737..3f6403daa37 100644 --- a/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/Allegra/ScriptTranslation.hs +++ b/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/Allegra/ScriptTranslation.hs @@ -1,5 +1,7 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} module Test.Cardano.Ledger.Allegra.ScriptTranslation ( testScriptPostTranslation, @@ -14,7 +16,11 @@ import Cardano.Ledger.Shelley.Core import Cardano.Ledger.Shelley.LedgerState (LedgerState (..)) import Cardano.Ledger.Shelley.Scripts ( MultiSig, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, +#else pattern RequireAllOf, +#endif ) import qualified Cardano.Ledger.Val as Val import Cardano.Slotting.Slot (SlotNo (..)) diff --git a/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/Mary/Examples/MultiAssets.hs b/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/Mary/Examples/MultiAssets.hs index d5aea9118a9..9bdc04aa1d7 100644 --- a/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/Mary/Examples/MultiAssets.hs +++ b/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/Mary/Examples/MultiAssets.hs @@ -1,7 +1,9 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} -- | -- Module : Test.Cardano.Ledger.Mary.Examples.MultiAssets @@ -15,8 +17,13 @@ module Test.Cardano.Ledger.Mary.Examples.MultiAssets ( import Cardano.Ledger.Allegra.Rules (AllegraUtxoPredFailure (..)) import Cardano.Ledger.Allegra.Scripts ( Timelock (..), +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.BaseTypes (StrictMaybe (..)) import Cardano.Ledger.Coin (Coin (..)) @@ -33,8 +40,13 @@ import Cardano.Ledger.Mary.Value ( import Cardano.Ledger.Shelley.API (LedgerEnv (..), ShelleyLEDGER) import Cardano.Ledger.Shelley.Rules (ShelleyLedgerPredFailure (..), ShelleyUtxowPredFailure (..)) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.Shelley.Tx (ShelleyTx (..)) import Cardano.Ledger.Shelley.TxOut (ShelleyTxOut (..)) diff --git a/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/ShelleyMA/Serialisation/Golden/Encoding.hs b/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/ShelleyMA/Serialisation/Golden/Encoding.hs index a2c7b9417fa..b1f83581399 100644 --- a/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/ShelleyMA/Serialisation/Golden/Encoding.hs +++ b/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/ShelleyMA/Serialisation/Golden/Encoding.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} @@ -15,10 +16,19 @@ import Cardano.Ledger.Address (Addr (..), RewardAccount (..)) import Cardano.Ledger.Allegra (AllegraEra) import Cardano.Ledger.Allegra.Scripts ( AllegraEraScript, +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Allegra.TxAuxData (data AllegraTxAuxData) +#else import Cardano.Ledger.Allegra.TxAuxData (pattern AllegraTxAuxData) +#endif import Cardano.Ledger.Allegra.TxBody (TxBody (..)) import Cardano.Ledger.BaseTypes (Network (..), StrictMaybe (..)) import Cardano.Ledger.Binary (DecCBOR) @@ -30,15 +40,27 @@ import Cardano.Ledger.Mary.TxBody (TxBody (..)) import Cardano.Ledger.Mary.Value (AssetName (..), MaryValue (..), MultiAsset (..), PolicyID (..)) import Cardano.Ledger.Shelley.PParams ( Update, +#if __GLASGOW_HASKELL__ >= 914 + data ProposedPPUpdates, + data Update, +#else pattern ProposedPPUpdates, pattern Update, +#endif ) import Cardano.Ledger.Shelley.Scripts ( ShelleyEraScript, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import qualified Cardano.Ledger.Shelley.TxAuxData as TxAuxData import Cardano.Ledger.Shelley.TxOut (ShelleyTxOut (..)) diff --git a/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/ShelleyMA/Serialisation/Timelocks.hs b/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/ShelleyMA/Serialisation/Timelocks.hs index cec8ed5b068..34bdbe56a4c 100644 --- a/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/ShelleyMA/Serialisation/Timelocks.hs +++ b/eras/shelley-ma/test-suite/test/Test/Cardano/Ledger/ShelleyMA/Serialisation/Timelocks.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -15,8 +16,13 @@ import Cardano.Ledger.Allegra (AllegraEra) import Cardano.Ledger.Allegra.Scripts ( AllegraEraScript, Timelock (..), +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Binary (natVersion) import Cardano.Ledger.Core @@ -24,7 +30,11 @@ import Cardano.Ledger.Mary (MaryEra) import Cardano.Ledger.Shelley (ShelleyEra) import Cardano.Ledger.Shelley.Scripts ( MultiSig, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, +#else pattern RequireAllOf, +#endif ) import Cardano.Slotting.Slot (SlotNo (..)) import Data.Sequence.Strict (fromList) diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Core.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Core.hs index f63effb7feb..300d6742564 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Core.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Core.hs @@ -1,17 +1,31 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE TypeFamilies #-} module Cardano.Ledger.Shelley.Core ( ShelleyEraTxBody (..), Withdrawals (..), ShelleyEraTxCert (..), +#if __GLASGOW_HASKELL__ >= 914 + data MirTxCert, +#else pattern MirTxCert, +#endif + MIRCert (..), MIRPot (..), MIRTarget (..), +#if __GLASGOW_HASKELL__ >= 914 + data GenesisDelegTxCert, + data RegTxCert, + data UnRegTxCert, + data DelegStakeTxCert, +#else pattern GenesisDelegTxCert, pattern RegTxCert, pattern UnRegTxCert, pattern DelegStakeTxCert, +#endif module Cardano.Ledger.Core, module Cardano.Ledger.Shelley.Governance, ) where @@ -37,9 +51,17 @@ import Cardano.Ledger.Shelley.TxCert ( MIRPot (..), MIRTarget (..), ShelleyEraTxCert (..), +#if __GLASGOW_HASKELL__ >= 914 + data DelegStakeTxCert, + data GenesisDelegTxCert, + data MirTxCert, + data RegTxCert, + data UnRegTxCert, +#else pattern DelegStakeTxCert, pattern GenesisDelegTxCert, pattern MirTxCert, pattern RegTxCert, pattern UnRegTxCert, +#endif ) diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/RewardUpdate.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/RewardUpdate.hs index a4a9c17908c..78352c491b6 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/RewardUpdate.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/RewardUpdate.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -309,9 +310,21 @@ instance Pulsable RewardPulser where completeM (RSLP _ free balance (clearRecent -> ans)) = pure $ VMap.foldlWithKey (rewardStakePoolMember free) ans balance -deriving instance Eq ans => Eq (RewardPulser m ans) - -deriving instance Show ans => Show (RewardPulser m ans) +deriving instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Eq ans => +#endif + Eq (RewardPulser m ans) + +deriving instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Show ans => +#endif + Show (RewardPulser m ans) instance NoThunks Pulser where showTypeOf _ = "RewardPulser" diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Deleg.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Deleg.hs index 6e177e8ee7e..341b4de2080 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Deleg.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Deleg.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -67,7 +68,9 @@ import Data.Group (Group (..)) import qualified Data.Map.Strict as Map import Data.Maybe (isJust) import qualified Data.Set as Set +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable (Typeable) +#endif import Data.Word (Word8) import GHC.Generics (Generic) import Lens.Micro @@ -195,7 +198,12 @@ instance Era era => EncCBOR (ShelleyDelegPredFailure era) where <> encCBOR amt instance - (Era era, Typeable (Script era)) => + (Era era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc + , Typeable (Script era) +#endif + ) => DecCBOR (ShelleyDelegPredFailure era) where decCBOR = decodeRecordSum "ShelleyDelegPredFailure" $ diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delegs.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delegs.hs index 91211b62708..aaa7976c8db 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delegs.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delegs.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -64,7 +65,9 @@ import Control.State.Transition ( validateTrans, ) import Data.Sequence (Seq (..)) +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable (Typeable) +#endif import Data.Word (Word16, Word32, Word64, Word8) import GHC.Generics (Generic) import Lens.Micro @@ -173,7 +176,11 @@ instance instance ( Era era , DecCBOR (PredicateFailure (EraRule "DELPL" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Typeable (Script era) +#endif ) => DecCBOR (ShelleyDelegsPredFailure era) where diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delpl.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delpl.hs index 070e5716889..debdd5f3645 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delpl.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delpl.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -45,7 +46,9 @@ import Cardano.Ledger.Shelley.TxCert (GenesisDelegCert (..), ShelleyTxCert (..)) import Cardano.Ledger.Slot (SlotNo) import Control.DeepSeq import Control.State.Transition +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable (Typeable) +#endif import Data.Word (Word8) import GHC.Generics (Generic) import Lens.Micro ((&), (.~), (^.)) @@ -162,7 +165,11 @@ instance ( Era era , DecCBOR (PredicateFailure (EraRule "POOL" era)) , DecCBOR (PredicateFailure (EraRule "DELEG" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Typeable (Script era) +#endif ) => DecCBOR (ShelleyDelplPredFailure era) where diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Epoch.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Epoch.hs index 687fb98a0a6..c70c4c28330 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Epoch.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Epoch.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -40,7 +41,11 @@ import Cardano.Ledger.Shelley.LedgerState ( lsUTxOStateL, totalObligation, utxosGovStateL, +#if __GLASGOW_HASKELL__ >= 914 + data EpochState, +#else pattern EpochState, +#endif ) import Cardano.Ledger.Shelley.LedgerState.Types (prevPParamsEpochStateL) import Cardano.Ledger.Shelley.Rewards () diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Mir.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Mir.hs index 0de10d2e432..699e437da99 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Mir.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Mir.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE EmptyDataDeriving #-} @@ -33,7 +34,11 @@ import Cardano.Ledger.Shelley.LedgerState ( esSnapshots, lsCertStateL, prevPParamsEpochStateL, +#if __GLASGOW_HASKELL__ >= 914 + data EpochState, +#else pattern EpochState, +#endif ) import Cardano.Ledger.State import Cardano.Ledger.Val ((<->)) diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Upec.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Upec.hs index 0d9062a7c76..759d32cd492 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Upec.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Upec.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -43,7 +44,9 @@ import Control.State.Transition ( judgmentContext, trans, ) +#if __GLASGOW_HASKELL__ < 914 import Data.Default (Default) +#endif import Data.Void (Void) data UpecState era = UpecState @@ -59,7 +62,11 @@ deriving stock instance instance ( EraGov era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Default (PParams era) +#endif , GovState era ~ ShelleyGovState era , AtMostEra "Babbage" era ) => diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxow.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxow.hs index f4b4bec2c70..34d73fd3faa 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxow.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxow.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -216,10 +217,19 @@ instance <> encCBOR ss instance - ( Era era - , DecCBOR (PredicateFailure (EraRule "UTXO" era)) + ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Era era , Typeable (Script era) , Typeable (TxAuxData era) + , +#else + Typeable era + , +#endif + DecCBOR (PredicateFailure (EraRule "UTXO" era)) ) => DecCBOR (ShelleyUtxowPredFailure era) where diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Scripts.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Scripts.hs index f6d98f38b4a..b79f315447c 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Scripts.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Scripts.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -22,10 +23,17 @@ module Cardano.Ledger.Shelley.Scripts ( MultiSig (..), ShelleyEraScript (..), +#if __GLASGOW_HASKELL__ >= 914 + data RequireSignature, + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, +#else pattern RequireSignature, pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, +#endif evalMultiSig, validateMultiSig, nativeMultiSigTag, @@ -53,7 +61,11 @@ import Cardano.Ledger.MemoBytes ( MemoBytes, Memoized (..), getMemoRawType, +#if __GLASGOW_HASKELL__ >= 914 + data Memo, +#else pattern Memo, +#endif ) import Cardano.Ledger.MemoBytes.Internal (memoBytesEra) import Cardano.Ledger.Shelley.Era diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/State/Account.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/State/Account.hs index 67df85701d8..18dea924d91 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/State/Account.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/State/Account.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveGeneric #-} @@ -34,7 +35,9 @@ import Data.Default import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import qualified Data.MapExtras as Map (extract) +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable +#endif import GHC.Generics (Generic) import Lens.Micro import NoThunks.Class (NoThunks (..)) @@ -66,7 +69,13 @@ instance EncCBOR (ShelleyAccountState era) where <> encCBOR sasDeposit <> encodeNullStrictMaybe encCBOR sasStakePoolDelegation -instance Typeable era => DecShareCBOR (ShelleyAccountState era) where +instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable era => +#endif + DecShareCBOR (ShelleyAccountState era) where type Share (ShelleyAccountState era) = (Interns (KeyHash 'StakePool), Interns (Credential 'DRepRole)) @@ -109,7 +118,13 @@ instance EncCBOR (ShelleyAccounts era) where encCBOR ShelleyAccounts {saStates, saPtrs} = encodeListLen 2 <> encCBOR saStates <> encCBOR saPtrs -instance Typeable era => DecShareCBOR (ShelleyAccounts era) where +instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable era => +#endif + DecShareCBOR (ShelleyAccounts era) where type Share (ShelleyAccounts era) = (Interns (Credential 'Staking), Interns (KeyHash 'StakePool), Interns (Credential 'DRepRole)) diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Transition.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Transition.hs index 4fc06201d7c..f5c6b63dd21 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Transition.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Transition.hs @@ -1,6 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE ConstrainedClassMethods #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -34,7 +35,11 @@ module Cardano.Ledger.Shelley.Transition ( tcShelleyGenesisL, tcInitialPParamsG ), +#if __GLASGOW_HASKELL__ >= 914 + data ShelleyTransitionConfig, +#else pattern ShelleyTransitionConfig, +#endif tcInitialFundsL, tcInitialStakingL, mkShelleyTransitionConfig, diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/TxCert.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/TxCert.hs index dc809c72728..5ad9505467e 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/TxCert.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/TxCert.hs @@ -26,11 +26,19 @@ module Cardano.Ledger.Shelley.TxCert ( ShelleyEraTxCert (..), +#if __GLASGOW_HASKELL__ >= 914 + data MirTxCert, + data GenesisDelegTxCert, + data RegTxCert, + data UnRegTxCert, + data DelegStakeTxCert, +#else pattern MirTxCert, pattern GenesisDelegTxCert, pattern RegTxCert, pattern UnRegTxCert, pattern DelegStakeTxCert, +#endif ShelleyDelegCert (..), getVKeyWitnessShelleyTxCert, getScriptWitnessShelleyTxCert, @@ -67,8 +75,13 @@ module Cardano.Ledger.Shelley.TxCert ( -- * Re-exports EraTxCert (..), +#if __GLASGOW_HASKELL__ >= 914 + data RegPoolTxCert, + data RetirePoolTxCert, +#else pattern RegPoolTxCert, pattern RetirePoolTxCert, +#endif PoolCert (..), isRegStakeTxCert, isUnRegStakeTxCert, diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/TxWits.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/TxWits.hs index 18219d9af06..55e9b6f9c29 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/TxWits.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/TxWits.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -89,10 +90,16 @@ deriving instance EraScript era => Show (ShelleyTxWitsRaw era) deriving instance EraScript era => Eq (ShelleyTxWitsRaw era) instance - ( Era era - , NFData (Script era) + ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Era era , NFData (WitVKey 'Witness) , NFData BootstrapWitness + , +#endif + NFData (Script era) ) => NFData (ShelleyTxWitsRaw era) @@ -118,10 +125,16 @@ deriving newtype instance EraScript era => Eq (ShelleyTxWits era) deriving newtype instance EraScript era => Show (ShelleyTxWits era) instance - ( Era era - , NFData (Script era) + ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Era era , NFData (WitVKey 'Witness) , NFData BootstrapWitness + , +#endif + NFData (Script era) ) => NFData (ShelleyTxWits era) diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Arbitrary.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Arbitrary.hs index c4c47dd301a..f65974a7c85 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Arbitrary.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Arbitrary.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} @@ -65,10 +66,17 @@ import Cardano.Ledger.Shelley.Rules ( ) import Cardano.Ledger.Shelley.Scripts ( ShelleyEraScript (..), +#if __GLASGOW_HASKELL__ < 914 pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#else + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#endif ) import Cardano.Ledger.Shelley.State import Cardano.Ledger.Shelley.Transition @@ -126,12 +134,16 @@ instance (EraTxOut era, Arbitrary (Value era)) => Arbitrary (ShelleyTxOut era) w instance ( EraTxOut era , Arbitrary (TxOut era) - , Arbitrary (Value era) - , Arbitrary (PParams era) , Arbitrary (StashedAVVMAddresses era) , Arbitrary (GovState era) , Arbitrary (CertState era) , Arbitrary (InstantStake era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Arbitrary (PParams era) + , Arbitrary (Value era) +#endif ) => Arbitrary (NewEpochState era) where @@ -586,7 +598,12 @@ sizedNativeScriptGens n = ] instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Arbitrary (PParams ShelleyEra) => +#endif Arbitrary ShelleyGenesis where arbitrary = do @@ -700,10 +717,14 @@ instance instance ( EraTx era , Arbitrary (TxBody TopTx era) - , Arbitrary (Value era) , Arbitrary (TxAuxData era) - , Arbitrary (Script era) , Arbitrary (TxWits era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Arbitrary (Value era) + , Arbitrary (Script era) +#endif ) => Arbitrary (ShelleyTx TopTx era) where diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Binary/RoundTrip.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Binary/RoundTrip.hs index b2e423b0eb7..d283148e4f4 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Binary/RoundTrip.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Binary/RoundTrip.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -45,8 +46,12 @@ roundTripStateEraTypesSpec :: , DecCBOR (StashedAVVMAddresses era) , Arbitrary (StashedAVVMAddresses era) , Arbitrary (TxOut era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Arbitrary (Value era) , Arbitrary (PParams era) +#endif , Arbitrary (GovState era) , Arbitrary (CertState era) , Arbitrary (InstantStake era) diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp/UtxowSpec.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp/UtxowSpec.hs index 9ef1ef94eb7..7a477b5aa8a 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp/UtxowSpec.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp/UtxowSpec.hs @@ -1,9 +1,11 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} module Test.Cardano.Ledger.Shelley.Imp.UtxowSpec (spec) where @@ -17,7 +19,11 @@ import Cardano.Ledger.Keys (asWitness, witVKeyHash) import Cardano.Ledger.Keys.Bootstrap import Cardano.Ledger.Shelley.Rules (ShelleyUtxowPredFailure (..)) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireSignature, +#else pattern RequireSignature, +#endif ) import qualified Data.Set as Set import Lens.Micro diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs index b1b9b99ee02..097b621aeba 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs @@ -218,10 +218,17 @@ import Cardano.Ledger.Shelley.Rules ( ) import Cardano.Ledger.Shelley.Scripts ( ShelleyEraScript, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.Shelley.State import Cardano.Ledger.Shelley.Translation (toFromByronTranslationContext) diff --git a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/Core.hs b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/Core.hs index 6f26912c2f5..4b5dc15e1f5 100644 --- a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/Core.hs +++ b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/Core.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} @@ -22,7 +23,11 @@ module Test.Cardano.Ledger.Shelley.Generator.Core ( TwoPhase2ArgInfo (..), ScriptInfo, KeySpace (..), +#if __GLASGOW_HASKELL__ >= 914 + data KeySpace, +#else pattern KeySpace, +#endif NatNonce (..), findPayKeyPairAddr, findPayKeyPairCred, @@ -63,10 +68,17 @@ import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Core import Cardano.Ledger.Credential ( Credential (..), +#if __GLASGOW_HASKELL__ >= 914 + data KeyHashObj, + data ScriptHashObj, + data StakeRefBase, + data StakeRefPtr, +#else pattern KeyHashObj, pattern ScriptHashObj, pattern StakeRefBase, pattern StakeRefPtr, +#endif ) import Cardano.Ledger.Hashes (unsafeMakeSafeHash) import Cardano.Ledger.Keys (VKey, asWitness) diff --git a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/ShelleyEraGen.hs b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/ShelleyEraGen.hs index 1c02a13eca4..e060a89be0b 100644 --- a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/ShelleyEraGen.hs +++ b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/ShelleyEraGen.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NamedFieldPuns #-} @@ -20,10 +21,17 @@ import Cardano.Ledger.Shelley.API ( ) import Cardano.Ledger.Shelley.Scripts ( MultiSig, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.Shelley.TxBody ( TxBody (..), diff --git a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Rules/Chain.hs b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Rules/Chain.hs index 96c8b7d9ca1..451e92877d4 100644 --- a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Rules/Chain.hs +++ b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Rules/Chain.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -35,7 +36,9 @@ import Cardano.Ledger.BaseTypes ( ShelleyBase, StrictMaybe (..), ) +#if __GLASGOW_HASKELL__ < 914 import Cardano.Ledger.Binary (EncCBORGroup) +#endif import Cardano.Ledger.Block (Block (..)) import Cardano.Ledger.Chain ( ChainPredicateFailure (..), @@ -157,7 +160,11 @@ data ChainEvent era deriving stock instance ( Era era , Show (PredicateFailure (EraRule "BBODY" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Show (PredicateFailure (EraRule "TICK" era)) +#endif , Show (PredicateFailure (EraRule "TICKN" era)) ) => Show (TestChainPredicateFailure era) @@ -165,7 +172,11 @@ deriving stock instance deriving stock instance ( Era era , Eq (PredicateFailure (EraRule "BBODY" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Eq (PredicateFailure (EraRule "TICK" era)) +#endif , Eq (PredicateFailure (EraRule "TICKN" era)) ) => Eq (TestChainPredicateFailure era) @@ -173,7 +184,11 @@ deriving stock instance instance ( Era era , NoThunks (PredicateFailure (EraRule "BBODY" era)) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , NoThunks (PredicateFailure (EraRule "TICK" era)) +#endif , NoThunks (PredicateFailure (EraRule "TICKN" era)) ) => NoThunks (TestChainPredicateFailure era) @@ -264,7 +279,11 @@ instance , State (EraRule "TICK" era) ~ NewEpochState era , Signal (EraRule "TICK" era) ~ SlotNo , Embed (PRTCL MockCrypto) (CHAIN era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , EncCBORGroup (BlockBody era) +#endif , AtMostEra "Alonzo" era , State (EraRule "LEDGERS" era) ~ LedgerState era , EraCertState era diff --git a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Rules/ClassifyTraces.hs b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Rules/ClassifyTraces.hs index 743dbd8b022..5194ffc3d04 100644 --- a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Rules/ClassifyTraces.hs +++ b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Rules/ClassifyTraces.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} @@ -31,8 +32,13 @@ import Cardano.Ledger.Shelley.Core import Cardano.Ledger.Shelley.LedgerState (LedgerState) import Cardano.Ledger.Shelley.PParams ( Update (..), +#if __GLASGOW_HASKELL__ >= 914 + data ProposedPPUpdates, + data Update, +#else pattern ProposedPPUpdates, pattern Update, +#endif ) import Cardano.Ledger.Shelley.State import Cardano.Ledger.Shelley.TxCert ( diff --git a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Utils.hs b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Utils.hs index 408cbd14d24..28ecd13f72c 100644 --- a/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Utils.hs +++ b/eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Utils.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE PatternSynonyms #-} @@ -86,7 +87,11 @@ import Data.Coerce (Coercible, coerce) import Data.Functor.Identity (runIdentity) import Data.List.NonEmpty (NonEmpty) import Data.Word (Word64) +#if __GLASGOW_HASKELL__ >= 914 +import Test.Cardano.Ledger.Core.KeyPair (KeyPair, data KeyPair) +#else import Test.Cardano.Ledger.Core.KeyPair (KeyPair, pattern KeyPair) +#endif import Test.Cardano.Ledger.Core.Utils as CoreUtils import Test.Cardano.Ledger.Shelley.Arbitrary (RawSeed (..)) import Test.Cardano.Ledger.Shelley.ConcreteCryptoTypes (MockCrypto) diff --git a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Fees.hs b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Fees.hs index 07463a1b21b..f5508e7c722 100644 --- a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Fees.hs +++ b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Fees.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} @@ -33,17 +34,28 @@ import Cardano.Ledger.Shelley.API ( ) import Cardano.Ledger.Shelley.Scripts ( ShelleyEraScript, +#if __GLASGOW_HASKELL__ >= 914 + data RequireMOf, + data RequireSignature, +#else pattern RequireMOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.Shelley.Tx ( ShelleyTx (..), ) import Cardano.Ledger.Shelley.TxAuxData import Cardano.Ledger.Shelley.TxCert ( +#if __GLASGOW_HASKELL__ >= 914 + data DelegStakeTxCert, + data RegTxCert, + data UnRegTxCert, +#else pattern DelegStakeTxCert, pattern RegTxCert, pattern UnRegTxCert, +#endif ) import Cardano.Ledger.Shelley.TxWits ( addrWits, diff --git a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/MultiSigExamples.hs b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/MultiSigExamples.hs index 6f0adfc16d0..f93b8349935 100644 --- a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/MultiSigExamples.hs +++ b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/MultiSigExamples.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE PatternSynonyms #-} @@ -26,9 +27,15 @@ import Cardano.Ledger.BaseTypes ( ) import Cardano.Ledger.Coin import Cardano.Ledger.Credential ( +#if __GLASGOW_HASKELL__ >= 914 + data KeyHashObj, + data ScriptHashObj, + data StakeRefBase, +#else pattern KeyHashObj, pattern ScriptHashObj, pattern StakeRefBase, +#endif ) import Cardano.Ledger.Keys (asWitness) import Cardano.Ledger.Shelley (ShelleyEra) @@ -42,10 +49,17 @@ import Cardano.Ledger.Shelley.Rules (ShelleyUTXOW, UtxoEnv (..)) import Cardano.Ledger.Shelley.Scripts ( MultiSig, ShelleyEraScript, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.Shelley.State import Cardano.Ledger.Shelley.TxAuxData (ShelleyTxAuxData) diff --git a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/RulesTests.hs b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/RulesTests.hs index 357adde9a0f..2434e0c9d07 100644 --- a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/RulesTests.hs +++ b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/RulesTests.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE PatternSynonyms #-} @@ -14,7 +15,11 @@ module Test.Cardano.Ledger.Shelley.RulesTests ( import Cardano.Ledger.BaseTypes (Network (..)) import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Core (hashScript) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Credential (data ScriptHashObj) +#else import Cardano.Ledger.Credential (pattern ScriptHashObj) +#endif import Cardano.Ledger.Keys (asWitness, hashKey) import Cardano.Ledger.Shelley (ShelleyEra) import Cardano.Ledger.Shelley.Rules (ShelleyUtxowPredFailure (..)) diff --git a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Serialisation/Golden/Encoding.hs b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Serialisation/Golden/Encoding.hs index b2e8d985d5d..13572d60abf 100644 --- a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Serialisation/Golden/Encoding.hs +++ b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Serialisation/Golden/Encoding.hs @@ -9,6 +9,7 @@ {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -Wno-orphans #-} -- | Golden tests that check CBOR token encoding. @@ -75,11 +76,20 @@ import Cardano.Ledger.Shelley.BlockBody (ShelleyBlockBody (..)) import Cardano.Ledger.Shelley.Core import Cardano.Ledger.Shelley.PParams ( ProposedPPUpdates (..), +#if __GLASGOW_HASKELL__ >= 914 + data ProposedPPUpdates, + data Update, +#else pattern ProposedPPUpdates, pattern Update, +#endif ) import Cardano.Ledger.Shelley.Rewards () +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Shelley.Scripts (data RequireSignature) +#else import Cardano.Ledger.Shelley.Scripts (pattern RequireSignature) +#endif import Cardano.Ledger.Shelley.Tx (ShelleyTx (..)) import qualified Cardano.Ledger.Shelley.TxAuxData as TxAuxData import Cardano.Ledger.Shelley.TxBody (TxBody (ShelleyTxBody)) @@ -116,7 +126,11 @@ import Cardano.Protocol.TPraos.OCert ( KESPeriod (..), OCert, OCertSignable (..), +#if __GLASGOW_HASKELL__ >= 914 + data OCert, +#else pattern OCert, +#endif ) import qualified Codec.CBOR.Encoding as CBOR (Encoding (..)) import Control.Monad diff --git a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/UnitTests.hs b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/UnitTests.hs index 5e366fa4972..9b64840d20d 100644 --- a/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/UnitTests.hs +++ b/eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/UnitTests.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleContexts #-} @@ -14,7 +15,11 @@ module Test.Cardano.Ledger.Shelley.UnitTests (unitTests) where import qualified Cardano.Crypto.VRF as VRF +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Address (Addr (..), raCredential, data RewardAccount) +#else import Cardano.Ledger.Address (Addr (..), raCredential, pattern RewardAccount) +#endif import Cardano.Ledger.BaseTypes hiding ((==>)) import Cardano.Ledger.Coin import Cardano.Ledger.Credential (Credential (..), Ptr (..), SlotNo32 (..), StakeReference (..)) diff --git a/libs/cardano-data/src/Data/ListMap.hs b/libs/cardano-data/src/Data/ListMap.hs index e4c64f76390..d2534770f59 100644 --- a/libs/cardano-data/src/Data/ListMap.hs +++ b/libs/cardano-data/src/Data/ListMap.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveGeneric #-} @@ -106,7 +107,13 @@ instance (ToJSON v, ToJSONKey k) => ToJSON (ListMap k v) where toJSON = J.toJSON1 toEncoding = J.toEncoding1 -instance (FromJSON k, FromJSONKey k) => FromJSON1 (ListMap k) where +instance ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + FromJSON k, +#endif + FromJSONKey k) => FromJSON1 (ListMap k) where liftParseJSON _ parser _ = J.withObject "ListMap" $ \obj -> do let kv = KM.toList obj res <- forM kv $ \(k, v) -> do @@ -121,7 +128,13 @@ instance (FromJSON k, FromJSONKey k) => FromJSON1 (ListMap k) where return (k', v') return $ ListMap res -instance (FromJSON v, FromJSON k, FromJSONKey k) => FromJSON (ListMap k v) where +instance (FromJSON v, +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + FromJSON k, +#endif + FromJSONKey k) => FromJSON (ListMap k v) where parseJSON = J.parseJSON1 instance NFData k => NFData1 (ListMap k) diff --git a/libs/cardano-data/src/Data/OMap/Strict.hs b/libs/cardano-data/src/Data/OMap/Strict.hs index 08aca69f791..897127aa3cb 100644 --- a/libs/cardano-data/src/Data/OMap/Strict.hs +++ b/libs/cardano-data/src/Data/OMap/Strict.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveGeneric #-} @@ -424,7 +425,13 @@ instance Ord k => Foldable (OMap k) where instance (EncCBOR v, Ord k) => EncCBOR (OMap k v) where encCBOR omap = encodeStrictSeq encCBOR (toStrictSeq omap) -instance (Typeable k, HasOKey k v, DecCBOR v, Eq v) => DecCBOR (OMap k v) where +instance (Typeable k, HasOKey k v, DecCBOR v +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Eq v +#endif + ) => DecCBOR (OMap k v) where decCBOR = decodeOMap decCBOR decodeOMap :: HasOKey k v => Decoder s v -> Decoder s (OMap k v) diff --git a/libs/cardano-data/src/Data/OSet/Strict.hs b/libs/cardano-data/src/Data/OSet/Strict.hs index 7b6182cc193..fd2f6ecac79 100644 --- a/libs/cardano-data/src/Data/OSet/Strict.hs +++ b/libs/cardano-data/src/Data/OSet/Strict.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -112,7 +113,13 @@ decodeOSet = decodeSetLikeEnforceNoDuplicates (flip snoc) (\oset -> (size oset, instance EncCBOR a => EncCBOR (OSet a) where encCBOR (OSet seq _set) = encodeTag setTag <> encodeStrictSeq encCBOR seq -instance (Show a, Ord a, DecCBOR a) => DecCBOR (OSet a) where +instance ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Show a, +#endif + Ord a, DecCBOR a) => DecCBOR (OSet a) where decCBOR = decodeOSet decCBOR instance ToJSON a => ToJSON (OSet a) where diff --git a/libs/cardano-data/src/Data/Universe.hs b/libs/cardano-data/src/Data/Universe.hs index 3dc82f37610..cb44154ab1f 100644 --- a/libs/cardano-data/src/Data/Universe.hs +++ b/libs/cardano-data/src/Data/Universe.hs @@ -44,7 +44,11 @@ module Data.Universe ( import Data.Kind (Type) import Data.Type.Equality (TestEquality (..), (:~:) (Refl)) +#if __GLASGOW_HASKELL__ < 914 import Type.Reflection (TypeRep, pattern App, pattern Con) +#else +import Type.Reflection (TypeRep, data App, data Con) +#endif -- ================================================== diff --git a/libs/cardano-data/testlib/Test/Cardano/Data.hs b/libs/cardano-data/testlib/Test/Cardano/Data.hs index 43d30d8f90b..78288f64a13 100644 --- a/libs/cardano-data/testlib/Test/Cardano/Data.hs +++ b/libs/cardano-data/testlib/Test/Cardano/Data.hs @@ -4,8 +4,8 @@ module Test.Cardano.Data ( ) where import Control.Monad -import qualified Data.Map.Internal.Debug as Map -import qualified Data.Map.Strict as Map hiding (showTree) +import qualified Data.Map.Internal.Debug as MapDebug +import qualified Data.Map.Strict as Map import Test.Hspec import Test.QuickCheck @@ -15,10 +15,10 @@ expectValidMap m = expectationFailure $ unlines [ "Interal strucutre of a map is invalid:" - , "Keys are ordered: " ++ show (Map.ordered m) - , "Tree is balanced: " ++ show (Map.balanced m) - , "Sizes are valid: " ++ show (Map.validsize m) - , Map.showTree m + , "Keys are ordered: " ++ show (MapDebug.ordered m) + , "Tree is balanced: " ++ show (MapDebug.balanced m) + , "Sizes are valid: " ++ show (MapDebug.validsize m) + , MapDebug.showTree m ] genNonEmptyMap :: Ord k => Gen k -> Gen v -> Gen (Map.Map k v) diff --git a/libs/cardano-ledger-api/src/Cardano/Ledger/Api/Scripts.hs b/libs/cardano-ledger-api/src/Cardano/Ledger/Api/Scripts.hs index 81d851786f4..75e0f4ff120 100644 --- a/libs/cardano-ledger-api/src/Cardano/Ledger/Api/Scripts.hs +++ b/libs/cardano-ledger-api/src/Cardano/Ledger/Api/Scripts.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -21,6 +22,9 @@ module Cardano.Ledger.Api.Scripts ( -- * Any era AnyEraScript (..), +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 pattern AnyEraSpendingPurpose, pattern AnyEraMintingPurpose, pattern AnyEraCertifyingPurpose, @@ -28,7 +32,15 @@ module Cardano.Ledger.Api.Scripts ( pattern AnyEraVotingPurpose, pattern AnyEraProposingPurpose, pattern AnyEraGuardingPurpose, - +#else + data AnyEraSpendingPurpose, + data AnyEraMintingPurpose, + data AnyEraCertifyingPurpose, + data AnyEraRewardingPurpose, + data AnyEraVotingPurpose, + data AnyEraProposingPurpose, + data AnyEraGuardingPurpose, +#endif -- * Alonzo AlonzoEraScript ( PlutusScript, @@ -39,10 +51,17 @@ module Cardano.Ledger.Api.Scripts ( toRewardingPurpose ), isPlutusScript, +#if __GLASGOW_HASKELL__ < 914 pattern SpendingPurpose, pattern MintingPurpose, pattern CertifyingPurpose, pattern RewardingPurpose, +#else + data SpendingPurpose, + data MintingPurpose, + data CertifyingPurpose, + data RewardingPurpose, +#endif CostModels, -- * Conway @@ -50,14 +69,23 @@ module Cardano.Ledger.Api.Scripts ( toVotingPurpose, toProposingPurpose ), +#if __GLASGOW_HASKELL__ < 914 pattern VotingPurpose, pattern ProposingPurpose, +#else + data VotingPurpose, + data ProposingPurpose, +#endif -- * Dijkstra DijkstraEraScript ( toGuardingPurpose ), +#if __GLASGOW_HASKELL__ < 914 pattern GuardingPurpose, +#else + data GuardingPurpose, +#endif ) where import Cardano.Ledger.Address (RewardAccount) @@ -66,18 +94,30 @@ import Cardano.Ledger.Alonzo.Scripts ( AlonzoEraScript (..), CostModels, isPlutusScript, +#if __GLASGOW_HASKELL__ < 914 pattern CertifyingPurpose, pattern MintingPurpose, pattern RewardingPurpose, pattern SpendingPurpose, +#else + data CertifyingPurpose, + data MintingPurpose, + data RewardingPurpose, + data SpendingPurpose, +#endif ) import Cardano.Ledger.Api.Era import Cardano.Ledger.Api.Scripts.Data import Cardano.Ledger.Conway.Governance (ProposalProcedure, Voter) import Cardano.Ledger.Conway.Scripts ( ConwayEraScript (..), +#if __GLASGOW_HASKELL__ < 914 pattern ProposingPurpose, pattern VotingPurpose, +#else + data ProposingPurpose, + data VotingPurpose, +#endif ) import Cardano.Ledger.Core ( EraScript (..), @@ -88,7 +128,11 @@ import Cardano.Ledger.Core ( ) import Cardano.Ledger.Dijkstra.Scripts ( DijkstraEraScript (..), +#if __GLASGOW_HASKELL__ < 914 pattern GuardingPurpose, +#else + data GuardingPurpose, +#endif ) import Cardano.Ledger.Hashes (ScriptHash) import Cardano.Ledger.Mary.Value (PolicyID) diff --git a/libs/cardano-ledger-api/src/Cardano/Ledger/Api/Tx/Cert.hs b/libs/cardano-ledger-api/src/Cardano/Ledger/Api/Tx/Cert.hs index 39b30a649b4..fe1d8d3b140 100644 --- a/libs/cardano-ledger-api/src/Cardano/Ledger/Api/Tx/Cert.hs +++ b/libs/cardano-ledger-api/src/Cardano/Ledger/Api/Tx/Cert.hs @@ -1,6 +1,8 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableSuperClasses #-} {-# LANGUAGE ViewPatterns #-} @@ -16,13 +18,19 @@ module Cardano.Ledger.Api.Tx.Cert ( upgradeTxCert, getVKeyWitnessTxCert, getScriptWitnessTxCert, +#if __GLASGOW_HASKELL__ < 914 pattern RegPoolTxCert, pattern RetirePoolTxCert, +#else + data RegPoolTxCert, + data RetirePoolTxCert, +#endif isRegStakeTxCert, isUnRegStakeTxCert, -- * Any Era AnyEraTxCert (..), +#if __GLASGOW_HASKELL__ < 914 pattern AnyEraRegPoolTxCert, pattern AnyEraRetirePoolTxCert, pattern AnyEraRegTxCert, @@ -38,7 +46,23 @@ module Cardano.Ledger.Api.Tx.Cert ( pattern AnyEraRegDRepTxCert, pattern AnyEraUnRegDRepTxCert, pattern AnyEraUpdateDRepTxCert, - +#else + data AnyEraRegPoolTxCert, + data AnyEraRetirePoolTxCert, + data AnyEraRegTxCert, + data AnyEraUnRegTxCert, + data AnyEraMirTxCert, + data AnyEraGenesisDelegTxCert, + data AnyEraRegDepositTxCert, + data AnyEraUnRegDepositTxCert, + data AnyEraDelegTxCert, + data AnyEraRegDepositDelegTxCert, + data AnyEraAuthCommitteeHotKeyTxCert, + data AnyEraResignCommitteeColdTxCert, + data AnyEraRegDRepTxCert, + data AnyEraUnRegDRepTxCert, + data AnyEraUpdateDRepTxCert, +#endif -- * Shelley Era -- | Complete set of patterns for Shelley through Babbage `TxCert`: @@ -60,11 +84,19 @@ module Cardano.Ledger.Api.Tx.Cert ( getGenesisDelegTxCert, getMirTxCert ), +#if __GLASGOW_HASKELL__ < 914 pattern MirTxCert, pattern GenesisDelegTxCert, pattern RegTxCert, pattern UnRegTxCert, pattern DelegStakeTxCert, +#else + data MirTxCert, + data GenesisDelegTxCert, + data RegTxCert, + data UnRegTxCert, + data DelegStakeTxCert, +#endif -- * Conway Era @@ -98,6 +130,7 @@ module Cardano.Ledger.Api.Tx.Cert ( getDelegateeTxCert, Delegatee (..), getStakePoolDelegatee, +#if __GLASGOW_HASKELL__ < 914 pattern RegDepositTxCert, pattern UnRegDepositTxCert, pattern DelegTxCert, @@ -106,6 +139,16 @@ module Cardano.Ledger.Api.Tx.Cert ( pattern ResignCommitteeColdTxCert, pattern RegDRepTxCert, pattern UnRegDRepTxCert, +#else + data RegDepositTxCert, + data UnRegDepositTxCert, + data DelegTxCert, + data RegDepositDelegTxCert, + data AuthCommitteeHotKeyTxCert, + data ResignCommitteeColdTxCert, + data RegDRepTxCert, + data UnRegDRepTxCert, +#endif ) where import Cardano.Ledger.Api.Era @@ -126,6 +169,7 @@ import Cardano.Ledger.Conway.TxCert ( Delegatee (..), getDelegateeTxCert, getStakePoolDelegatee, +#if __GLASGOW_HASKELL__ < 914 pattern AuthCommitteeHotKeyTxCert, pattern DelegTxCert, pattern RegDRepTxCert, @@ -134,6 +178,16 @@ import Cardano.Ledger.Conway.TxCert ( pattern ResignCommitteeColdTxCert, pattern UnRegDRepTxCert, pattern UnRegDepositTxCert, +#else + data AuthCommitteeHotKeyTxCert, + data DelegTxCert, + data RegDRepTxCert, + data RegDepositDelegTxCert, + data RegDepositTxCert, + data ResignCommitteeColdTxCert, + data UnRegDRepTxCert, + data UnRegDepositTxCert, +#endif ) import Cardano.Ledger.Core ( EraTxCert ( @@ -153,8 +207,13 @@ import Cardano.Ledger.Core ( VRFVerKeyHash, isRegStakeTxCert, isUnRegStakeTxCert, +#if __GLASGOW_HASKELL__ < 914 pattern RegPoolTxCert, pattern RetirePoolTxCert, +#else + data RegPoolTxCert, + data RetirePoolTxCert, +#endif ) import Cardano.Ledger.Credential (Credential) import Cardano.Ledger.Shelley.TxCert ( @@ -167,11 +226,19 @@ import Cardano.Ledger.Shelley.TxCert ( getRegTxCert, getUnRegTxCert ), +#if __GLASGOW_HASKELL__ < 914 pattern DelegStakeTxCert, pattern GenesisDelegTxCert, pattern MirTxCert, pattern RegTxCert, pattern UnRegTxCert, +#else + data DelegStakeTxCert, + data GenesisDelegTxCert, + data MirTxCert, + data RegTxCert, + data UnRegTxCert, +#endif ) import Cardano.Ledger.State (StakePoolParams) diff --git a/libs/cardano-ledger-binary/testlib/Test/Cardano/Ledger/Binary/Twiddle.hs b/libs/cardano-ledger-binary/testlib/Test/Cardano/Ledger/Binary/Twiddle.hs index 319155d70f6..d7bfbb61078 100644 --- a/libs/cardano-ledger-binary/testlib/Test/Cardano/Ledger/Binary/Twiddle.hs +++ b/libs/cardano-ledger-binary/testlib/Test/Cardano/Ledger/Binary/Twiddle.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstrainedClassMethods #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE EmptyCase #-} {-# LANGUAGE FlexibleContexts #-} @@ -110,7 +111,13 @@ instance Twiddle Int where -- This is not possible with the CBOR AST provided by cborg twiddle _ = pure . TInt -instance (Twiddle a, Arbitrary a, EncCBOR a) => Arbitrary (Twiddler a) where +instance (Twiddle a, Arbitrary a +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , EncCBOR a +#endif + ) => Arbitrary (Twiddler a) where arbitrary = do x <- arbitrary v <- arbitrary diff --git a/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/ExecSpecRule/Conway/Utxow.hs b/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/ExecSpecRule/Conway/Utxow.hs index 0fdda5f127f..3b36000315b 100644 --- a/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/ExecSpecRule/Conway/Utxow.hs +++ b/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/ExecSpecRule/Conway/Utxow.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -14,10 +15,14 @@ module Test.Cardano.Ledger.Conformance.ExecSpecRule.Conway.Utxow () where import Cardano.Ledger.Conway (ConwayEra) import Cardano.Ledger.Conway.Core (EraTx (..)) +#if __GLASGOW_HASKELL__ < 914 import Cardano.Ledger.Conway.TxCert (ConwayTxCert) +#endif import Cardano.Ledger.Conway.UTxO (getConwayWitsVKeyNeeded) import Cardano.Ledger.Shelley.LedgerState (UTxOState (..)) +#if __GLASGOW_HASKELL__ < 914 import Cardano.Ledger.TxIn (TxId) +#endif import Control.State.Transition.Extended (TRC (..)) import Data.Bifunctor (Bifunctor (..)) import Data.Coerce (coerce) @@ -40,7 +45,11 @@ import Test.Cardano.Ledger.Conway.TreeDiff (showExpr) import Test.Cardano.Ledger.Shelley.Utils (runSTS) instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 SpecTranslate TxId (ConwayTxCert ConwayEra) => +#endif ExecSpecRule "UTXOW" ConwayEra where type ExecContext "UTXOW" ConwayEra = UtxoExecContext ConwayEra diff --git a/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/SpecTranslate/Conway/Base.hs b/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/SpecTranslate/Conway/Base.hs index d3ad22feb82..9a2ff470317 100644 --- a/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/SpecTranslate/Conway/Base.hs +++ b/libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/SpecTranslate/Conway/Base.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -26,8 +27,13 @@ module Test.Cardano.Ledger.Conformance.SpecTranslate.Conway.Base ( import Cardano.Ledger.Address (RewardAccount (..)) import Cardano.Ledger.Allegra.Scripts ( Timelock, +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Alonzo (AlonzoTxAuxData, MaryValue) import Cardano.Ledger.Alonzo.PParams (OrdExUnits (OrdExUnits)) @@ -46,10 +52,17 @@ import Cardano.Ledger.Credential (Credential (..)) import Cardano.Ledger.HKD (HKD) import Cardano.Ledger.Shelley.Rules (Identity) import Cardano.Ledger.Shelley.Scripts ( +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.TxIn (TxId (..), TxIn (..)) import Cardano.Ledger.Val (Val (..)) diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/BaseTypes.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/BaseTypes.hs index b3af188b342..aead8b5f977 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/BaseTypes.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/BaseTypes.hs @@ -343,11 +343,23 @@ fromRatioBoundedRatio ratio lowerBound = minBound :: BoundedRatio b a upperBound = maxBound :: BoundedRatio b a -instance (ToCBOR a, Integral a, Bounded a, Typeable b) => ToCBOR (BoundedRatio b a) where +instance (ToCBOR a, +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Integral a, Bounded a, +#endif + Typeable b) => ToCBOR (BoundedRatio b a) where toCBOR (BoundedRatio u) = Plain.encodeRatioWithTag toCBOR u instance - (FromCBOR a, Bounded (BoundedRatio b a), Bounded a, Integral a, Typeable b, Show a) => + (FromCBOR a, Bounded (BoundedRatio b a), Bounded a, Integral a, Typeable b +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Show a +#endif + ) => FromCBOR (BoundedRatio b a) where fromCBOR = do diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/Core/TxCert.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/Core/TxCert.hs index 4667583da88..a11ace3e252 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/Core/TxCert.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/Core/TxCert.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ConstrainedClassMethods #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -12,8 +13,13 @@ module Cardano.Ledger.Core.TxCert ( EraTxCert (..), +#if __GLASGOW_HASKELL__ >= 914 + data RegPoolTxCert, + data RetirePoolTxCert, +#else pattern RegPoolTxCert, pattern RetirePoolTxCert, +#endif PoolCert (..), getPoolCertTxCert, poolCertKeyHashWitness, diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs index 27f087c7520..fb151c5081d 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} @@ -391,7 +392,13 @@ instance SafeToHash ByteString where originalBytes x = x -- | Hash of a hash. Hash is always safe to hash. Do you even hash? -instance Hash.HashAlgorithm h => SafeToHash (Hash.Hash h i) where +instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Hash.HashAlgorithm h => +#endif + SafeToHash (Hash.Hash h i) where originalBytes = Hash.hashToBytes -- | Types that are 'SafeToHash' AND have the type uniquely determines the 'index' type diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/Keys/WitVKey.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/Keys/WitVKey.hs index 5efd5421a61..8d65b483b01 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/Keys/WitVKey.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/Keys/WitVKey.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -53,7 +54,13 @@ deriving via instance NFData (WitVKey kr) where rnf WitVKeyInternal {wvkKeyHash} = wvkKeyHash `seq` () -instance Typeable kr => Ord (WitVKey kr) where +instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable kr => +#endif + Ord (WitVKey kr) where compare x y = -- It is advised against comparison on keys and signatures directly, -- therefore we use hashes of verification keys and signatures for diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/State/CertState.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/State/CertState.hs index 2bb6eea80b9..7f24c454b3b 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/State/CertState.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/State/CertState.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingVia #-} @@ -264,7 +265,13 @@ instance DecShareCBOR (PState era) where psRetiring <- decSharePlusLensCBOR (toMemptyLens _1 _2) pure PState {psVRFKeyHashes, psStakePools, psFutureStakePools, psRetiring} -instance (Era era, DecShareCBOR (PState era)) => DecCBOR (PState era) where +instance (Era era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , DecShareCBOR (PState era) +#endif + ) => DecCBOR (PState era) where decCBOR = decNoShareCBOR instance ToKeyValuePairs (PState era) where diff --git a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Arbitrary.hs b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Arbitrary.hs index 3032abf5576..c9ce70706f6 100644 --- a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Arbitrary.hs +++ b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Arbitrary.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} @@ -319,7 +320,13 @@ instance Arbitrary (VRFVerKeyHash r) where instance Arbitrary (VKey kd) where arbitrary = VKey <$> arbitrary -instance Typeable kr => Arbitrary (WitVKey kr) where +instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable kr => +#endif + Arbitrary (WitVKey kr) where arbitrary = WitVKey <$> arbitrary <*> arbitrary instance Arbitrary ChainCode where diff --git a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/KeyPair.hs b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/KeyPair.hs index 5e5c4854ddc..024bf053d1d 100644 --- a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/KeyPair.hs +++ b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/KeyPair.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveGeneric #-} @@ -70,7 +71,9 @@ import Data.Proxy import Data.Set (Set) import qualified Data.Set as Set import qualified Data.TreeDiff as Tree (Expr (..)) +#if __GLASGOW_HASKELL__ < 914 import Data.Typeable +#endif import GHC.Generics (Generic) import NoThunks.Class (NoThunks (..)) import System.Random.Stateful @@ -108,7 +111,13 @@ instance Uniform (KeyPair kd) where instance EncCBOR (KeyPair r) where encCBOR (KeyPair x y) = encode $ Coders.Rec KeyPair !> To x !> To y -deriving instance Typeable r => Eq (KeyPair r) +deriving instance +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + Typeable r => +#endif + Eq (KeyPair r) instance ToExpr (KeyPair r) where toExpr (KeyPair x y) = Tree.App "KeyPair" [toExpr x, Tree.App (take 10 (show y)) []] diff --git a/libs/cardano-ledger-test/cardano-ledger-test.cabal b/libs/cardano-ledger-test/cardano-ledger-test.cabal index e77a53df1b3..ef37222f852 100644 --- a/libs/cardano-ledger-test/cardano-ledger-test.cabal +++ b/libs/cardano-ledger-test/cardano-ledger-test.cabal @@ -75,8 +75,10 @@ library -Wunused-packages build-depends: + -- QuickCheck version 2.16 inrtroduces the Some type which needs to + -- be hidden to prevent name clashes with other packages. FailT, - QuickCheck, + QuickCheck >=2.16, base >=4.18 && <5, bytestring, cardano-crypto, diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/Instances/Ledger.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/Instances/Ledger.hs index 72e4f7a910f..0f8044ef289 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/Instances/Ledger.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/Instances/Ledger.hs @@ -1264,7 +1264,11 @@ genProposalsSplit maxTotal = do instance ( HasSpec (SimpleRep (Proposals era)) , HasSpec (Proposals era) +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , HasSimpleRep (Proposals era) +#endif , era ~ ConwayEra , EraSpecPParams era ) => diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/LedgerTypes/Tests.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/LedgerTypes/Tests.hs index 79ffb7a41c9..7ae89c840c7 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/LedgerTypes/Tests.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/LedgerTypes/Tests.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} @@ -35,7 +36,9 @@ import Test.Cardano.Ledger.Constrained.Conway.LedgerTypes.Specs import Test.Cardano.Ledger.Constrained.Conway.LedgerTypes.WellFormed import Test.Cardano.Ledger.Constrained.Conway.PParams (pparamsSpec) import Test.Cardano.Ledger.Constrained.Conway.WitnessUniverse +#if __GLASGOW_HASKELL__ < 914 import Test.Cardano.Ledger.Conway.Era +#endif import Test.Hspec hiding (context) import Test.Hspec.QuickCheck (prop) import Test.QuickCheck ( @@ -121,7 +124,11 @@ soundSpecWith n specx = it (show (typeRep (Proxy @t))) $ withMaxSuccess n $ prop specSuite :: forall (era :: Type). ( era ~ ConwayEra +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , ShelleyEraTest era +#endif ) => Int -> Spec specSuite n = do diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/LedgerTypes/WellFormed.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/LedgerTypes/WellFormed.hs index 08294f183af..002439d651b 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/LedgerTypes/WellFormed.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/LedgerTypes/WellFormed.hs @@ -77,7 +77,13 @@ conwayDStateGen :: forall era. era ~ ConwayEra => Gen (DState era) conwayDStateGen = dsX @ConwayEra -vsX :: forall era. (GenScript era, era ~ ConwayEra) => Gen (VState era) +vsX :: forall era. ( +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + GenScript era, +#endif + era ~ ConwayEra) => Gen (VState era) vsX = do univ <- genWitUniv 25 epoch <- genFromSpec @EpochNo epochNoSpec @@ -101,7 +107,13 @@ utxoX = do utxostateX :: forall era. - (era ~ ConwayEra, HasSpec (InstantStake era)) => + (era ~ ConwayEra +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , HasSpec (InstantStake era) +#endif + ) => PParams era -> Gen (UTxOState era) utxostateX pp = do @@ -118,7 +130,13 @@ conwaygovX pp = do genFromSpec @(ConwayGovState ConwayEra) (conwayGovStateSpec pp env) lsX :: - forall era. (era ~ ConwayEra, HasSpec (InstantStake era)) => PParams era -> Gen (LedgerState era) + forall era. (era ~ ConwayEra +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , HasSpec (InstantStake era) +#endif + ) => PParams era -> Gen (LedgerState era) lsX pp = do univ <- genWitUniv @era 200 context <- genCertContext @era univ @@ -127,7 +145,13 @@ lsX pp = do esX :: forall era. - (era ~ ConwayEra, HasSpec (InstantStake era)) => + (era ~ ConwayEra +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , HasSpec (InstantStake era) +#endif + ) => PParams era -> Gen (EpochState era) esX pp = do @@ -138,7 +162,13 @@ esX pp = do nesX :: forall era. - (era ~ ConwayEra, HasSpec (InstantStake era)) => + (era ~ ConwayEra +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , HasSpec (InstantStake era) +#endif + ) => PParams era -> Gen (NewEpochState era) nesX pp = do @@ -151,8 +181,12 @@ snapX = genFromSpec @SnapShot snapShotSpec snapsX :: forall era. - ( HasSpec (InstantStake era) - , era ~ ConwayEra + ( era ~ ConwayEra +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , HasSpec (InstantStake era) +#endif ) => PParams era -> Gen SnapShots @@ -163,7 +197,13 @@ snapsX pp = do ls <- genFromSpec @(LedgerState era) (ledgerStateSpec pp univ context (lit epoch)) genFromSpec @SnapShots (snapShotsSpec (lit (getMarkSnapShot ls))) -instanRewX :: forall era. (era ~ ConwayEra, EraSpecTxOut era) => Gen InstantaneousRewards +instanRewX :: forall era. (era ~ ConwayEra +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , EraSpecTxOut era +#endif + ) => Gen InstantaneousRewards instanRewX = do univ <- genWitUniv @era 50 acct <- genFromSpec @ChainAccountState accountStateSpec diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/WitnessUniverse.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/WitnessUniverse.hs index 383559ab353..a232d7a724d 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/WitnessUniverse.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/WitnessUniverse.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -34,8 +35,13 @@ import Cardano.Ledger.Address (BootstrapAddress (..), RewardAccount (..)) import Cardano.Ledger.Allegra (AllegraEra) import Cardano.Ledger.Allegra.Scripts ( AllegraEraScript (..), +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Alonzo (AlonzoEra) import Cardano.Ledger.Alonzo.Scripts (AlonzoEraScript (..), AsIx (..), PlutusPurpose) @@ -208,7 +214,13 @@ wbMap :: WitBlock t era -> Map t (ProofType t era) wbMap (WitBlock _ y) = y -- | when we print a WitBlock, we are only interested in the hashes, not the witnesses -instance (Show t, ToExpr t) => Show (WitBlock t era) where +instance (Show t +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , ToExpr t +#endif + ) => Show (WitBlock t era) where show (WitBlock hashset _) = unlines (map show (Set.toList hashset)) instance NFData (WitBlock t era) where diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoAPI.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoAPI.hs index d649ef30e91..77f584b3fcd 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoAPI.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoAPI.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -36,14 +37,22 @@ import Cardano.Ledger.Conway.Core ( ppMaxTxExUnitsL, ppMaxValSizeL, ppMinFeeAL, +#if __GLASGOW_HASKELL__ >= 914 + data SpendingPurpose, +#else pattern SpendingPurpose, +#endif ) import Cardano.Ledger.Core (EraScript (..), EraTx (..), EraTxBody (..), EraTxWits (..), hashScript) import Cardano.Ledger.Hashes (hashAnnotated) import Cardano.Ledger.Plutus (ExUnits (..)) import Cardano.Ledger.Plutus.Data (Data (..)) import Cardano.Ledger.Plutus.Language (Language (..)) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Shelley.Scripts (data RequireAllOf) +#else import Cardano.Ledger.Shelley.Scripts (pattern RequireAllOf) +#endif import Cardano.Ledger.Tools (estimateMinFeeTx) import qualified Data.Map.Strict as Map import qualified Data.Set as Set diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoBBODY.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoBBODY.hs index f3b2ba5f33c..191e1c73900 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoBBODY.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoBBODY.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -18,7 +19,11 @@ module Test.Cardano.Ledger.Examples.AlonzoBBODY (tests) where import Cardano.Ledger.Address (RewardAccount (..)) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Allegra.Scripts (data RequireTimeStart) +#else import Cardano.Ledger.Allegra.Scripts (pattern RequireTimeStart) +#endif import Cardano.Ledger.Alonzo.Plutus.Context (EraPlutusTxInfo) import Cardano.Ledger.Alonzo.Scripts (ExUnits (..)) import Cardano.Ledger.Alonzo.TxWits (Redeemers (..), hashDataTxWitsL) @@ -53,8 +58,13 @@ import Cardano.Ledger.Shelley.Rules ( ) import Cardano.Ledger.Shelley.Scripts ( ShelleyEraScript, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.State import Cardano.Ledger.TxIn (TxIn (..)) diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoCollectInputs.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoCollectInputs.hs index daff5376e09..d28ab2cc1ba 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoCollectInputs.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/AlonzoCollectInputs.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -28,7 +29,11 @@ import Cardano.Ledger.Alonzo.Scripts ( AsIx (..), AsIxItem (..), PlutusPurpose, +#if __GLASGOW_HASKELL__ >= 914 + data SpendingPurpose, +#else pattern SpendingPurpose, +#endif ) import Cardano.Ledger.Alonzo.TxWits ( AlonzoEraTxWits (..), diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/STSTestUtils.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/STSTestUtils.hs index fcd6e4fea01..cbf080e8bf9 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/STSTestUtils.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Examples/STSTestUtils.hs @@ -1,5 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -41,7 +43,11 @@ module Test.Cardano.Ledger.Examples.STSTestUtils ( ) where import Cardano.Ledger.Address (Addr (..)) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Allegra.Scripts (AllegraEraScript, data RequireTimeStart) +#else import Cardano.Ledger.Allegra.Scripts (AllegraEraScript, pattern RequireTimeStart) +#endif import Cardano.Ledger.Alonzo.Rules ( AlonzoUtxoPredFailure (..), AlonzoUtxosPredFailure (..), @@ -66,8 +72,13 @@ import Cardano.Ledger.Shelley.Rules (BbodyEnv (..), ShelleyBbodyState) import qualified Cardano.Ledger.Shelley.Rules as Shelley import Cardano.Ledger.Shelley.Scripts ( ShelleyEraScript, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.State import Cardano.Ledger.TxIn (TxIn (..)) diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Functions.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Functions.hs index 8fd768209fa..0ccb2ab265b 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Functions.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Functions.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -37,7 +38,11 @@ import Cardano.Ledger.Shelley.LedgerState ( NewEpochState (..), UTxOState (..), ) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Shelley.Scripts (data RequireAllOf, data RequireAnyOf) +#else import Cardano.Ledger.Shelley.Scripts (pattern RequireAllOf, pattern RequireAnyOf) +#endif import Cardano.Ledger.Shelley.TxOut (ShelleyTxOut (..)) import Cardano.Ledger.TxIn (TxIn (..)) import Cardano.Ledger.Val (Val ((<+>), (<->)), inject) diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/GenState.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/GenState.hs index 3756606cfe2..da3976d4058 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/GenState.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/GenState.hs @@ -1,6 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -85,8 +86,13 @@ import Cardano.Ledger.Allegra.Scripts ( AllegraEraScript, Timelock (..), ValidityInterval (..), +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Alonzo.Plutus.Context (EraPlutusContext) import Cardano.Ledger.Alonzo.Scripts hiding (Script) @@ -108,10 +114,17 @@ import Cardano.Ledger.Shelley.LedgerState ( import Cardano.Ledger.Shelley.Scripts ( MultiSig, ShelleyEraScript, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.State import Cardano.Ledger.TxIn (TxId, TxIn (..)) diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Instances.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Instances.hs index dfe5720cfc3..8364686a88d 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Instances.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Instances.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} @@ -7,6 +8,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -Wno-orphans #-} module Test.Cardano.Ledger.Generic.Instances () where @@ -32,7 +34,11 @@ import Cardano.Ledger.Credential (Credential (..), Ptr (..)) import Cardano.Ledger.Mary (MaryEra) import Cardano.Ledger.Plutus (ExUnits (..), Language (..)) import Cardano.Ledger.Shelley (ShelleyEra) +#if __GLASGOW_HASKELL__ >= 914 +import Cardano.Ledger.Shelley.Scripts (data RequireAllOf, data RequireAnyOf) +#else import Cardano.Ledger.Shelley.Scripts (pattern RequireAllOf, pattern RequireAnyOf) +#endif import Cardano.Ledger.Shelley.TxCert (ShelleyDelegCert (..), ShelleyTxCert (..)) import Cardano.Ledger.Val (Val (..)) import Control.Monad.RWS.Strict (gets) diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/MockChain.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/MockChain.hs index 920165069d2..6196dfa5df5 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/MockChain.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/MockChain.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE EmptyCase #-} @@ -122,7 +123,11 @@ instance (Era era, NoThunks (NewEpochState era)) => NoThunks (MockChainState era instance ( EraGov era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , STS (ShelleyTICK era) +#endif , State (EraRule "TICK" era) ~ NewEpochState era , Signal (EraRule "TICK" era) ~ SlotNo , Environment (EraRule "TICK" era) ~ () diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/TxGen.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/TxGen.hs index 85ca237e64c..324ed005398 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/TxGen.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/TxGen.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -32,8 +33,13 @@ module Test.Cardano.Ledger.Generic.TxGen ( import Cardano.Ledger.Allegra.Scripts ( AllegraEraScript, Timelock (..), +#if __GLASGOW_HASKELL__ >= 914 + data RequireTimeExpire, + data RequireTimeStart, +#else pattern RequireTimeExpire, pattern RequireTimeStart, +#endif ) import Cardano.Ledger.Alonzo.Scripts hiding (Script) import Cardano.Ledger.Alonzo.TxBody (AlonzoTxOut (..)) @@ -58,10 +64,17 @@ import Cardano.Ledger.Shelley.API ( import Cardano.Ledger.Shelley.Scripts ( MultiSig, ShelleyEraScript, +#if __GLASGOW_HASKELL__ >= 914 + data RequireAllOf, + data RequireAnyOf, + data RequireMOf, + data RequireSignature, +#else pattern RequireAllOf, pattern RequireAnyOf, pattern RequireMOf, pattern RequireSignature, +#endif ) import Cardano.Ledger.Shelley.TxCert (ShelleyTxCert (..)) import Cardano.Ledger.Slot (EpochNo (EpochNo)) @@ -139,7 +152,7 @@ import Test.Cardano.Ledger.Generic.ModelState ( import Test.Cardano.Ledger.Generic.Proof hiding (lift) import Test.Cardano.Ledger.Shelley.Serialisation.EraIndepGenerators () import Test.Cardano.Ledger.Shelley.Utils (epochFromSlotNo, runShelleyBase) -import Test.QuickCheck +import Test.QuickCheck hiding (Some) alonzoMkRedeemersFromTags :: (AlonzoEraScript era, EraModel era) => diff --git a/libs/cardano-protocol-tpraos/test/Test/Cardano/Protocol/Binary/BinarySpec.hs b/libs/cardano-protocol-tpraos/test/Test/Cardano/Protocol/Binary/BinarySpec.hs index a5a846db4f8..bdb18886a46 100644 --- a/libs/cardano-protocol-tpraos/test/Test/Cardano/Protocol/Binary/BinarySpec.hs +++ b/libs/cardano-protocol-tpraos/test/Test/Cardano/Protocol/Binary/BinarySpec.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -36,7 +37,11 @@ spec = do blockEraSpec :: forall era. ( EraBlockBody era +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Arbitrary (Tx TopTx era) +#endif , Arbitrary (BlockBody era) ) => Spec diff --git a/libs/cardano-protocol-tpraos/testlib/Test/Cardano/Protocol/TPraos/Arbitrary.hs b/libs/cardano-protocol-tpraos/testlib/Test/Cardano/Protocol/TPraos/Arbitrary.hs index 8eb58e3c713..fb43074865d 100644 --- a/libs/cardano-protocol-tpraos/testlib/Test/Cardano/Protocol/TPraos/Arbitrary.hs +++ b/libs/cardano-protocol-tpraos/testlib/Test/Cardano/Protocol/TPraos/Arbitrary.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE DisambiguateRecordFields #-} {-# LANGUAGE FlexibleContexts #-} @@ -155,7 +156,11 @@ instance , EraBlockBody era , KES.Signable (KES c) ~ SignableRepresentation , VRF.Signable (VRF c) ~ SignableRepresentation +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 , Arbitrary (Tx TopTx era) +#endif , Arbitrary (BlockBody era) ) => Arbitrary (Block (BHeader c) era) diff --git a/libs/non-integral/test/Tests/Cardano/Ledger/NonIntegral.hs b/libs/non-integral/test/Tests/Cardano/Ledger/NonIntegral.hs index 227339e5a5e..2f8c52b0b66 100644 --- a/libs/non-integral/test/Tests/Cardano/Ledger/NonIntegral.hs +++ b/libs/non-integral/test/Tests/Cardano/Ledger/NonIntegral.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE TypeSynonymInstances #-} @@ -42,10 +43,22 @@ newtype Normalized a = Norm (a, a) deriving (Show) newtype UnitInterval a = Unit a deriving (Show) -instance (Fractional a, Arbitrary a) => Arbitrary (Normalized a) where +instance (Fractional a +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Arbitrary a +#endif + ) => Arbitrary (Normalized a) where arbitrary = return . Norm . normalize =<< arbitrary -instance (Fractional a, Arbitrary a) => Arbitrary (UnitInterval a) where +instance (Fractional a +#if __GLASGOW_HASKELL__ < 914 + -- These constraints are REQUIRED for ghc < 9.14 but REDUNDANT for ghc >= 9.14 + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26381#note_637863 + , Arbitrary a +#endif + ) => Arbitrary (UnitInterval a) where arbitrary = return . Unit . toUnit =<< arbitrary type NonNegInts = (NonNegative Integer, Positive Integer)