Skip to content

Commit

Permalink
Disable redundant-constraints only on ghc-8.10.7
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Sep 5, 2023
1 parent 6b27964 commit 5d68efa
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 41 deletions.
3 changes: 3 additions & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 7 additions & 15 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -37,27 +37,19 @@ 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
-> ExceptT ShelleyAddressCmdError IO ()
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
Expand Down
7 changes: 4 additions & 3 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 10 additions & 14 deletions cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 5 additions & 9 deletions cardano-cli/src/Cardano/CLI/Types/Key.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5d68efa

Please sign in to comment.