Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename the Byron, Shelley etc types to be clearly eras
So rename ByronEra -> ByronEra, Shelley to ShelleyEra etc This first step adds the new names, and keeps deprecated aliases for the previous names. The purpose of this renaming is because we want to clarify that these type tags are really used to indicate an era. Where we are tempted to use them for something other than eras then we need new names. For example we have Byron and Shelley address types, which are not quite the same as the Byron and Shelley era, since both address types are available in the Shelley and all subsequent eras. So we will want to introduce new names such as ByronAddr/ShelleyAddr and use those rather than ByronEra/ShelleyEra for types of addresses.
- Loading branch information
Showing
5 changed files
with
77 additions
and
35 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
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 |
---|---|---|
@@ -1,47 +1,89 @@ | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE PatternSynonyms #-} | ||
|
||
|
||
-- | Cardano eras, sometimes we have to distinguish them. | ||
-- | ||
module Cardano.Api.Eras | ||
( -- * Eras | ||
Byron | ||
ByronEra | ||
, ShelleyEra | ||
, AllegraEra | ||
, MaryEra | ||
|
||
-- * Deprecated aliases | ||
, Byron | ||
, Shelley | ||
, Allegra | ||
, Mary | ||
, AsType(..) | ||
|
||
-- * Data family instances | ||
, AsType(AsByronEra, AsShelleyEra, AsAllegraEra, AsMaryEra, | ||
AsByron, AsShelley, AsAllegra, AsMary) | ||
) where | ||
|
||
import Cardano.Api.HasTypeProxy | ||
|
||
|
||
-- | A type used as a tag to distinguish the Byron era. | ||
data Byron | ||
data ByronEra | ||
|
||
-- | A type used as a tag to distinguish the Shelley era. | ||
data Shelley | ||
data ShelleyEra | ||
|
||
-- | A type used as a tag to distinguish the Allegra era. | ||
data Allegra | ||
data AllegraEra | ||
|
||
-- | A type used as a tag to distinguish the Mary era. | ||
data Mary | ||
data MaryEra | ||
|
||
|
||
instance HasTypeProxy ByronEra where | ||
data AsType ByronEra = AsByronEra | ||
proxyToAsType _ = AsByronEra | ||
|
||
instance HasTypeProxy ShelleyEra where | ||
data AsType ShelleyEra = AsShelleyEra | ||
proxyToAsType _ = AsShelleyEra | ||
|
||
instance HasTypeProxy AllegraEra where | ||
data AsType AllegraEra = AsAllegraEra | ||
proxyToAsType _ = AsAllegraEra | ||
|
||
instance HasTypeProxy MaryEra where | ||
data AsType MaryEra = AsMaryEra | ||
proxyToAsType _ = AsMaryEra | ||
|
||
|
||
-- ---------------------------------------------------------------------------- | ||
-- Deprecated aliases | ||
-- | ||
|
||
type Byron = ByronEra | ||
type Shelley = ShelleyEra | ||
type Allegra = AllegraEra | ||
type Mary = MaryEra | ||
|
||
{-# DEPRECATED Byron "Use 'ByronEra' or 'ByronAddr' as appropriate" #-} | ||
{-# DEPRECATED Shelley "Use 'ShelleyEra' or 'ShelleyAddr' as appropriate" #-} | ||
{-# DEPRECATED Allegra "Use 'AllegraEra' instead" #-} | ||
{-# DEPRECATED Mary "Use 'MaryEra' instead" #-} | ||
|
||
pattern AsByron :: AsType ByronEra | ||
pattern AsByron = AsByronEra | ||
|
||
instance HasTypeProxy Byron where | ||
data AsType Byron = AsByron | ||
proxyToAsType _ = AsByron | ||
pattern AsShelley :: AsType ShelleyEra | ||
pattern AsShelley = AsShelleyEra | ||
|
||
instance HasTypeProxy Shelley where | ||
data AsType Shelley = AsShelley | ||
proxyToAsType _ = AsShelley | ||
pattern AsAllegra :: AsType AllegraEra | ||
pattern AsAllegra = AsAllegraEra | ||
|
||
instance HasTypeProxy Allegra where | ||
data AsType Allegra = AsAllegra | ||
proxyToAsType _ = AsAllegra | ||
pattern AsMary :: AsType MaryEra | ||
pattern AsMary = AsMaryEra | ||
|
||
instance HasTypeProxy Mary where | ||
data AsType Mary = AsMary | ||
proxyToAsType _ = AsMary | ||
{-# DEPRECATED AsByron "Use 'AsByronEra' instead" #-} | ||
{-# DEPRECATED AsShelley "Use 'AsShelleyEra' instead" #-} | ||
{-# DEPRECATED AsAllegra "Use 'AsAllegraEra' instead" #-} | ||
{-# DEPRECATED AsMary "Use 'AsMaryEra' instead" #-} | ||
|
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