From 7c32575f838a7dbf370572ce6306496ab1eb5147 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Jul 2023 08:08:32 +1000 Subject: [PATCH] Make it build with ghc-9.6 --- cabal.project | 24 ++++++++++++++++++- cardano-cli/cardano-cli.cabal | 2 +- cardano-cli/src/Cardano/CLI/Shelley/Key.hs | 11 ++++++++- .../src/Cardano/CLI/Shelley/Run/Address.hs | 11 +++++++++ .../src/Cardano/CLI/Shelley/Run/Genesis.hs | 2 +- .../src/Cardano/CLI/Shelley/Run/Key.hs | 2 +- .../src/Cardano/CLI/Shelley/Run/Query.hs | 1 + 7 files changed, 48 insertions(+), 5 deletions(-) diff --git a/cabal.project b/cabal.project index 2000e135aa..c6a7d981d7 100644 --- a/cabal.project +++ b/cabal.project @@ -13,7 +13,7 @@ repository cardano-haskell-packages -- See CONTRIBUTING for information about these, including some Nix commands -- you need to run if you change them index-state: - , hackage.haskell.org 2023-07-05T20:00:33Z + , hackage.haskell.org 2023-07-10T22:41:49Z , cardano-haskell-packages 2023-07-13T14:00:00Z packages: @@ -37,6 +37,28 @@ test-show-details: direct -- Always write GHC env files, because they are needed for ghci. write-ghc-environment-files: always +-- https://github.com/obsidiansystems/dependent-sum-template/issues/5 +if impl(ghc >= 9.2) + constraints : + dependent-sum-template < 0.1.2 + +if impl(ghc >= 9.6) + allow-newer: + -- Only really needed because `cardano-ledger-byron-test` has not yet been released to CHaP + -- and its not possible to specify `cardano-ledger-byron-test:base` because the dependencies + -- of `cardano-ledger-byron-test` also do not permit the version of `base` that `ghc-9.6` + -- provides. + , *:base + +source-repository-package + type: git + location: https://github.com/input-output-hk/cardano-api + tag: 9e018cc133bafaf9be899087d27199e6bdb5b3de + subdir: + cardano-api + cardano-api-gen + + -- IMPORTANT -- Do NOT add more source-repository-package stanzas here unless they are strictly -- temporary! Please read the section in CONTRIBUTING about updating dependencies. diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 5dec823f96..d852b13066 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -23,7 +23,7 @@ common project-config default-language: Haskell2010 default-extensions: OverloadedStrings - build-depends: base >= 4.14 && < 4.17 + build-depends: base >= 4.14 && < 4.19 ghc-options: -Wall -Wcompat diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Key.hs b/cardano-cli/src/Cardano/CLI/Shelley/Key.hs index 56cfcedd1b..152b9a7d19 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Key.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} @@ -205,7 +206,15 @@ readVerificationKeyOrHashOrTextEnvFile asType verKeyOrHashOrFile = pure (verificationKeyHash <$> eitherVk) VerificationKeyHash vkHash -> pure (Right vkHash) -generateKeyPair :: Key keyrole => AsType keyrole -> IO (VerificationKey keyrole, SigningKey keyrole) +generateKeyPair :: +#if __GLASGOW_HASKELL__ >= 902 +-- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.2 and above complains if its +-- not present. + (Key keyrole, HasTypeProxy keyrole) => +#else + Key keyrole => +#endif + AsType keyrole -> IO (VerificationKey keyrole, SigningKey keyrole) generateKeyPair asType = do skey <- generateSigningKey asType return (getVerificationKey skey, skey) diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs index 29e2273a2a..aab7382881 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-} @@ -78,6 +79,11 @@ runAddressKeyGenToFile fmt kt vkf skf = case kt of generateAndWriteByronKeyFiles :: Key keyrole +#if __GLASGOW_HASKELL__ >= 902 +-- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.2 and above complains if its +-- not present. + => HasTypeProxy keyrole +#endif => AsType keyrole -> VerificationKeyFile Out -> SigningKeyFile Out @@ -87,6 +93,11 @@ generateAndWriteByronKeyFiles asType vkf skf = do generateAndWriteKeyFiles :: Key keyrole +#if __GLASGOW_HASKELL__ >= 902 +-- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.2 and above complains if its +-- not present. + => HasTypeProxy keyrole +#endif => SerialiseAsBech32 (SigningKey keyrole) => SerialiseAsBech32 (VerificationKey keyrole) => KeyOutputFormat diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs index ebdd143e9b..bd57330868 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs @@ -458,7 +458,7 @@ runGenesisCreate toSKeyJSON :: Key a => SigningKey a -> ByteString toSKeyJSON = LBS.toStrict . textEnvelopeToJSON Nothing -toVkeyJSON :: Key a => SigningKey a -> ByteString +toVkeyJSON :: (Key a, HasTypeProxy a) => SigningKey a -> ByteString toVkeyJSON = LBS.toStrict . textEnvelopeToJSON Nothing . getVerificationKey toVkeyJSON' :: Key a => VerificationKey a -> ByteString diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs index 7a9e0e2f53..0ca0a86947 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs @@ -139,7 +139,7 @@ data SomeSigningKey | AKesSigningKey (SigningKey KesKey) withSomeSigningKey :: SomeSigningKey - -> (forall keyrole. Key keyrole => SigningKey keyrole -> a) + -> (forall keyrole. (Key keyrole, HasTypeProxy keyrole) => SigningKey keyrole -> a) -> a withSomeSigningKey ssk f = case ssk of diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs index f9f5879cbb..4395f37424 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs @@ -8,6 +8,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-} {-# OPTIONS_GHC -fno-warn-orphans #-}