Skip to content

Commit

Permalink
Merge pull request #226 from input-output-hk/newhoggy/featuresInEra-i…
Browse files Browse the repository at this point in the history
…nstances

`FeatureInEra` instances for `CardanoEra` and `ShelleyBasedEra`
  • Loading branch information
carbolymer authored Sep 4, 2023
2 parents 48d95c6 + 740616e commit ae2d2da
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cardano-api/internal/Cardano/Api/Eras/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ instance TestEquality CardanoEra where
testEquality ConwayEra ConwayEra = Just Refl
testEquality _ _ = Nothing

instance FeatureInEra CardanoEra where
featureInEra _ yes = yes

-- | The class of Cardano eras. This allows uniform handling of all Cardano
-- eras, but also non-uniform by making case distinctions on the 'CardanoEra'
Expand Down Expand Up @@ -450,6 +452,16 @@ instance TestEquality ShelleyBasedEra where
testEquality ShelleyBasedEraConway ShelleyBasedEraConway = Just Refl
testEquality _ _ = Nothing

instance FeatureInEra ShelleyBasedEra where
featureInEra no yes = \case
ByronEra -> no
ShelleyEra -> yes ShelleyBasedEraShelley
AllegraEra -> yes ShelleyBasedEraAllegra
MaryEra -> yes ShelleyBasedEraMary
AlonzoEra -> yes ShelleyBasedEraAlonzo
BabbageEra -> yes ShelleyBasedEraBabbage
ConwayEra -> yes ShelleyBasedEraConway

-- | The class of eras that are based on Shelley. This allows uniform handling
-- of Shelley-based eras, but also non-uniform by making case distinctions on
-- the 'ShelleyBasedEra' constructors.
Expand Down

0 comments on commit ae2d2da

Please sign in to comment.