Skip to content

Commit

Permalink
Extract indexProxy from HashAnnotated type class and deprecate it
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Dec 19, 2024
1 parent 9e4f836 commit 282302b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions libs/cardano-ledger-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 0 additions & 4 deletions libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ module Cardano.Ledger.Hashes (
-- ** Other operations
castSafeHash,
extractHash,
indexProxy,
)
where

Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions libs/cardano-ledger-core/src/Cardano/Ledger/SafeHash.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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" #-}

0 comments on commit 282302b

Please sign in to comment.