From 282302b59088c2f11fae37b2c3531ba3766264fc Mon Sep 17 00:00:00 2001 From: Alexey Kuleshevich Date: Thu, 19 Dec 2024 15:30:44 -0700 Subject: [PATCH] Extract `indexProxy` from `HashAnnotated` type class and deprecate it --- libs/cardano-ledger-core/CHANGELOG.md | 1 + libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs | 4 ---- libs/cardano-ledger-core/src/Cardano/Ledger/SafeHash.hs | 9 +++++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/cardano-ledger-core/CHANGELOG.md b/libs/cardano-ledger-core/CHANGELOG.md index a79861aee47..091ec6d4cc9 100644 --- a/libs/cardano-ledger-core/CHANGELOG.md +++ b/libs/cardano-ledger-core/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.17.0.0 +* Extract `indexProxy` from `HashAnnotated` type class and deprecate it. * Extract `hashTxAuxData` from `EraTxAuxData` into a standalone function. * Add `TxAuxDataHash` and deprecate `AuxiliaryDayaHash` in its favor. * Deprecate `Cardano.Ledger.Crypto` module in favor of `cardano-protocol-tpraos:Cardano.Protocol.Crypto` diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs index b78f55a2fb0..e51d833ad76 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs @@ -76,7 +76,6 @@ module Cardano.Ledger.Hashes ( -- ** Other operations castSafeHash, extractHash, - indexProxy, ) where @@ -386,9 +385,6 @@ instance Hash.HashAlgorithm h => SafeToHash (Hash.Hash h i) where -- can be easily derived (because their methods have default methods when the type is a -- newtype around a type that is 'SafeToHash'). For example, class SafeToHash x => HashAnnotated x i | x -> i where - -- TODO: move outside of type class - indexProxy :: x -> Proxy i - indexProxy _ = Proxy @i -- | Create a @('SafeHash' i)@, given @(`HashAnnotated` x i)@ instance. hashAnnotated :: x -> SafeHash i diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/SafeHash.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/SafeHash.hs index e3adb237cab..a465eda6c06 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/SafeHash.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/SafeHash.hs @@ -1,3 +1,7 @@ +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-redundant-constraints #-} + module Cardano.Ledger.SafeHash {-# DEPRECATED "Use `Cardano.Ledger.Hashes` instead" #-} ( -- * SafeHash and SafeToHash @@ -26,3 +30,8 @@ module Cardano.Ledger.SafeHash where import Cardano.Ledger.Hashes +import Data.Proxy + +indexProxy :: forall x i. HashAnnotated x i => x -> Proxy i +indexProxy _ = Proxy @i +{-# DEPRECATED indexProxy "As useless and unused" #-}