Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New caseShelleyToBabbageAndConwayEraOnwards function #231

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -58,7 +58,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