-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from input-output-hk/smelc/add-babbage-era-only
Add BabbageEraOnly
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{-# LANGUAGE ConstraintKinds #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
module Cardano.Api.Eon.BabbageEraOnly | ||
( BabbageEraOnly(..) | ||
, babbageEraOnlyConstraints | ||
, babbageEraOnlyToCardanoEra | ||
|
||
, BabbageEraOnlyConstraints | ||
) where | ||
|
||
import Cardano.Api.Eras.Core | ||
|
||
import Data.Typeable (Typeable) | ||
|
||
data BabbageEraOnly era where | ||
BabbageEraOnlyBabbage :: BabbageEraOnly BabbageEra | ||
|
||
deriving instance Show (BabbageEraOnly era) | ||
deriving instance Eq (BabbageEraOnly era) | ||
|
||
instance Eon BabbageEraOnly where | ||
inEonForEra no yes = \case | ||
ByronEra -> no | ||
ShelleyEra -> no | ||
AllegraEra -> no | ||
MaryEra -> no | ||
AlonzoEra -> no | ||
BabbageEra -> yes BabbageEraOnlyBabbage | ||
ConwayEra -> no | ||
|
||
instance ToCardanoEra BabbageEraOnly where | ||
toCardanoEra = \case | ||
BabbageEraOnlyBabbage -> BabbageEra | ||
|
||
type BabbageEraOnlyConstraints era = | ||
( IsCardanoEra era | ||
, Typeable era | ||
) | ||
|
||
babbageEraOnlyConstraints :: () | ||
=> BabbageEraOnly era | ||
-> (BabbageEraOnlyConstraints era => a) | ||
-> a | ||
babbageEraOnlyConstraints = \case | ||
BabbageEraOnlyBabbage -> id | ||
|
||
babbageEraOnlyToCardanoEra :: BabbageEraOnly era -> CardanoEra era | ||
babbageEraOnlyToCardanoEra = \case | ||
BabbageEraOnlyBabbage -> BabbageEra |