From 6e22a69bd0ce967d87ee57b0e9147a9e8d980817 Mon Sep 17 00:00:00 2001 From: Alexander Esgen Date: Fri, 8 Sep 2023 11:43:53 +0200 Subject: [PATCH] `Translate`: allow heterogenous translations --- .../Consensus/HardFork/Combinator/Protocol.hs | 2 +- .../Consensus/HardFork/Combinator/State/Types.hs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs index e85142bf9d..6d2a5e6e9c 100644 --- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs +++ b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs @@ -51,7 +51,7 @@ import Ouroboros.Consensus.HardFork.Combinator.Protocol.ChainSel import Ouroboros.Consensus.HardFork.Combinator.Protocol.LedgerView (HardForkLedgerView, HardForkLedgerView_ (..), Ticked (..)) import Ouroboros.Consensus.HardFork.Combinator.State (HardForkState, - Translate (..)) + Translate) import qualified Ouroboros.Consensus.HardFork.Combinator.State as State import Ouroboros.Consensus.HardFork.Combinator.Translation import Ouroboros.Consensus.Protocol.Abstract diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/State/Types.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/State/Types.hs index c146392dc3..66f8cf1403 100644 --- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/State/Types.hs +++ b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/State/Types.hs @@ -12,8 +12,10 @@ module Ouroboros.Consensus.HardFork.Combinator.State.Types ( , sequenceHardForkState -- * Supporting types , CrossEraForecaster (..) + , TickedTranslate , TransitionInfo (..) - , Translate (..) + , Translate + , Translate' (..) ) where import Control.Monad.Except @@ -109,13 +111,17 @@ sequenceHardForkState (HardForkState tel) = Supporting types -------------------------------------------------------------------------------} --- | Translate @f x@ to @f y@ across an era transition +-- | Translate @f x@ to @g y@ across an era transition -- --- Typically @f@ will be 'LedgerState' or 'WrapChainDepState'. -newtype Translate f x y = Translate { - translateWith :: EpochNo -> f x -> f y +-- Typically @f@/@g@ will be 'LedgerState' or 'WrapChainDepState'. +newtype Translate' f g x y = Translate { + translateWith :: EpochNo -> f x -> g y } +type Translate f = Translate' f f + +type TickedTranslate f = Translate' (Ticked :.: f) f + -- | Forecast a @'Ticked' (view y)@ from a @state x@ across an -- era transition. --