From 500b62ef8545607e1b645642ad34f159a9bcaf63 Mon Sep 17 00:00:00 2001 From: John Ky Date: Sat, 16 Sep 2023 15:34:27 +1000 Subject: [PATCH 1/7] Fix typo --- cardano-api/internal/Cardano/Api/Eras/Core.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/Eras/Core.hs b/cardano-api/internal/Cardano/Api/Eras/Core.hs index 96940b2580..3bcc5322b9 100644 --- a/cardano-api/internal/Cardano/Api/Eras/Core.hs +++ b/cardano-api/internal/Cardano/Api/Eras/Core.hs @@ -139,7 +139,7 @@ class FeatureInEra (feature :: Type -> Type) where -- the 'either' function convention. featureInEra :: () => a -- ^ Value to use if the feature is not supported in the era - -> (feature era -> a) -- ^ Function to get thealue to use if the feature is supported in the era + -> (feature era -> a) -- ^ Function to get the value to use if the feature is supported in the era -> CardanoEra era -- ^ Era to check -> a -- ^ The value to use @@ -147,7 +147,7 @@ inEraFeature :: () => FeatureInEra feature => CardanoEra era -- ^ Era to check -> a -- ^ Value to use if the feature is not supported in the era - -> (feature era -> a) -- ^ Function to get thealue to use if the feature is supported in the era + -> (feature era -> a) -- ^ Function to get the value to use if the feature is supported in the era -> a -- ^ The value to use inEraFeature era no yes = featureInEra no yes era @@ -155,7 +155,7 @@ inEraFeature era no yes = inEraFeatureMaybe :: () => FeatureInEra feature => CardanoEra era -- ^ Era to check - -> (feature era -> a) -- ^ Function to get thealue to use if the feature is supported in the era + -> (feature era -> a) -- ^ Function to get the value to use if the feature is supported in the era -> Maybe a -- ^ The value to use inEraFeatureMaybe era yes = inEraFeature era Nothing (Just . yes) From 072d0bfd96f5d4dc68fb2ea40e3a3c8d2356c49a Mon Sep 17 00:00:00 2001 From: John Ky Date: Sat, 16 Sep 2023 08:24:19 +1000 Subject: [PATCH 2/7] Rename Feature module to Eon --- cardano-api/cardano-api.cabal | 16 ++++++++-------- cardano-api/internal/Cardano/Api/Certificate.hs | 4 ++-- .../internal/Cardano/Api/Convenience/Query.hs | 2 +- .../Api/{Feature => Eon}/AlonzoEraOnly.hs | 2 +- .../Api/{Feature => Eon}/AlonzoEraOnwards.hs | 2 +- .../Api/{Feature => Eon}/BabbageEraOnwards.hs | 2 +- .../Api/{Feature => Eon}/ConwayEraOnwards.hs | 2 +- .../Api/{Feature => Eon}/ShelleyToAllegraEra.hs | 2 +- .../Api/{Feature => Eon}/ShelleyToAlonzoEra.hs | 2 +- .../Api/{Feature => Eon}/ShelleyToBabbageEra.hs | 2 +- .../Api/{Feature => Eon}/ShelleyToMaryEra.hs | 2 +- cardano-api/internal/Cardano/Api/Eras/Case.hs | 12 ++++++------ cardano-api/internal/Cardano/Api/TxBody.hs | 2 +- cardano-api/src/Cardano/Api.hs | 16 ++++++++-------- 14 files changed, 34 insertions(+), 34 deletions(-) rename cardano-api/internal/Cardano/Api/{Feature => Eon}/AlonzoEraOnly.hs (98%) rename cardano-api/internal/Cardano/Api/{Feature => Eon}/AlonzoEraOnwards.hs (99%) rename cardano-api/internal/Cardano/Api/{Feature => Eon}/BabbageEraOnwards.hs (98%) rename cardano-api/internal/Cardano/Api/{Feature => Eon}/ConwayEraOnwards.hs (98%) rename cardano-api/internal/Cardano/Api/{Feature => Eon}/ShelleyToAllegraEra.hs (98%) rename cardano-api/internal/Cardano/Api/{Feature => Eon}/ShelleyToAlonzoEra.hs (99%) rename cardano-api/internal/Cardano/Api/{Feature => Eon}/ShelleyToBabbageEra.hs (99%) rename cardano-api/internal/Cardano/Api/{Feature => Eon}/ShelleyToMaryEra.hs (99%) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index ee8ef2529e..9bc2c5ebad 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -55,6 +55,14 @@ library internal Cardano.Api.Convenience.Query Cardano.Api.DeserialiseAnyOf Cardano.Api.DRepMetadata + Cardano.Api.Eon.AlonzoEraOnly + Cardano.Api.Eon.AlonzoEraOnwards + Cardano.Api.Eon.BabbageEraOnwards + Cardano.Api.Eon.ConwayEraOnwards + Cardano.Api.Eon.ShelleyToAllegraEra + Cardano.Api.Eon.ShelleyToAlonzoEra + Cardano.Api.Eon.ShelleyToBabbageEra + Cardano.Api.Eon.ShelleyToMaryEra Cardano.Api.EraCast Cardano.Api.Eras Cardano.Api.Eras.Case @@ -62,14 +70,6 @@ library internal Cardano.Api.Eras.Core Cardano.Api.Error Cardano.Api.Feature - Cardano.Api.Feature.AlonzoEraOnly - Cardano.Api.Feature.AlonzoEraOnwards - Cardano.Api.Feature.BabbageEraOnwards - Cardano.Api.Feature.ConwayEraOnwards - Cardano.Api.Feature.ShelleyToAllegraEra - Cardano.Api.Feature.ShelleyToAlonzoEra - Cardano.Api.Feature.ShelleyToBabbageEra - Cardano.Api.Feature.ShelleyToMaryEra Cardano.Api.Fees Cardano.Api.Genesis Cardano.Api.GenesisParameters diff --git a/cardano-api/internal/Cardano/Api/Certificate.hs b/cardano-api/internal/Cardano/Api/Certificate.hs index 6c685975db..14516b35c3 100644 --- a/cardano-api/internal/Cardano/Api/Certificate.hs +++ b/cardano-api/internal/Cardano/Api/Certificate.hs @@ -74,10 +74,10 @@ module Cardano.Api.Certificate ( import Cardano.Api.Address import Cardano.Api.DRepMetadata +import Cardano.Api.Eon.ConwayEraOnwards +import Cardano.Api.Eon.ShelleyToBabbageEra import Cardano.Api.EraCast import Cardano.Api.Eras -import Cardano.Api.Feature.ConwayEraOnwards -import Cardano.Api.Feature.ShelleyToBabbageEra import Cardano.Api.Governance.Actions.VotingProcedure import Cardano.Api.HasTypeProxy import Cardano.Api.Keys.Praos diff --git a/cardano-api/internal/Cardano/Api/Convenience/Query.hs b/cardano-api/internal/Cardano/Api/Convenience/Query.hs index 8e5bf777a6..f81d613e69 100644 --- a/cardano-api/internal/Cardano/Api/Convenience/Query.hs +++ b/cardano-api/internal/Cardano/Api/Convenience/Query.hs @@ -19,8 +19,8 @@ module Cardano.Api.Convenience.Query ( import Cardano.Api.Address import Cardano.Api.Certificate import Cardano.Api.Convenience.Constraints +import Cardano.Api.Eon.ConwayEraOnwards (ConwayEraOnwards) import Cardano.Api.Eras -import Cardano.Api.Feature.ConwayEraOnwards (ConwayEraOnwards) import Cardano.Api.IO import Cardano.Api.IPC import Cardano.Api.IPC.Monad diff --git a/cardano-api/internal/Cardano/Api/Feature/AlonzoEraOnly.hs b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs similarity index 98% rename from cardano-api/internal/Cardano/Api/Feature/AlonzoEraOnly.hs rename to cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs index 2133bb9d75..b17447ee50 100644 --- a/cardano-api/internal/Cardano/Api/Feature/AlonzoEraOnly.hs +++ b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs @@ -8,7 +8,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -module Cardano.Api.Feature.AlonzoEraOnly +module Cardano.Api.Eon.AlonzoEraOnly ( AlonzoEraOnly(..) , IsAlonzoEraOnly(..) , AnyAlonzoEraOnly(..) diff --git a/cardano-api/internal/Cardano/Api/Feature/AlonzoEraOnwards.hs b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs similarity index 99% rename from cardano-api/internal/Cardano/Api/Feature/AlonzoEraOnwards.hs rename to cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs index 144aa6e489..8d8af3da92 100644 --- a/cardano-api/internal/Cardano/Api/Feature/AlonzoEraOnwards.hs +++ b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs @@ -8,7 +8,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -module Cardano.Api.Feature.AlonzoEraOnwards +module Cardano.Api.Eon.AlonzoEraOnwards ( AlonzoEraOnwards(..) , IsAlonzoEraOnwards(..) , AnyAlonzoEraOnwards(..) diff --git a/cardano-api/internal/Cardano/Api/Feature/BabbageEraOnwards.hs b/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs similarity index 98% rename from cardano-api/internal/Cardano/Api/Feature/BabbageEraOnwards.hs rename to cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs index 9070a95f2f..577128430f 100644 --- a/cardano-api/internal/Cardano/Api/Feature/BabbageEraOnwards.hs +++ b/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs @@ -8,7 +8,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -module Cardano.Api.Feature.BabbageEraOnwards +module Cardano.Api.Eon.BabbageEraOnwards ( BabbageEraOnwards(..) , IsBabbageEraOnwards(..) , AnyBabbageEraOnwards(..) diff --git a/cardano-api/internal/Cardano/Api/Feature/ConwayEraOnwards.hs b/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs similarity index 98% rename from cardano-api/internal/Cardano/Api/Feature/ConwayEraOnwards.hs rename to cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs index 4931988df7..db0fc9f619 100644 --- a/cardano-api/internal/Cardano/Api/Feature/ConwayEraOnwards.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs @@ -8,7 +8,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -module Cardano.Api.Feature.ConwayEraOnwards +module Cardano.Api.Eon.ConwayEraOnwards ( ConwayEraOnwards(..) , IsConwayEraOnwards(..) , AnyConwayEraOnwards(..) diff --git a/cardano-api/internal/Cardano/Api/Feature/ShelleyToAllegraEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs similarity index 98% rename from cardano-api/internal/Cardano/Api/Feature/ShelleyToAllegraEra.hs rename to cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs index b6834dcbaa..6fb802fcd2 100644 --- a/cardano-api/internal/Cardano/Api/Feature/ShelleyToAllegraEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs @@ -8,7 +8,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -module Cardano.Api.Feature.ShelleyToAllegraEra +module Cardano.Api.Eon.ShelleyToAllegraEra ( ShelleyToAllegraEra(..) , IsShelleyToAllegraEra(..) , AnyShelleyToAllegraEra(..) diff --git a/cardano-api/internal/Cardano/Api/Feature/ShelleyToAlonzoEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs similarity index 99% rename from cardano-api/internal/Cardano/Api/Feature/ShelleyToAlonzoEra.hs rename to cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs index 4a50997c04..f60546cf24 100644 --- a/cardano-api/internal/Cardano/Api/Feature/ShelleyToAlonzoEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs @@ -8,7 +8,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -module Cardano.Api.Feature.ShelleyToAlonzoEra +module Cardano.Api.Eon.ShelleyToAlonzoEra ( ShelleyToAlonzoEra(..) , IsShelleyToAlonzoEra(..) , AnyShelleyToAlonzoEra(..) diff --git a/cardano-api/internal/Cardano/Api/Feature/ShelleyToBabbageEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs similarity index 99% rename from cardano-api/internal/Cardano/Api/Feature/ShelleyToBabbageEra.hs rename to cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs index 1211554b33..3800173a83 100644 --- a/cardano-api/internal/Cardano/Api/Feature/ShelleyToBabbageEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs @@ -8,7 +8,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -module Cardano.Api.Feature.ShelleyToBabbageEra +module Cardano.Api.Eon.ShelleyToBabbageEra ( ShelleyToBabbageEra(..) , IsShelleyToBabbageEra(..) , AnyShelleyToBabbageEra(..) diff --git a/cardano-api/internal/Cardano/Api/Feature/ShelleyToMaryEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs similarity index 99% rename from cardano-api/internal/Cardano/Api/Feature/ShelleyToMaryEra.hs rename to cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs index 274be16475..2ec2cf7fe2 100644 --- a/cardano-api/internal/Cardano/Api/Feature/ShelleyToMaryEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs @@ -8,7 +8,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -module Cardano.Api.Feature.ShelleyToMaryEra +module Cardano.Api.Eon.ShelleyToMaryEra ( ShelleyToMaryEra(..) , IsShelleyToMaryEra(..) , AnyShelleyToMaryEra(..) diff --git a/cardano-api/internal/Cardano/Api/Eras/Case.hs b/cardano-api/internal/Cardano/Api/Eras/Case.hs index 23edd60665..d5a41b6e54 100644 --- a/cardano-api/internal/Cardano/Api/Eras/Case.hs +++ b/cardano-api/internal/Cardano/Api/Eras/Case.hs @@ -13,14 +13,14 @@ module Cardano.Api.Eras.Case , caseShelleyToBabbageOrConwayEraOnwards ) where +import Cardano.Api.Eon.AlonzoEraOnwards +import Cardano.Api.Eon.BabbageEraOnwards +import Cardano.Api.Eon.ConwayEraOnwards +import Cardano.Api.Eon.ShelleyToAlonzoEra +import Cardano.Api.Eon.ShelleyToBabbageEra +import Cardano.Api.Eon.ShelleyToMaryEra import Cardano.Api.Eras.Constraints import Cardano.Api.Eras.Core -import Cardano.Api.Feature.AlonzoEraOnwards -import Cardano.Api.Feature.BabbageEraOnwards -import Cardano.Api.Feature.ConwayEraOnwards -import Cardano.Api.Feature.ShelleyToAlonzoEra -import Cardano.Api.Feature.ShelleyToBabbageEra -import Cardano.Api.Feature.ShelleyToMaryEra caseByronOrShelleyBasedEra :: () => (CardanoEra ByronEra -> a) diff --git a/cardano-api/internal/Cardano/Api/TxBody.hs b/cardano-api/internal/Cardano/Api/TxBody.hs index dfd5499ab5..80e42142f0 100644 --- a/cardano-api/internal/Cardano/Api/TxBody.hs +++ b/cardano-api/internal/Cardano/Api/TxBody.hs @@ -186,11 +186,11 @@ module Cardano.Api.TxBody ( import Cardano.Api.Address import Cardano.Api.Certificate import Cardano.Api.Convenience.Constraints +import Cardano.Api.Eon.ConwayEraOnwards import Cardano.Api.EraCast import Cardano.Api.Eras import Cardano.Api.Error import Cardano.Api.Feature -import Cardano.Api.Feature.ConwayEraOnwards import Cardano.Api.Governance.Actions.ProposalProcedure import Cardano.Api.Governance.Actions.VotingProcedure import Cardano.Api.Hash diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index a0c14e7618..2e2913e9ca 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -1008,18 +1008,18 @@ import Cardano.Api.Convenience.Construction import Cardano.Api.Convenience.Query import Cardano.Api.DeserialiseAnyOf import Cardano.Api.DRepMetadata +import Cardano.Api.Eon.AlonzoEraOnly +import Cardano.Api.Eon.AlonzoEraOnwards +import Cardano.Api.Eon.BabbageEraOnwards +import Cardano.Api.Eon.ConwayEraOnwards +import Cardano.Api.Eon.ShelleyToAllegraEra +import Cardano.Api.Eon.ShelleyToAlonzoEra +import Cardano.Api.Eon.ShelleyToBabbageEra +import Cardano.Api.Eon.ShelleyToMaryEra import Cardano.Api.EraCast import Cardano.Api.Eras import Cardano.Api.Error import Cardano.Api.Feature -import Cardano.Api.Feature.AlonzoEraOnly -import Cardano.Api.Feature.AlonzoEraOnwards -import Cardano.Api.Feature.BabbageEraOnwards -import Cardano.Api.Feature.ConwayEraOnwards -import Cardano.Api.Feature.ShelleyToAllegraEra -import Cardano.Api.Feature.ShelleyToAlonzoEra -import Cardano.Api.Feature.ShelleyToBabbageEra -import Cardano.Api.Feature.ShelleyToMaryEra import Cardano.Api.Fees import Cardano.Api.Genesis import Cardano.Api.GenesisParameters From 42949681f1126f44f8dd125d7ed351e9c2107415 Mon Sep 17 00:00:00 2001 From: John Ky Date: Sat, 16 Sep 2023 08:32:48 +1000 Subject: [PATCH 3/7] Rename FeatureInEra to Eon --- cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs | 10 +-- .../internal/Cardano/Api/Eon/AlonzoEraOnly.hs | 2 +- .../Cardano/Api/Eon/AlonzoEraOnwards.hs | 2 +- .../Cardano/Api/Eon/BabbageEraOnwards.hs | 2 +- .../Cardano/Api/Eon/ConwayEraOnwards.hs | 2 +- .../Cardano/Api/Eon/ShelleyToAllegraEra.hs | 2 +- .../Cardano/Api/Eon/ShelleyToAlonzoEra.hs | 2 +- .../Cardano/Api/Eon/ShelleyToBabbageEra.hs | 2 +- .../Cardano/Api/Eon/ShelleyToMaryEra.hs | 2 +- cardano-api/internal/Cardano/Api/Eras.hs | 4 +- cardano-api/internal/Cardano/Api/Eras/Core.hs | 71 ++++++++++--------- cardano-api/internal/Cardano/Api/Feature.hs | 8 +-- .../Cardano/Api/ProtocolParameters.hs | 4 +- cardano-api/src/Cardano/Api.hs | 2 +- 14 files changed, 58 insertions(+), 57 deletions(-) diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index 050f4db2d6..46486ab896 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -735,19 +735,19 @@ genTxBody era = do -- | Generate a 'Featured' for the given 'CardanoEra' with the provided generator. genFeaturedInEra :: () => Alternative f - => feature era + => eon era -> f a - -> f (Featured feature era a) + -> f (Featured eon era a) genFeaturedInEra witness gen = Featured witness <$> gen -- | Generate a 'Featured' for the given 'CardanoEra' with the provided generator. genMaybeFeaturedInEra :: () - => FeatureInEra feature + => Eon eon => Alternative f - => (feature era -> f a) + => (eon era -> f a) -> CardanoEra era - -> f (Maybe (Featured feature era a)) + -> f (Maybe (Featured eon era a)) genMaybeFeaturedInEra f = featureInEra (pure Nothing) $ \w -> pure Nothing <|> fmap Just (genFeaturedInEra w (f w)) diff --git a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs index b17447ee50..5d95a31cb4 100644 --- a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs +++ b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs @@ -50,7 +50,7 @@ deriving instance Eq (AlonzoEraOnly era) instance IsAlonzoEraOnly AlonzoEra where alonzoEraOnly = AlonzoEraOnlyAlonzo -instance FeatureInEra AlonzoEraOnly where +instance Eon AlonzoEraOnly where featureInEra no yes = \case ByronEra -> no ShelleyEra -> no diff --git a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs index 8d8af3da92..cb0f11c890 100644 --- a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs +++ b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs @@ -58,7 +58,7 @@ instance IsAlonzoEraOnwards BabbageEra where instance IsAlonzoEraOnwards ConwayEra where alonzoEraOnwards = AlonzoEraOnwardsConway -instance FeatureInEra AlonzoEraOnwards where +instance Eon AlonzoEraOnwards where featureInEra no yes = \case ByronEra -> no ShelleyEra -> no diff --git a/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs b/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs index 577128430f..fdd4f6e752 100644 --- a/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs +++ b/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs @@ -54,7 +54,7 @@ instance IsBabbageEraOnwards BabbageEra where instance IsBabbageEraOnwards ConwayEra where babbageEraOnwards = BabbageEraOnwardsConway -instance FeatureInEra BabbageEraOnwards where +instance Eon BabbageEraOnwards where featureInEra no yes = \case ByronEra -> no ShelleyEra -> no diff --git a/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs b/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs index db0fc9f619..0a3ee8c3f2 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs @@ -52,7 +52,7 @@ deriving instance Eq (ConwayEraOnwards era) instance IsConwayEraOnwards ConwayEra where conwayEraOnwards = ConwayEraOnwardsConway -instance FeatureInEra ConwayEraOnwards where +instance Eon ConwayEraOnwards where featureInEra no yes = \case ByronEra -> no ShelleyEra -> no diff --git a/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs index 6fb802fcd2..fda8b02c6f 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs @@ -55,7 +55,7 @@ instance IsShelleyToAllegraEra ShelleyEra where instance IsShelleyToAllegraEra AllegraEra where shelleyToAllegraEra = ShelleyToAllegraEraAllegra -instance FeatureInEra ShelleyToAllegraEra where +instance Eon ShelleyToAllegraEra where featureInEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyToAllegraEraShelley diff --git a/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs index f60546cf24..3a77d27723 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs @@ -63,7 +63,7 @@ instance IsShelleyToAlonzoEra MaryEra where instance IsShelleyToAlonzoEra AlonzoEra where shelleyToAlonzoEra = ShelleyToAlonzoEraAlonzo -instance FeatureInEra ShelleyToAlonzoEra where +instance Eon ShelleyToAlonzoEra where featureInEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyToAlonzoEraShelley diff --git a/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs index 3800173a83..ed3ed2884d 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs @@ -67,7 +67,7 @@ instance IsShelleyToBabbageEra AlonzoEra where instance IsShelleyToBabbageEra BabbageEra where shelleyToBabbageEra = ShelleyToBabbageEraBabbage -instance FeatureInEra ShelleyToBabbageEra where +instance Eon ShelleyToBabbageEra where featureInEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyToBabbageEraShelley diff --git a/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs index 2ec2cf7fe2..ce4f78b397 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs @@ -59,7 +59,7 @@ instance IsShelleyToMaryEra AllegraEra where instance IsShelleyToMaryEra MaryEra where shelleyToMaryEra = ShelleyToMaryEraMary -instance FeatureInEra ShelleyToMaryEra where +instance Eon ShelleyToMaryEra where featureInEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyToMaryEraShelley diff --git a/cardano-api/internal/Cardano/Api/Eras.hs b/cardano-api/internal/Cardano/Api/Eras.hs index 4f3b538df0..87110ec11c 100644 --- a/cardano-api/internal/Cardano/Api/Eras.hs +++ b/cardano-api/internal/Cardano/Api/Eras.hs @@ -20,8 +20,8 @@ module Cardano.Api.Eras , CardanoLedgerEra , ToCardanoEra(..) - -- * FeatureInEra - , FeatureInEra(..) + -- * IsEon + , Eon(..) , inEraFeature , inEraFeatureMaybe , maybeFeatureInEra diff --git a/cardano-api/internal/Cardano/Api/Eras/Core.hs b/cardano-api/internal/Cardano/Api/Eras/Core.hs index 3bcc5322b9..5fcdf20d22 100644 --- a/cardano-api/internal/Cardano/Api/Eras/Core.hs +++ b/cardano-api/internal/Cardano/Api/Eras/Core.hs @@ -30,8 +30,8 @@ module Cardano.Api.Eras.Core , CardanoLedgerEra , ToCardanoEra(..) - -- * FeatureInEra - , FeatureInEra(..) + -- * IsEon + , Eon(..) , inEraFeature , inEraFeatureMaybe , maybeFeatureInEra @@ -129,74 +129,75 @@ instance HasTypeProxy ConwayEra where proxyToAsType _ = AsConwayEra -- ---------------------------------------------------------------------------- --- FeatureInEra +-- Eon --- | A class for producing values for features that are supported in some eras --- but not others. -class FeatureInEra (feature :: Type -> Type) where - -- | Determine the value to use for a feature in a given 'CardanoEra'. +-- | An Eon is a span of multiple eras. Eons are used to scope functionality to +-- particular eras such that it isn't possible construct code that uses functionality +-- that is outside of given eras. +class Eon (eon :: Type -> Type) where + -- | Determine the value to use in an eon (a span of multiple eras). -- Note that the negative case is the first argument, and the positive case is the second as per -- the 'either' function convention. featureInEra :: () - => a -- ^ Value to use if the feature is not supported in the era - -> (feature era -> a) -- ^ Function to get the value to use if the feature is supported in the era - -> CardanoEra era -- ^ Era to check - -> a -- ^ The value to use + => a -- ^ Value to use if the feature is not supported in the era + -> (eon era -> a) -- ^ Function to get the value to use if the feature is supported in the era + -> CardanoEra era -- ^ Era to check + -> a -- ^ The value to use inEraFeature :: () - => FeatureInEra feature - => CardanoEra era -- ^ Era to check - -> a -- ^ Value to use if the feature is not supported in the era - -> (feature era -> a) -- ^ Function to get the value to use if the feature is supported in the era - -> a -- ^ The value to use + => Eon eon + => CardanoEra era -- ^ Era to check + -> a -- ^ Value to use if the feature is not supported in the era + -> (eon era -> a) -- ^ Function to get the value to use if the feature is supported in the era + -> a -- ^ The value to use inEraFeature era no yes = featureInEra no yes era inEraFeatureMaybe :: () - => FeatureInEra feature - => CardanoEra era -- ^ Era to check - -> (feature era -> a) -- ^ Function to get the value to use if the feature is supported in the era - -> Maybe a -- ^ The value to use + => Eon eon + => CardanoEra era -- ^ Era to check + -> (eon era -> a) -- ^ Function to get the value to use if the feature is supported in the era + -> Maybe a -- ^ The value to use inEraFeatureMaybe era yes = inEraFeature era Nothing (Just . yes) maybeFeatureInEra :: () - => FeatureInEra feature - => CardanoEra era -- ^ Era to check - -> Maybe (feature era) -- ^ The feature if supported in the era + => Eon eon + => CardanoEra era -- ^ Era to check + -> Maybe (eon era) -- ^ The feature if supported in the era maybeFeatureInEra = featureInEra Nothing Just -- | Determine the value to use for a feature in a given 'ShelleyBasedEra'. featureInShelleyBasedEra :: () - => FeatureInEra feature + => Eon eon => a - -> (feature era -> a) + -> (eon era -> a) -> ShelleyBasedEra era -> a featureInShelleyBasedEra no yes = featureInEra no yes . shelleyBasedToCardanoEra maybeFeatureInShelleyBasedEra :: () - => FeatureInEra feature + => Eon eon => ShelleyBasedEra era - -> Maybe (feature era) + -> Maybe (eon era) maybeFeatureInShelleyBasedEra = featureInEra Nothing Just . shelleyBasedToCardanoEra inShelleyBasedEraFeature :: () - => FeatureInEra feature + => Eon eon => ShelleyBasedEra era -> a - -> (feature era -> a) + -> (eon era -> a) -> a inShelleyBasedEraFeature era no yes = featureInShelleyBasedEra no yes era inShelleyBasedEraFeatureMaybe :: () - => FeatureInEra feature + => Eon eon => ShelleyBasedEra era - -> (feature era -> a) + -> (eon era -> a) -> Maybe a inShelleyBasedEraFeatureMaybe era yes = inShelleyBasedEraFeature era Nothing (Just . yes) @@ -204,9 +205,9 @@ inShelleyBasedEraFeatureMaybe era yes = -- ---------------------------------------------------------------------------- -- ToCardanoEra -class ToCardanoEra (feature :: Type -> Type) where +class ToCardanoEra (eon :: Type -> Type) where toCardanoEra :: () - => feature era + => eon era -> CardanoEra era -- ---------------------------------------------------------------------------- @@ -256,7 +257,7 @@ instance TestEquality CardanoEra where testEquality ConwayEra ConwayEra = Just Refl testEquality _ _ = Nothing -instance FeatureInEra CardanoEra where +instance Eon CardanoEra where featureInEra _ yes = yes instance ToCardanoEra CardanoEra where @@ -417,7 +418,7 @@ instance TestEquality ShelleyBasedEra where testEquality ShelleyBasedEraConway ShelleyBasedEraConway = Just Refl testEquality _ _ = Nothing -instance FeatureInEra ShelleyBasedEra where +instance Eon ShelleyBasedEra where featureInEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyBasedEraShelley diff --git a/cardano-api/internal/Cardano/Api/Feature.hs b/cardano-api/internal/Cardano/Api/Feature.hs index ee7e82aba9..095af7da05 100644 --- a/cardano-api/internal/Cardano/Api/Feature.hs +++ b/cardano-api/internal/Cardano/Api/Feature.hs @@ -35,16 +35,16 @@ unFeatured (Featured _ a) = a -- | Attempt to construct a 'FeatureValue' from a value and era. -- If the feature is not supported in the era, then 'NoFeatureValue' is returned. asFeaturedInEra :: () - => FeatureInEra feature + => Eon eon => a -> CardanoEra era - -> Maybe (Featured feature era a) + -> Maybe (Featured eon era a) asFeaturedInEra value = featureInEra Nothing (Just . flip Featured value) -- | Attempt to construct a 'FeatureValue' from a value and a shelley-based-era. asFeaturedInShelleyBasedEra :: () - => FeatureInEra feature + => Eon eon => a -> ShelleyBasedEra era - -> Maybe (Featured feature era a) + -> Maybe (Featured eon era a) asFeaturedInShelleyBasedEra value = asFeaturedInEra value . shelleyBasedToCardanoEra diff --git a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs index d71eed9a8a..000787d0b6 100644 --- a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs @@ -1003,7 +1003,7 @@ data ProtocolUTxOCostPerByteFeature era where deriving instance Eq (ProtocolUTxOCostPerByteFeature era) deriving instance Show (ProtocolUTxOCostPerByteFeature era) -instance FeatureInEra ProtocolUTxOCostPerByteFeature where +instance Eon ProtocolUTxOCostPerByteFeature where featureInEra no yes = \case ByronEra -> no ShelleyEra -> no @@ -1029,7 +1029,7 @@ data ProtocolUTxOCostPerWordFeature era where deriving instance Eq (ProtocolUTxOCostPerWordFeature era) deriving instance Show (ProtocolUTxOCostPerWordFeature era) -instance FeatureInEra ProtocolUTxOCostPerWordFeature where +instance Eon ProtocolUTxOCostPerWordFeature where featureInEra no yes = \case ByronEra -> no ShelleyEra -> no diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 2e2913e9ca..17a91e0311 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -28,7 +28,7 @@ module Cardano.Api ( ToCardanoEra(..), -- * Feature support - FeatureInEra(..), + Eon(..), inEraFeature, inEraFeatureMaybe, maybeFeatureInEra, From 08f0e3a24fd6fadfef18fa838c557af110da7749 Mon Sep 17 00:00:00 2001 From: John Ky Date: Sat, 16 Sep 2023 08:37:09 +1000 Subject: [PATCH 4/7] Rename featureInEra to inEonForEra --- cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs | 10 ++++---- .../internal/Cardano/Api/Eon/AlonzoEraOnly.hs | 2 +- .../Cardano/Api/Eon/AlonzoEraOnwards.hs | 2 +- .../Cardano/Api/Eon/BabbageEraOnwards.hs | 2 +- .../Cardano/Api/Eon/ConwayEraOnwards.hs | 2 +- .../Cardano/Api/Eon/ShelleyToAllegraEra.hs | 2 +- .../Cardano/Api/Eon/ShelleyToAlonzoEra.hs | 2 +- .../Cardano/Api/Eon/ShelleyToBabbageEra.hs | 2 +- .../Cardano/Api/Eon/ShelleyToMaryEra.hs | 2 +- cardano-api/internal/Cardano/Api/Eras/Core.hs | 25 +++++++++---------- cardano-api/internal/Cardano/Api/Feature.hs | 24 +++++++++--------- .../Cardano/Api/ProtocolParameters.hs | 4 +-- 12 files changed, 39 insertions(+), 40 deletions(-) diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index 46486ab896..957fdc58ca 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -749,7 +749,7 @@ genMaybeFeaturedInEra :: () -> CardanoEra era -> f (Maybe (Featured eon era a)) genMaybeFeaturedInEra f = - featureInEra (pure Nothing) $ \w -> + inEonForEra (pure Nothing) $ \w -> pure Nothing <|> fmap Just (genFeaturedInEra w (f w)) genTxScriptValidity :: CardanoEra era -> Gen (TxScriptValidity era) @@ -915,7 +915,7 @@ genProtocolParameters era = do protocolParamPoolPledgeInfluence <- genRationalInt64 protocolParamMonetaryExpansion <- genRational protocolParamTreasuryCut <- genRational - protocolParamUTxOCostPerWord <- featureInEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era + protocolParamUTxOCostPerWord <- inEonForEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era protocolParamCostModels <- pure mempty --TODO: Babbage figure out how to deal with -- asymmetric cost model JSON instances @@ -925,7 +925,7 @@ genProtocolParameters era = do protocolParamMaxValueSize <- Gen.maybe genNat protocolParamCollateralPercent <- Gen.maybe genNat protocolParamMaxCollateralInputs <- Gen.maybe genNat - protocolParamUTxOCostPerByte <- featureInEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era + protocolParamUTxOCostPerByte <- inEonForEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era pure ProtocolParameters {..} @@ -952,7 +952,7 @@ genProtocolParametersUpdate era = do protocolUpdatePoolPledgeInfluence <- Gen.maybe genRationalInt64 protocolUpdateMonetaryExpansion <- Gen.maybe genRational protocolUpdateTreasuryCut <- Gen.maybe genRational - protocolUpdateUTxOCostPerWord <- featureInEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era + protocolUpdateUTxOCostPerWord <- inEonForEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era let protocolUpdateCostModels = mempty -- genCostModels --TODO: Babbage figure out how to deal with -- asymmetric cost model JSON instances @@ -962,7 +962,7 @@ genProtocolParametersUpdate era = do protocolUpdateMaxValueSize <- Gen.maybe genNat protocolUpdateCollateralPercent <- Gen.maybe genNat protocolUpdateMaxCollateralInputs <- Gen.maybe genNat - protocolUpdateUTxOCostPerByte <- featureInEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era + protocolUpdateUTxOCostPerByte <- inEonForEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era pure ProtocolParametersUpdate{..} diff --git a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs index 5d95a31cb4..4eb067d99f 100644 --- a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs +++ b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs @@ -51,7 +51,7 @@ instance IsAlonzoEraOnly AlonzoEra where alonzoEraOnly = AlonzoEraOnlyAlonzo instance Eon AlonzoEraOnly where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> no AllegraEra -> no diff --git a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs index cb0f11c890..b598bb4fb4 100644 --- a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs +++ b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs @@ -59,7 +59,7 @@ instance IsAlonzoEraOnwards ConwayEra where alonzoEraOnwards = AlonzoEraOnwardsConway instance Eon AlonzoEraOnwards where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> no AllegraEra -> no diff --git a/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs b/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs index fdd4f6e752..a8006dc260 100644 --- a/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs +++ b/cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs @@ -55,7 +55,7 @@ instance IsBabbageEraOnwards ConwayEra where babbageEraOnwards = BabbageEraOnwardsConway instance Eon BabbageEraOnwards where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> no AllegraEra -> no diff --git a/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs b/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs index 0a3ee8c3f2..acb53541a8 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs @@ -53,7 +53,7 @@ instance IsConwayEraOnwards ConwayEra where conwayEraOnwards = ConwayEraOnwardsConway instance Eon ConwayEraOnwards where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> no AllegraEra -> no diff --git a/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs index fda8b02c6f..0317de3192 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAllegraEra.hs @@ -56,7 +56,7 @@ instance IsShelleyToAllegraEra AllegraEra where shelleyToAllegraEra = ShelleyToAllegraEraAllegra instance Eon ShelleyToAllegraEra where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyToAllegraEraShelley AllegraEra -> yes ShelleyToAllegraEraAllegra diff --git a/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs index 3a77d27723..79b090a0f9 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToAlonzoEra.hs @@ -64,7 +64,7 @@ instance IsShelleyToAlonzoEra AlonzoEra where shelleyToAlonzoEra = ShelleyToAlonzoEraAlonzo instance Eon ShelleyToAlonzoEra where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyToAlonzoEraShelley AllegraEra -> yes ShelleyToAlonzoEraAllegra diff --git a/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs index ed3ed2884d..654f3249d8 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToBabbageEra.hs @@ -68,7 +68,7 @@ instance IsShelleyToBabbageEra BabbageEra where shelleyToBabbageEra = ShelleyToBabbageEraBabbage instance Eon ShelleyToBabbageEra where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyToBabbageEraShelley AllegraEra -> yes ShelleyToBabbageEraAllegra diff --git a/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs index ce4f78b397..8ea842d488 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyToMaryEra.hs @@ -60,7 +60,7 @@ instance IsShelleyToMaryEra MaryEra where shelleyToMaryEra = ShelleyToMaryEraMary instance Eon ShelleyToMaryEra where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyToMaryEraShelley AllegraEra -> yes ShelleyToMaryEraAllegra diff --git a/cardano-api/internal/Cardano/Api/Eras/Core.hs b/cardano-api/internal/Cardano/Api/Eras/Core.hs index 5fcdf20d22..6202262c4c 100644 --- a/cardano-api/internal/Cardano/Api/Eras/Core.hs +++ b/cardano-api/internal/Cardano/Api/Eras/Core.hs @@ -2,7 +2,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} @@ -138,25 +137,25 @@ class Eon (eon :: Type -> Type) where -- | Determine the value to use in an eon (a span of multiple eras). -- Note that the negative case is the first argument, and the positive case is the second as per -- the 'either' function convention. - featureInEra :: () - => a -- ^ Value to use if the feature is not supported in the era - -> (eon era -> a) -- ^ Function to get the value to use if the feature is supported in the era + inEonForEra :: () + => a -- ^ Value to use if the eon does not include the era + -> (eon era -> a) -- ^ Function to get the value to use if the eon includes the era -> CardanoEra era -- ^ Era to check -> a -- ^ The value to use inEraFeature :: () => Eon eon => CardanoEra era -- ^ Era to check - -> a -- ^ Value to use if the feature is not supported in the era - -> (eon era -> a) -- ^ Function to get the value to use if the feature is supported in the era + -> a -- ^ Value to use if the eon does not include the era + -> (eon era -> a) -- ^ Function to get the value to use if the eon includes the era -> a -- ^ The value to use inEraFeature era no yes = - featureInEra no yes era + inEonForEra no yes era inEraFeatureMaybe :: () => Eon eon => CardanoEra era -- ^ Era to check - -> (eon era -> a) -- ^ Function to get the value to use if the feature is supported in the era + -> (eon era -> a) -- ^ Function to get the value to use if the eon includes the era -> Maybe a -- ^ The value to use inEraFeatureMaybe era yes = inEraFeature era Nothing (Just . yes) @@ -166,7 +165,7 @@ maybeFeatureInEra :: () => CardanoEra era -- ^ Era to check -> Maybe (eon era) -- ^ The feature if supported in the era maybeFeatureInEra = - featureInEra Nothing Just + inEonForEra Nothing Just -- | Determine the value to use for a feature in a given 'ShelleyBasedEra'. featureInShelleyBasedEra :: () @@ -176,14 +175,14 @@ featureInShelleyBasedEra :: () -> ShelleyBasedEra era -> a featureInShelleyBasedEra no yes = - featureInEra no yes . shelleyBasedToCardanoEra + inEonForEra no yes . shelleyBasedToCardanoEra maybeFeatureInShelleyBasedEra :: () => Eon eon => ShelleyBasedEra era -> Maybe (eon era) maybeFeatureInShelleyBasedEra = - featureInEra Nothing Just . shelleyBasedToCardanoEra + inEonForEra Nothing Just . shelleyBasedToCardanoEra inShelleyBasedEraFeature :: () => Eon eon @@ -258,7 +257,7 @@ instance TestEquality CardanoEra where testEquality _ _ = Nothing instance Eon CardanoEra where - featureInEra _ yes = yes + inEonForEra _ yes = yes instance ToCardanoEra CardanoEra where toCardanoEra = id @@ -419,7 +418,7 @@ instance TestEquality ShelleyBasedEra where testEquality _ _ = Nothing instance Eon ShelleyBasedEra where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> yes ShelleyBasedEraShelley AllegraEra -> yes ShelleyBasedEraAllegra diff --git a/cardano-api/internal/Cardano/Api/Feature.hs b/cardano-api/internal/Cardano/Api/Feature.hs index 095af7da05..538466d8ee 100644 --- a/cardano-api/internal/Cardano/Api/Feature.hs +++ b/cardano-api/internal/Cardano/Api/Feature.hs @@ -14,32 +14,32 @@ module Cardano.Api.Feature import Cardano.Api.Eras.Core --- | A value only if the feature is supported in this era -data Featured feature era a where +-- | A value only if the eon includes era +data Featured eon era a where Featured - :: feature era - -- ^ The witness that the feature is supported in this era + :: eon era + -- ^ The witness that the eon includes era -> a -- ^ The value to use - -> Featured feature era a + -> Featured eon era a -deriving instance (Eq a, Eq (feature era)) => Eq (Featured feature era a) -deriving instance (Show a, Show (feature era)) => Show (Featured feature era a) +deriving instance (Eq a, Eq (eon era)) => Eq (Featured eon era a) +deriving instance (Show a, Show (eon era)) => Show (Featured eon era a) -instance Functor (Featured feature era) where - fmap f (Featured feature a) = Featured feature (f a) +instance Functor (Featured eon era) where + fmap f (Featured eon a) = Featured eon (f a) -unFeatured :: Featured feature era a -> a +unFeatured :: Featured eon era a -> a unFeatured (Featured _ a) = a -- | Attempt to construct a 'FeatureValue' from a value and era. --- If the feature is not supported in the era, then 'NoFeatureValue' is returned. +-- If the eon is not supported in the era, then 'NoFeatureValue' is returned. asFeaturedInEra :: () => Eon eon => a -> CardanoEra era -> Maybe (Featured eon era a) -asFeaturedInEra value = featureInEra Nothing (Just . flip Featured value) +asFeaturedInEra value = inEonForEra Nothing (Just . flip Featured value) -- | Attempt to construct a 'FeatureValue' from a value and a shelley-based-era. asFeaturedInShelleyBasedEra :: () diff --git a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs index 000787d0b6..dcd896040b 100644 --- a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs @@ -1004,7 +1004,7 @@ deriving instance Eq (ProtocolUTxOCostPerByteFeature era) deriving instance Show (ProtocolUTxOCostPerByteFeature era) instance Eon ProtocolUTxOCostPerByteFeature where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> no AllegraEra -> no @@ -1030,7 +1030,7 @@ deriving instance Eq (ProtocolUTxOCostPerWordFeature era) deriving instance Show (ProtocolUTxOCostPerWordFeature era) instance Eon ProtocolUTxOCostPerWordFeature where - featureInEra no yes = \case + inEonForEra no yes = \case ByronEra -> no ShelleyEra -> no AllegraEra -> no From ff7e3a7daee33d77187aad8804d366a27c775a5e Mon Sep 17 00:00:00 2001 From: John Ky Date: Tue, 19 Sep 2023 09:40:00 +1000 Subject: [PATCH 5/7] Rename inEraFeature to forEraInEon --- cardano-api/internal/Cardano/Api/Certificate.hs | 8 ++++---- cardano-api/internal/Cardano/Api/Convenience/Query.hs | 2 +- cardano-api/internal/Cardano/Api/Eras.hs | 2 +- cardano-api/internal/Cardano/Api/Eras/Core.hs | 8 ++++---- cardano-api/src/Cardano/Api.hs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/Certificate.hs b/cardano-api/internal/Cardano/Api/Certificate.hs index 14516b35c3..e3b146623d 100644 --- a/cardano-api/internal/Cardano/Api/Certificate.hs +++ b/cardano-api/internal/Cardano/Api/Certificate.hs @@ -270,8 +270,8 @@ instance EraCast Certificate where case cert of ShelleyRelatedCertificate sourceWit sourceLedgerCert -> shelleyToBabbageEraConstraints sourceWit - $ inEraFeature targetEra - ( inEraFeature targetEra + $ forEraInEon targetEra + ( forEraInEon targetEra ( Left $ EraCastError { originalValue = cert , fromEra = shelleyToBabbageEraToCardanoEra sourceWit @@ -299,8 +299,8 @@ instance EraCast Certificate where ConwayCertificate sourceWit sourceLedgerCert -> conwayEraOnwardsConstraints sourceWit - $ inEraFeature targetEra - ( inEraFeature targetEra + $ forEraInEon targetEra + ( forEraInEon targetEra ( Left $ EraCastError { originalValue = cert , fromEra = conwayEraOnwardsToCardanoEra sourceWit diff --git a/cardano-api/internal/Cardano/Api/Convenience/Query.hs b/cardano-api/internal/Cardano/Api/Convenience/Query.hs index f81d613e69..d2c6236c1d 100644 --- a/cardano-api/internal/Cardano/Api/Convenience/Query.hs +++ b/cardano-api/internal/Cardano/Api/Convenience/Query.hs @@ -126,7 +126,7 @@ queryStateForBalancedTx era allTxIns certs = runExceptT $ do & onLeft (left . QueryEraMismatch) drepDelegDeposits <- - inEraFeature @ConwayEraOnwards era (pure mempty) $ \_ -> + forEraInEon @ConwayEraOnwards era (pure mempty) $ \_ -> Map.map (fromShelleyLovelace . drepDeposit) <$> (lift (queryDRepState qeInMode sbe drepCreds) & onLeft (left . QceUnsupportedNtcVersion) diff --git a/cardano-api/internal/Cardano/Api/Eras.hs b/cardano-api/internal/Cardano/Api/Eras.hs index 87110ec11c..0e27fa4e76 100644 --- a/cardano-api/internal/Cardano/Api/Eras.hs +++ b/cardano-api/internal/Cardano/Api/Eras.hs @@ -22,7 +22,7 @@ module Cardano.Api.Eras -- * IsEon , Eon(..) - , inEraFeature + , forEraInEon , inEraFeatureMaybe , maybeFeatureInEra diff --git a/cardano-api/internal/Cardano/Api/Eras/Core.hs b/cardano-api/internal/Cardano/Api/Eras/Core.hs index 6202262c4c..ebdc5b9ef9 100644 --- a/cardano-api/internal/Cardano/Api/Eras/Core.hs +++ b/cardano-api/internal/Cardano/Api/Eras/Core.hs @@ -31,7 +31,7 @@ module Cardano.Api.Eras.Core -- * IsEon , Eon(..) - , inEraFeature + , forEraInEon , inEraFeatureMaybe , maybeFeatureInEra , featureInShelleyBasedEra @@ -143,13 +143,13 @@ class Eon (eon :: Type -> Type) where -> CardanoEra era -- ^ Era to check -> a -- ^ The value to use -inEraFeature :: () +forEraInEon :: () => Eon eon => CardanoEra era -- ^ Era to check -> a -- ^ Value to use if the eon does not include the era -> (eon era -> a) -- ^ Function to get the value to use if the eon includes the era -> a -- ^ The value to use -inEraFeature era no yes = +forEraInEon era no yes = inEonForEra no yes era inEraFeatureMaybe :: () @@ -158,7 +158,7 @@ inEraFeatureMaybe :: () -> (eon era -> a) -- ^ Function to get the value to use if the eon includes the era -> Maybe a -- ^ The value to use inEraFeatureMaybe era yes = - inEraFeature era Nothing (Just . yes) + forEraInEon era Nothing (Just . yes) maybeFeatureInEra :: () => Eon eon diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 17a91e0311..e3233febcb 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -29,7 +29,7 @@ module Cardano.Api ( -- * Feature support Eon(..), - inEraFeature, + forEraInEon, inEraFeatureMaybe, maybeFeatureInEra, From 9469db13cbb80aa97cfed2b2452fa125e44102c7 Mon Sep 17 00:00:00 2001 From: John Ky Date: Tue, 19 Sep 2023 09:46:03 +1000 Subject: [PATCH 6/7] Rename Feature to Eon in eon related functions --- cardano-api/internal/Cardano/Api/Eras.hs | 13 +++--- cardano-api/internal/Cardano/Api/Eras/Core.hs | 44 +++++++++---------- cardano-api/internal/Cardano/Api/TxBody.hs | 4 +- cardano-api/src/Cardano/Api.hs | 12 ++--- 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/Eras.hs b/cardano-api/internal/Cardano/Api/Eras.hs index 0e27fa4e76..f4f299cb1d 100644 --- a/cardano-api/internal/Cardano/Api/Eras.hs +++ b/cardano-api/internal/Cardano/Api/Eras.hs @@ -23,13 +23,12 @@ module Cardano.Api.Eras -- * IsEon , Eon(..) , forEraInEon - , inEraFeatureMaybe - , maybeFeatureInEra - - , featureInShelleyBasedEra - , inShelleyBasedEraFeature - , inShelleyBasedEraFeatureMaybe - , maybeFeatureInShelleyBasedEra + , inEraEonMaybe + , maybeEonInEra + , eonInShelleyBasedEra + , inShelleyBasedEraEon + , inShelleyBasedEraEonMaybe + , maybeEonInShelleyBasedEra -- * Shelley-based eras , ShelleyBasedEra(..) diff --git a/cardano-api/internal/Cardano/Api/Eras/Core.hs b/cardano-api/internal/Cardano/Api/Eras/Core.hs index ebdc5b9ef9..c04c860875 100644 --- a/cardano-api/internal/Cardano/Api/Eras/Core.hs +++ b/cardano-api/internal/Cardano/Api/Eras/Core.hs @@ -32,12 +32,12 @@ module Cardano.Api.Eras.Core -- * IsEon , Eon(..) , forEraInEon - , inEraFeatureMaybe - , maybeFeatureInEra - , featureInShelleyBasedEra - , inShelleyBasedEraFeature - , inShelleyBasedEraFeatureMaybe - , maybeFeatureInShelleyBasedEra + , inEraEonMaybe + , maybeEonInEra + , eonInShelleyBasedEra + , inShelleyBasedEraEon + , inShelleyBasedEraEonMaybe + , maybeEonInShelleyBasedEra -- * Shelley-based eras , ShelleyBasedEra(..) @@ -152,54 +152,54 @@ forEraInEon :: () forEraInEon era no yes = inEonForEra no yes era -inEraFeatureMaybe :: () +inEraEonMaybe :: () => Eon eon => CardanoEra era -- ^ Era to check -> (eon era -> a) -- ^ Function to get the value to use if the eon includes the era -> Maybe a -- ^ The value to use -inEraFeatureMaybe era yes = +inEraEonMaybe era yes = forEraInEon era Nothing (Just . yes) -maybeFeatureInEra :: () +maybeEonInEra :: () => Eon eon => CardanoEra era -- ^ Era to check - -> Maybe (eon era) -- ^ The feature if supported in the era -maybeFeatureInEra = + -> Maybe (eon era) -- ^ The eon if supported in the era +maybeEonInEra = inEonForEra Nothing Just --- | Determine the value to use for a feature in a given 'ShelleyBasedEra'. -featureInShelleyBasedEra :: () +-- | Determine the value to use for a eon in a given 'ShelleyBasedEra'. +eonInShelleyBasedEra :: () => Eon eon => a -> (eon era -> a) -> ShelleyBasedEra era -> a -featureInShelleyBasedEra no yes = +eonInShelleyBasedEra no yes = inEonForEra no yes . shelleyBasedToCardanoEra -maybeFeatureInShelleyBasedEra :: () +maybeEonInShelleyBasedEra :: () => Eon eon => ShelleyBasedEra era -> Maybe (eon era) -maybeFeatureInShelleyBasedEra = +maybeEonInShelleyBasedEra = inEonForEra Nothing Just . shelleyBasedToCardanoEra -inShelleyBasedEraFeature :: () +inShelleyBasedEraEon :: () => Eon eon => ShelleyBasedEra era -> a -> (eon era -> a) -> a -inShelleyBasedEraFeature era no yes = - featureInShelleyBasedEra no yes era +inShelleyBasedEraEon era no yes = + eonInShelleyBasedEra no yes era -inShelleyBasedEraFeatureMaybe :: () +inShelleyBasedEraEonMaybe :: () => Eon eon => ShelleyBasedEra era -> (eon era -> a) -> Maybe a -inShelleyBasedEraFeatureMaybe era yes = - inShelleyBasedEraFeature era Nothing (Just . yes) +inShelleyBasedEraEonMaybe era yes = + inShelleyBasedEraEon era Nothing (Just . yes) -- ---------------------------------------------------------------------------- -- ToCardanoEra diff --git a/cardano-api/internal/Cardano/Api/TxBody.hs b/cardano-api/internal/Cardano/Api/TxBody.hs index 80e42142f0..11f1e4d3b4 100644 --- a/cardano-api/internal/Cardano/Api/TxBody.hs +++ b/cardano-api/internal/Cardano/Api/TxBody.hs @@ -2722,7 +2722,7 @@ fromLedgerProposalProcedures -> Ledger.TxBody (ShelleyLedgerEra era) -> Maybe (Featured ConwayEraOnwards era [Proposal era]) fromLedgerProposalProcedures sbe body = - inShelleyBasedEraFeatureMaybe sbe $ \w -> + inShelleyBasedEraEonMaybe sbe $ \w -> conwayEraOnwardsConstraints w $ Featured w $ fmap Proposal @@ -2734,7 +2734,7 @@ fromLedgerVotingProcedures :: () -> Ledger.TxBody (ShelleyLedgerEra era) -> Maybe (Featured ConwayEraOnwards era (VotingProcedures era)) fromLedgerVotingProcedures sbe body = - inShelleyBasedEraFeatureMaybe sbe $ \w -> + inShelleyBasedEraEonMaybe sbe $ \w -> conwayEraOnwardsConstraints w $ Featured w $ VotingProcedures diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index e3233febcb..9f4fc965b5 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -30,13 +30,13 @@ module Cardano.Api ( -- * Feature support Eon(..), forEraInEon, - inEraFeatureMaybe, - maybeFeatureInEra, + inEraEonMaybe, + maybeEonInEra, - featureInShelleyBasedEra, - inShelleyBasedEraFeature, - inShelleyBasedEraFeatureMaybe, - maybeFeatureInShelleyBasedEra, + eonInShelleyBasedEra, + inShelleyBasedEraEon, + inShelleyBasedEraEonMaybe, + maybeEonInShelleyBasedEra, Featured(..), asFeaturedInEra, From e4e590d92cb07fc48b2b42c333aea25baed44140 Mon Sep 17 00:00:00 2001 From: John Ky Date: Thu, 21 Sep 2023 02:02:29 +1000 Subject: [PATCH 7/7] Update cabal-cache version --- .github/workflows/haskell.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index b9c67bc85d..fbd7681b81 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -20,7 +20,7 @@ jobs: env: # Modify this value to "invalidate" the cabal cache. - CABAL_CACHE_VERSION: "2023-08-22" + CABAL_CACHE_VERSION: "2023-09-21" concurrency: group: >