From 5d68efaaa7cf417033b8d87150fb6376ed2e9fed Mon Sep 17 00:00:00 2001 From: John Ky Date: Tue, 5 Sep 2023 20:48:15 +1000 Subject: [PATCH] Disable redundant-constraints only on ghc-8.10.7 --- cardano-cli/cardano-cli.cabal | 3 +++ .../src/Cardano/CLI/EraBased/Run/Address.hs | 22 ++++++----------- .../src/Cardano/CLI/EraBased/Run/Key.hs | 7 +++--- .../src/Cardano/CLI/Legacy/Run/Genesis.hs | 24 ++++++++----------- cardano-cli/src/Cardano/CLI/Types/Key.hs | 14 ++++------- 5 files changed, 29 insertions(+), 41 deletions(-) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 5c854e1112..8327949cd3 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -51,6 +51,9 @@ library if flag(unexpected_thunks) cpp-options: -DUNEXPECTED_THUNKS + if impl(ghc < 9) + ghc-options: -Wno-redundant-constraints + hs-source-dirs: src exposed-modules: Cardano.CLI.Byron.Commands diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs index 594572bd6d..c69165586c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs @@ -14,11 +14,11 @@ import Cardano.Api import Cardano.Api.Shelley import Cardano.CLI.Read -import Cardano.CLI.Types.Key (PaymentVerifier (..), StakeIdentifier (..), - StakeVerifier (..), VerificationKeyTextOrFile, generateKeyPair, readVerificationKeyOrFile, - readVerificationKeyTextOrFileAnyOf) import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.ShelleyAddressCmdError +import Cardano.CLI.Types.Key (PaymentVerifier (..), StakeIdentifier (..), + StakeVerifier (..), VerificationKeyTextOrFile, generateKeyPair, + readVerificationKeyOrFile, readVerificationKeyTextOrFileAnyOf) import Control.Monad.IO.Class (MonadIO (..)) import Control.Monad.Trans.Except (ExceptT) @@ -37,13 +37,9 @@ runAddressKeyGenCmd fmt kt vkf skf = case kt of AddressKeyShelleyExtended -> generateAndWriteKeyFiles fmt AsPaymentExtendedKey vkf skf AddressKeyByron -> generateAndWriteByronKeyFiles AsByronKey vkf skf -generateAndWriteByronKeyFiles - :: Key keyrole -#if __GLASGOW_HASKELL__ >= 904 --- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.4 and above complains if its --- not present. +generateAndWriteByronKeyFiles :: () + => Key keyrole => HasTypeProxy keyrole -#endif => AsType keyrole -> VerificationKeyFile Out -> SigningKeyFile Out @@ -51,13 +47,9 @@ generateAndWriteByronKeyFiles generateAndWriteByronKeyFiles asType vkf skf = do uncurry (writeByronPaymentKeyFiles vkf skf) =<< liftIO (generateKeyPair asType) -generateAndWriteKeyFiles - :: Key keyrole -#if __GLASGOW_HASKELL__ >= 904 --- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.4 and above complains if its --- not present. +generateAndWriteKeyFiles :: () + => Key keyrole => HasTypeProxy keyrole -#endif => SerialiseAsBech32 (SigningKey keyrole) => SerialiseAsBech32 (VerificationKey keyrole) => KeyOutputFormat diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs index a144b96a07..d6415f0590 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs @@ -76,9 +76,10 @@ data SomeSigningKey | AVrfSigningKey (SigningKey VrfKey) | AKesSigningKey (SigningKey KesKey) -withSomeSigningKey :: SomeSigningKey - -> (forall keyrole. (Key keyrole, HasTypeProxy keyrole) => SigningKey keyrole -> a) - -> a +withSomeSigningKey :: () + => SomeSigningKey + -> (forall keyrole. (Key keyrole, HasTypeProxy keyrole) => SigningKey keyrole -> a) + -> a withSomeSigningKey ssk f = case ssk of AByronSigningKey sk -> f sk diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs index 0429270b8d..7c3a3b813c 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs @@ -1,6 +1,6 @@ {-# LANGUAGE BangPatterns #-} -{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE CPP #-} +{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -46,17 +46,17 @@ import Cardano.Chain.Update hiding (ProtocolParameters) import Cardano.CLI.Byron.Delegation import Cardano.CLI.Byron.Genesis as Byron import qualified Cardano.CLI.Byron.Key as Byron +import Cardano.CLI.EraBased.Run.StakeAddress (runStakeAddressKeyGenToFileCmd) import qualified Cardano.CLI.IO.Lazy as Lazy import Cardano.CLI.Legacy.Commands.Genesis -import Cardano.CLI.Legacy.Run.Node ( - runLegacyNodeIssueOpCertCmd, runLegacyNodeKeyGenColdCmd, runLegacyNodeKeyGenKesCmd, runLegacyNodeKeyGenVrfCmd) -import Cardano.CLI.EraBased.Run.StakeAddress (runStakeAddressKeyGenToFileCmd) +import Cardano.CLI.Legacy.Run.Node (runLegacyNodeIssueOpCertCmd, + runLegacyNodeKeyGenColdCmd, runLegacyNodeKeyGenKesCmd, runLegacyNodeKeyGenVrfCmd) import Cardano.CLI.Orphans () import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.ProtocolParamsError import Cardano.CLI.Types.Errors.ShelleyGenesisCmdError -import Cardano.CLI.Types.Errors.ShelleyPoolCmdError import Cardano.CLI.Types.Errors.ShelleyNodeCmdError +import Cardano.CLI.Types.Errors.ShelleyPoolCmdError import Cardano.CLI.Types.Key import qualified Cardano.Crypto as CC import Cardano.Crypto.Hash (HashAlgorithm) @@ -403,15 +403,11 @@ runLegacyGenesisCreateCmd toSKeyJSON :: Key a => SigningKey a -> ByteString toSKeyJSON = LBS.toStrict . textEnvelopeToJSON Nothing -toVkeyJSON :: -#if __GLASGOW_HASKELL__ >= 904 --- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.4 and above complains if its --- not present. - (Key a, HasTypeProxy a) => -#else - (Key a) => -#endif - 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/Types/Key.hs b/cardano-cli/src/Cardano/CLI/Types/Key.hs index 81794a5471..99d8f90e33 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Key.hs @@ -327,15 +327,11 @@ readVerificationKeyOrHashOrTextEnvFile asType verKeyOrHashOrFile = pure (verificationKeyHash <$> eitherVk) VerificationKeyHash vkHash -> pure (Right vkHash) -generateKeyPair :: -#if __GLASGOW_HASKELL__ >= 904 --- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.4 and above complains if its --- not present. - (Key keyrole, HasTypeProxy keyrole) => -#else - Key keyrole => -#endif - AsType keyrole -> IO (VerificationKey keyrole, SigningKey keyrole) +generateKeyPair :: () + => Key keyrole + => HasTypeProxy keyrole + => AsType keyrole + -> IO (VerificationKey keyrole, SigningKey keyrole) generateKeyPair asType = do skey <- generateSigningKey asType return (getVerificationKey skey, skey)