{-# LANGUAGE GADTs #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module Bcc.Api.Eras
(
ColeEra
, SophieEra
, EvieEra
, JenEra
, AurumEra
, BccEra(..)
, IsBccEra(..)
, AnyBccEra(..)
, anyBccEra
, InAnyBccEra(..)
, Cole
, Sophie
, Evie
, Jen
, SophieBasedEra(..)
, IsSophieBasedEra(..)
, InAnySophieBasedEra(..)
, sophieBasedToBccEra
, SophieLedgerEra
, BccEraStyle(..)
, bccEraStyle
, AsType(AsColeEra, AsSophieEra, AsEvieEra, AsJenEra, AsAurumEra,
AsCole, AsSophie, AsEvie, AsJen)
) where
import Prelude
import Data.Aeson (ToJSON, toJSON)
import Data.Type.Equality (TestEquality (..), (:~:) (Refl))
import Shardagnostic.Consensus.Sophie.Eras as Ledger
(StandardSophie,
StandardEvie,
StandardJen,
StandardAurum)
import Bcc.Api.HasTypeProxy
data ColeEra
data SophieEra
data EvieEra
data JenEra
data AurumEra
instance HasTypeProxy ColeEra where
data AsType ColeEra = AsColeEra
proxyToAsType :: Proxy ColeEra -> AsType ColeEra
proxyToAsType Proxy ColeEra
_ = AsType ColeEra
AsColeEra
instance HasTypeProxy SophieEra where
data AsType SophieEra = AsSophieEra
proxyToAsType :: Proxy SophieEra -> AsType SophieEra
proxyToAsType Proxy SophieEra
_ = AsType SophieEra
AsSophieEra
instance HasTypeProxy EvieEra where
data AsType EvieEra = AsEvieEra
proxyToAsType :: Proxy EvieEra -> AsType EvieEra
proxyToAsType Proxy EvieEra
_ = AsType EvieEra
AsEvieEra
instance HasTypeProxy JenEra where
data AsType JenEra = AsJenEra
proxyToAsType :: Proxy JenEra -> AsType JenEra
proxyToAsType Proxy JenEra
_ = AsType JenEra
AsJenEra
instance HasTypeProxy AurumEra where
data AsType AurumEra = AsAurumEra
proxyToAsType :: Proxy AurumEra -> AsType AurumEra
proxyToAsType Proxy AurumEra
_ = AsType AurumEra
AsAurumEra
type Cole = ColeEra
type Sophie = SophieEra
type Evie = EvieEra
type Jen = JenEra
{-# DEPRECATED Cole "Use 'ColeEra' or 'ColeAddr' as appropriate" #-}
{-# DEPRECATED Sophie "Use 'SophieEra' or 'SophieAddr' as appropriate" #-}
{-# DEPRECATED Evie "Use 'EvieEra' instead" #-}
{-# DEPRECATED Jen "Use 'JenEra' instead" #-}
pattern AsCole :: AsType ColeEra
pattern $bAsCole :: AsType ColeEra
$mAsCole :: forall r. AsType ColeEra -> (Void# -> r) -> (Void# -> r) -> r
AsCole = AsColeEra
pattern AsSophie :: AsType SophieEra
pattern $bAsSophie :: AsType SophieEra
$mAsSophie :: forall r. AsType SophieEra -> (Void# -> r) -> (Void# -> r) -> r
AsSophie = AsSophieEra
pattern AsEvie :: AsType EvieEra
pattern $bAsEvie :: AsType EvieEra
$mAsEvie :: forall r. AsType EvieEra -> (Void# -> r) -> (Void# -> r) -> r
AsEvie = AsEvieEra
pattern AsJen :: AsType JenEra
pattern $bAsJen :: AsType JenEra
$mAsJen :: forall r. AsType JenEra -> (Void# -> r) -> (Void# -> r) -> r
AsJen = AsJenEra
{-# DEPRECATED AsCole "Use 'AsColeEra' instead" #-}
{-# DEPRECATED AsSophie "Use 'AsSophieEra' instead" #-}
{-# DEPRECATED AsEvie "Use 'AsEvieEra' instead" #-}
{-# DEPRECATED AsJen "Use 'AsJenEra' instead" #-}
data BccEra era where
ColeEra :: BccEra ColeEra
SophieEra :: BccEra SophieEra
EvieEra :: BccEra EvieEra
JenEra :: BccEra JenEra
AurumEra :: BccEra AurumEra
deriving instance Eq (BccEra era)
deriving instance Ord (BccEra era)
deriving instance Show (BccEra era)
instance ToJSON (BccEra era) where
toJSON :: BccEra era -> Value
toJSON BccEra era
ColeEra = Value
"Cole"
toJSON BccEra era
SophieEra = Value
"Sophie"
toJSON BccEra era
EvieEra = Value
"Evie"
toJSON BccEra era
JenEra = Value
"Jen"
toJSON BccEra era
AurumEra = Value
"Aurum"
instance TestEquality BccEra where
testEquality :: BccEra a -> BccEra b -> Maybe (a :~: b)
testEquality BccEra a
ColeEra BccEra b
ColeEra = (a :~: a) -> Maybe (a :~: a)
forall a. a -> Maybe a
Just a :~: a
forall k (a :: k). a :~: a
Refl
testEquality BccEra a
SophieEra BccEra b
SophieEra = (a :~: a) -> Maybe (a :~: a)
forall a. a -> Maybe a
Just a :~: a
forall k (a :: k). a :~: a
Refl
testEquality BccEra a
EvieEra BccEra b
EvieEra = (a :~: a) -> Maybe (a :~: a)
forall a. a -> Maybe a
Just a :~: a
forall k (a :: k). a :~: a
Refl
testEquality BccEra a
JenEra BccEra b
JenEra = (a :~: a) -> Maybe (a :~: a)
forall a. a -> Maybe a
Just a :~: a
forall k (a :: k). a :~: a
Refl
testEquality BccEra a
AurumEra BccEra b
AurumEra = (a :~: a) -> Maybe (a :~: a)
forall a. a -> Maybe a
Just a :~: a
forall k (a :: k). a :~: a
Refl
testEquality BccEra a
_ BccEra b
_ = Maybe (a :~: b)
forall a. Maybe a
Nothing
class HasTypeProxy era => IsBccEra era where
bccEra :: BccEra era
instance IsBccEra ColeEra where
bccEra :: BccEra ColeEra
bccEra = BccEra ColeEra
ColeEra
instance IsBccEra SophieEra where
bccEra :: BccEra SophieEra
bccEra = BccEra SophieEra
SophieEra
instance IsBccEra EvieEra where
bccEra :: BccEra EvieEra
bccEra = BccEra EvieEra
EvieEra
instance IsBccEra JenEra where
bccEra :: BccEra JenEra
bccEra = BccEra JenEra
JenEra
instance IsBccEra AurumEra where
bccEra :: BccEra AurumEra
bccEra = BccEra AurumEra
AurumEra
data AnyBccEra where
AnyBccEra :: IsBccEra era
=> BccEra era
-> AnyBccEra
deriving instance Show AnyBccEra
instance Eq AnyBccEra where
AnyBccEra BccEra era
era == :: AnyBccEra -> AnyBccEra -> Bool
== AnyBccEra BccEra era
era' =
case BccEra era -> BccEra era -> Maybe (era :~: era)
forall k (f :: k -> *) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
testEquality BccEra era
era BccEra era
era' of
Maybe (era :~: era)
Nothing -> Bool
False
Just era :~: era
Refl -> Bool
True
instance ToJSON AnyBccEra where
toJSON :: AnyBccEra -> Value
toJSON (AnyBccEra BccEra era
era) = BccEra era -> Value
forall a. ToJSON a => a -> Value
toJSON BccEra era
era
anyBccEra :: BccEra era -> AnyBccEra
anyBccEra :: BccEra era -> AnyBccEra
anyBccEra BccEra era
ColeEra = BccEra ColeEra -> AnyBccEra
forall era. IsBccEra era => BccEra era -> AnyBccEra
AnyBccEra BccEra ColeEra
ColeEra
anyBccEra BccEra era
SophieEra = BccEra SophieEra -> AnyBccEra
forall era. IsBccEra era => BccEra era -> AnyBccEra
AnyBccEra BccEra SophieEra
SophieEra
anyBccEra BccEra era
EvieEra = BccEra EvieEra -> AnyBccEra
forall era. IsBccEra era => BccEra era -> AnyBccEra
AnyBccEra BccEra EvieEra
EvieEra
anyBccEra BccEra era
JenEra = BccEra JenEra -> AnyBccEra
forall era. IsBccEra era => BccEra era -> AnyBccEra
AnyBccEra BccEra JenEra
JenEra
anyBccEra BccEra era
AurumEra = BccEra AurumEra -> AnyBccEra
forall era. IsBccEra era => BccEra era -> AnyBccEra
AnyBccEra BccEra AurumEra
AurumEra
data InAnyBccEra thing where
InAnyBccEra :: IsBccEra era
=> BccEra era
-> thing era
-> InAnyBccEra thing
data SophieBasedEra era where
SophieBasedEraSophie :: SophieBasedEra SophieEra
SophieBasedEraEvie :: SophieBasedEra EvieEra
SophieBasedEraJen :: SophieBasedEra JenEra
SophieBasedEraAurum :: SophieBasedEra AurumEra
deriving instance Eq (SophieBasedEra era)
deriving instance Ord (SophieBasedEra era)
deriving instance Show (SophieBasedEra era)
class IsBccEra era => IsSophieBasedEra era where
sophieBasedEra :: SophieBasedEra era
instance IsSophieBasedEra SophieEra where
sophieBasedEra :: SophieBasedEra SophieEra
sophieBasedEra = SophieBasedEra SophieEra
SophieBasedEraSophie
instance IsSophieBasedEra EvieEra where
sophieBasedEra :: SophieBasedEra EvieEra
sophieBasedEra = SophieBasedEra EvieEra
SophieBasedEraEvie
instance IsSophieBasedEra JenEra where
sophieBasedEra :: SophieBasedEra JenEra
sophieBasedEra = SophieBasedEra JenEra
SophieBasedEraJen
instance IsSophieBasedEra AurumEra where
sophieBasedEra :: SophieBasedEra AurumEra
sophieBasedEra = SophieBasedEra AurumEra
SophieBasedEraAurum
data InAnySophieBasedEra thing where
InAnySophieBasedEra :: IsSophieBasedEra era
=> SophieBasedEra era
-> thing era
-> InAnySophieBasedEra thing
sophieBasedToBccEra :: SophieBasedEra era -> BccEra era
sophieBasedToBccEra :: SophieBasedEra era -> BccEra era
sophieBasedToBccEra SophieBasedEra era
SophieBasedEraSophie = BccEra era
BccEra SophieEra
SophieEra
sophieBasedToBccEra SophieBasedEra era
SophieBasedEraEvie = BccEra era
BccEra EvieEra
EvieEra
sophieBasedToBccEra SophieBasedEra era
SophieBasedEraJen = BccEra era
BccEra JenEra
JenEra
sophieBasedToBccEra SophieBasedEra era
SophieBasedEraAurum = BccEra era
BccEra AurumEra
AurumEra
data BccEraStyle era where
LegacyColeEra :: BccEraStyle ColeEra
SophieBasedEra :: IsSophieBasedEra era
=> SophieBasedEra era
-> BccEraStyle era
deriving instance Eq (BccEraStyle era)
deriving instance Ord (BccEraStyle era)
deriving instance Show (BccEraStyle era)
bccEraStyle :: BccEra era -> BccEraStyle era
bccEraStyle :: BccEra era -> BccEraStyle era
bccEraStyle BccEra era
ColeEra = BccEraStyle era
BccEraStyle ColeEra
LegacyColeEra
bccEraStyle BccEra era
SophieEra = SophieBasedEra SophieEra -> BccEraStyle SophieEra
forall era.
IsSophieBasedEra era =>
SophieBasedEra era -> BccEraStyle era
SophieBasedEra SophieBasedEra SophieEra
SophieBasedEraSophie
bccEraStyle BccEra era
EvieEra = SophieBasedEra EvieEra -> BccEraStyle EvieEra
forall era.
IsSophieBasedEra era =>
SophieBasedEra era -> BccEraStyle era
SophieBasedEra SophieBasedEra EvieEra
SophieBasedEraEvie
bccEraStyle BccEra era
JenEra = SophieBasedEra JenEra -> BccEraStyle JenEra
forall era.
IsSophieBasedEra era =>
SophieBasedEra era -> BccEraStyle era
SophieBasedEra SophieBasedEra JenEra
SophieBasedEraJen
bccEraStyle BccEra era
AurumEra = SophieBasedEra AurumEra -> BccEraStyle AurumEra
forall era.
IsSophieBasedEra era =>
SophieBasedEra era -> BccEraStyle era
SophieBasedEra SophieBasedEra AurumEra
SophieBasedEraAurum
type family SophieLedgerEra era where
SophieLedgerEra SophieEra = Ledger.StandardSophie
SophieLedgerEra EvieEra = Ledger.StandardEvie
SophieLedgerEra JenEra = Ledger.StandardJen
SophieLedgerEra AurumEra = Ledger.StandardAurum