diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Classes.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Classes.hs index 90902af7cc6..2348475ae26 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Classes.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Classes.hs @@ -773,8 +773,8 @@ data CertStateF era where unCertStateF :: CertStateF era -> CertState era unCertStateF (CertStateF _ x) = x -instance PrettyA (CertStateF era) where - prettyA (CertStateF p x) = unReflect pcCertState p x +instance Reflect era => PrettyA (CertStateF era) where + prettyA (CertStateF _ x) = pcCertState x instance Eq (CertStateF era) where (CertStateF Shelley x) == (CertStateF Shelley y) = x == y @@ -882,14 +882,14 @@ genProposedPPUpdates p = case p of Babbage -> ProposedPPUpdatesF p . PP.ProposedPPUpdates <$> arbitrary Conway -> ProposedPPUpdatesF p . PP.ProposedPPUpdates <$> arbitrary -genCertState :: Proof era -> Gen (CertStateF era) -genCertState p = case p of - Shelley -> CertStateF p <$> arbitrary - Allegra -> CertStateF p <$> arbitrary - Mary -> CertStateF p <$> arbitrary - Alonzo -> CertStateF p <$> arbitrary - Babbage -> CertStateF p <$> arbitrary - Conway -> CertStateF p <$> arbitrary +genCertState :: forall era. Reflect era => Gen (CertStateF era) +genCertState = case reify @era of + p@Shelley -> CertStateF p <$> arbitrary + p@Allegra -> CertStateF p <$> arbitrary + p@Mary -> CertStateF p <$> arbitrary + p@Alonzo -> CertStateF p <$> arbitrary + p@Babbage -> CertStateF p <$> arbitrary + p@Conway -> CertStateF p <$> arbitrary genGovState :: Proof era -> Gen (GovState era) genGovState p = case p of diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Preds/CertState.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Preds/CertState.hs index e47fda64147..25aef7758e8 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Preds/CertState.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Preds/CertState.hs @@ -351,7 +351,7 @@ demoC mode = do >>= (\subst -> monadTyped $ substToEnv subst emptyEnv) ) certState <- monadTyped . runTarget env $ certStateT - when (mode == Interactive) $ putStrLn (show (pcCertState proof (unCertStateF certState))) + when (mode == Interactive) $ putStrLn (show (pcCertState (unCertStateF certState))) modeRepl mode proof env "" demoTestC :: TestTree diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/TypeRep.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/TypeRep.hs index ea9d13acc18..acadda176e5 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/TypeRep.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/TypeRep.hs @@ -280,7 +280,7 @@ data Rep era t where PParamsR :: Era era => Proof era -> Rep era (PParamsF era) FuturePParamsR :: Era era => Proof era -> Rep era (FuturePParams era) PParamsUpdateR :: Era era => Proof era -> Rep era (PParamsUpdateF era) - CertStateR :: Era era => Proof era -> Rep era (CertStateF era) + CertStateR :: Reflect era => Rep era (CertStateF era) -- DeltaCoinR :: Rep era DeltaCoin GenDelegPairR :: Era era => Rep era GenDelegPair @@ -613,7 +613,7 @@ synopsis (UTxOR p) (UTxO mp) = "UTxO( " ++ synopsis (MapR TxInR (TxOutR p)) (Map synopsis (PParamsR _) (PParamsF p x) = show $ pcPParams p x synopsis (FuturePParamsR p) x = show $ pcFuturePParams p x synopsis (PParamsUpdateR _) _ = "PParamsUpdate ..." -synopsis (CertStateR _) (CertStateF p x) = show $ pcCertState p x +synopsis CertStateR (CertStateF _ x) = show $ pcCertState x synopsis DeltaCoinR (DeltaCoin n) = show (hsep [ppString "▵₳", ppInteger n]) synopsis GenDelegPairR x = show (pcGenDelegPair x) synopsis FutureGenDelegR x = show (pcFutureGenDeleg x) @@ -773,7 +773,7 @@ genSizedRep _n (UTxOR p) = genUTxO p genSizedRep _ (PParamsR p) = genPParams p genSizedRep _ (FuturePParamsR p) = genFuturePParams p genSizedRep _ (PParamsUpdateR p) = genPParamsUpdate p -genSizedRep _ (CertStateR p) = genCertState p +genSizedRep _ CertStateR = genCertState genSizedRep _ DeltaCoinR = DeltaCoin <$> choose (-1000, 1000) genSizedRep _ GenDelegPairR = arbitrary genSizedRep _ FutureGenDelegR = arbitrary @@ -1041,7 +1041,7 @@ shrinkRep (UTxOR _) _ = [] shrinkRep (PParamsR _) _ = [] shrinkRep (FuturePParamsR _) _ = [] shrinkRep (PParamsUpdateR _) _ = [] -shrinkRep (CertStateR _) _ = [] +shrinkRep CertStateR _ = [] shrinkRep CharR t = shrink t shrinkRep DeltaCoinR t = shrink t shrinkRep GenDelegPairR t = shrink t diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/PrettyCore.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/PrettyCore.hs index 80435a5e35a..bc55e70e118 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/PrettyCore.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/PrettyCore.hs @@ -3167,12 +3167,12 @@ instance PrettyA FutureGenDeleg where instance PrettyA GenDelegPair where prettyA = pcGenDelegPair -pcCertState :: Proof era -> CertState era -> PDoc -pcCertState p certState = case whichCertState p of - CertStateShelleyToBabbage -> pcShelleyCertState p certState +pcCertState :: forall era. Reflect era => CertState era -> PDoc +pcCertState certState = case whichCertState (reify @era) of + CertStateShelleyToBabbage -> pcShelleyCertState certState -pcShelleyCertState :: Proof era -> ShelleyCertState era -> PDoc -pcShelleyCertState _p (ShelleyCertState {..}) = +pcShelleyCertState :: ShelleyCertState era -> PDoc +pcShelleyCertState (ShelleyCertState {..}) = ppRecord "ShelleyCertState" [ ("pstate", pcPState shelleyCertPState) @@ -3374,12 +3374,12 @@ psUTxOState proof (UTxOState (UTxO u) dep fs gs (IStake m _) don) = , ("donation", pcCoin don) ] -pcLedgerState :: Proof era -> LedgerState era -> PDoc +pcLedgerState :: Reflect era => Proof era -> LedgerState era -> PDoc pcLedgerState proof ls = ppRecord "LedgerState" [ ("utxoState", pcUTxOState proof (lsUTxOState ls)) - , ("certState", pcCertState proof (lsCertState ls)) + , ("certState", pcCertState (lsCertState ls)) ] instance Reflect era => PrettyA (LedgerState era) where @@ -3391,7 +3391,7 @@ psLedgerState proof ls = ppRecord "LedgerState" [ ("utxoState", psUTxOState proof (lsUTxOState ls)) - , ("certState", pcCertState proof (lsCertState ls)) + , ("certState", pcCertState (lsCertState ls)) ] pcPState :: PState era -> PDoc @@ -3667,7 +3667,7 @@ instance Reflect era => PrettyA (CertEnv era) where ] instance Reflect era => PrettyA (ShelleyCertState era) where - prettyA = pcShelleyCertState reify + prettyA = pcShelleyCertState instance PrettyA x => PrettyA (Seq x) where prettyA x = prettyA (toList x) diff --git a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Same.hs b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Same.hs index 8ecbecb7b25..209aa50dd75 100644 --- a/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Same.hs +++ b/libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Same.hs @@ -179,9 +179,9 @@ instance Reflect era => Same era (LedgerState era) where ++ certState where prettyShelley :: [(String, Maybe PDoc)] - prettyShelley = [("ShelleyCertState", (sameCertState proof (lsCertState x1) (lsCertState x2)))] + prettyShelley = [("ShelleyCertState", (sameCertState (lsCertState x1) (lsCertState x2)))] prettyConway :: [(String, Maybe PDoc)] - prettyConway = [("ConwayCertState", (sameCertState proof (lsCertState x1) (lsCertState x2)))] + prettyConway = [("ConwayCertState", (sameCertState (lsCertState x1) (lsCertState x2)))] certState = case reify @era of Shelley -> prettyShelley Mary -> prettyShelley @@ -350,13 +350,14 @@ sameTransCtx Babbage x y = eqByShow x y sameTransCtx Conway x y = eqByShow x y {-# NOINLINE sameTransCtx #-} -sameCertState :: Proof era -> CertState era -> CertState era -> Maybe PDoc -sameCertState Shelley x y = eqByShow x y -sameCertState Allegra x y = eqByShow x y -sameCertState Mary x y = eqByShow x y -sameCertState Alonzo x y = eqByShow x y -sameCertState Babbage x y = eqByShow x y -sameCertState Conway x y = eqByShow x y +sameCertState :: forall era. Reflect era => CertState era -> CertState era -> Maybe PDoc +sameCertState x y = case reify @era of + Shelley -> eqByShow x y + Allegra -> eqByShow x y + Mary -> eqByShow x y + Alonzo -> eqByShow x y + Babbage -> eqByShow x y + Conway -> eqByShow x y {-# NOINLINE sameCertState #-} -- ==========================