Skip to content

Commit

Permalink
Merge pull request #231 from input-output-hk/newhoggy/new-caseShelley…
Browse files Browse the repository at this point in the history
…ToBabbageAndConwayEraOnwards-function

New `caseShelleyToBabbageAndConwayEraOnwards` function
  • Loading branch information
newhoggy authored Sep 9, 2023
2 parents 6b18972 + e99eca8 commit ebbca89
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ library internal
Cardano.Api.DRepMetadata
Cardano.Api.EraCast
Cardano.Api.Eras
Cardano.Api.Eras.Case
Cardano.Api.Eras.Constraints
Cardano.Api.Eras.Core
Cardano.Api.Error
Expand Down
4 changes: 4 additions & 0 deletions cardano-api/internal/Cardano/Api/Eras.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ module Cardano.Api.Eras
, requireShelleyBasedEra

, withShelleyBasedEraConstraintsForLedger

-- * Era case handling
, caseShelleyToBabbageAndConwayEraOnwards
) where

import Cardano.Api.Eras.Case
import Cardano.Api.Eras.Constraints
import Cardano.Api.Eras.Core
23 changes: 23 additions & 0 deletions cardano-api/internal/Cardano/Api/Eras/Case.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.Api.Eras.Case
( caseShelleyToBabbageAndConwayEraOnwards
) where

import Cardano.Api.Eras.Core
import Cardano.Api.Feature.ConwayEraOnwards
import Cardano.Api.Feature.ShelleyToBabbageEra

caseShelleyToBabbageAndConwayEraOnwards :: ()
=> (ShelleyToBabbageEra era -> a)
-> (ConwayEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToBabbageAndConwayEraOnwards l r = \case
ShelleyBasedEraShelley -> l ShelleyToBabbageEraShelley
ShelleyBasedEraAllegra -> l ShelleyToBabbageEraAllegra
ShelleyBasedEraMary -> l ShelleyToBabbageEraMary
ShelleyBasedEraAlonzo -> l ShelleyToBabbageEraAlonzo
ShelleyBasedEraBabbage -> l ShelleyToBabbageEraBabbage
ShelleyBasedEraConway -> r ConwayEraOnwardsConway
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Cardano.Api.Feature.ConwayEraOnwards
, conwayEraOnwardsToShelleyBasedEra
) where

import Cardano.Api.Eras
import Cardano.Api.Eras.Core
import Cardano.Api.Modes
import Cardano.Api.Query.Types

Expand Down
3 changes: 3 additions & 0 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ module Cardano.Api (
shelleyBasedEraConstraints,
withShelleyBasedEraConstraintsForLedger,

-- * Era case handling
caseShelleyToBabbageAndConwayEraOnwards,

-- * Assertions on era
requireShelleyBasedEra,

Expand Down

0 comments on commit ebbca89

Please sign in to comment.