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

Remove Show (Some a) and Eq (Some a). Add Show (Some Era) and Eq (Some Era). #665

Merged
merged 1 commit into from
Nov 19, 2024
Merged
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
19 changes: 8 additions & 11 deletions cardano-api/internal/Cardano/Api/Experimental/Eras.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ type family LedgerEra era = (r :: Type) | r -> era where
LedgerEra BabbageEra = Ledger.Babbage
LedgerEra ConwayEra = Ledger.Conway

-- | An existential type for singleton types. Use to hold any era e.g. @Some Era@. One can then bring the
-- era witness back into scope for example using this pattern:
-- | An existential wrapper for types of kind @k -> Types@. Use it to hold any era e.g. @Some Era@. One can
-- then bring the era witness back into scope for example using this pattern:
-- @
-- anyEra = Some ConwayEra
-- -- then later in the code
Expand All @@ -81,15 +81,6 @@ data Some (f :: k -> Type) where
=> f a
-> Some f

-- | Assumes that @f@ is a singleton
instance Show (Some f) where
showsPrec _ (Some v) = showsTypeRep (typeOf v)

-- | Assumes that @f@ is a singleton
instance TestEquality f => Eq (Some f) where
Some era1 == Some era2 =
isJust $ testEquality era1 era2

-- | Represents the eras in Cardano's blockchain.
-- This type represents eras currently on mainnet and new eras which are
-- in development.
Expand Down Expand Up @@ -119,6 +110,12 @@ instance TestEquality Era where
instance ToJSON (Era era) where
toJSON = eraToStringLike

instance Show (Some Era) where
showsPrec _ (Some era) = shows era

instance Eq (Some Era) where
Some era1 == Some era2 = isJust $ testEquality era1 era2

instance Bounded (Some Era) where
minBound = Some BabbageEra
maxBound = Some ConwayEra
Expand Down
Loading