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

Expose CurrentEra and UpcomingEra pattern synonyms #414

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Dec 21, 2023

@carbolymer pointed out the following situation and suggested the use of pattern synonyms to remedy it.

Changelog

- description: |
    Expose CurrentEra and UpcomingEra pattern synonyms
# uncomment types applicable to the change:
  type:
  - feature        # introduces a new feature
  - breaking       # the API has changed in a breaking way
  - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - improvement    # QoL changes e.g. refactoring
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Additional context for the PR goes here. If the PR fixes a particular issue please provide a link to the issue.

How to trust this PR

Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@Jimbo4350 Jimbo4350 mentioned this pull request Dec 21, 2023
3 tasks
@Jimbo4350 Jimbo4350 changed the title Expose CurrentEra and UpcomingEra pattern synonyms WIP: Expose CurrentEra and UpcomingEra pattern synonyms Dec 21, 2023
@Jimbo4350 Jimbo4350 changed the title WIP: Expose CurrentEra and UpcomingEra pattern synonyms Expose CurrentEra and UpcomingEra pattern synonyms Dec 21, 2023
@Jimbo4350 Jimbo4350 force-pushed the jordan/era-handling-refactor-2 branch from 202cbf2 to 556450b Compare December 21, 2023 18:17
@Jimbo4350 Jimbo4350 force-pushed the jordan/era-handling-refactor-2 branch 4 times, most recently from 29c1603 to 0fbb6fb Compare December 21, 2023 18:29
-- doThing :: Era era -> ()
-- doThing = \case
-- CurrentEra' -> enableFeature
-- UpcomingEra' -> disableFeature
Copy link
Contributor Author

@Jimbo4350 Jimbo4350 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment elaborating on why this is undesirable i.e updating the type synonyms will go unnoticed by consumers. Also include comment in this module explaining how we will deprecate eras.

CurrentEra
:: SupportedProtocolVersionRange BabbageEra
=> Era BabbageEra
CurrentEra'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think being clear that this constructor should not be used would be better than just apostrophe.

Suggested change
CurrentEra'
UnsafeCurrentEra

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsafe implies something breaks the type system, memory safety etc. I'll append Internal to the constructors

@Jimbo4350 Jimbo4350 force-pushed the jordan/era-handling-refactor-2 branch 3 times, most recently from 045f9f2 to 3cd3610 Compare December 22, 2023 14:05
@Jimbo4350 Jimbo4350 enabled auto-merge December 22, 2023 14:07
@Jimbo4350 Jimbo4350 force-pushed the jordan/era-handling-refactor-2 branch from 3cd3610 to 442b5c8 Compare December 22, 2023 14:29
@Jimbo4350 Jimbo4350 disabled auto-merge December 22, 2023 14:32
@Jimbo4350 Jimbo4350 force-pushed the jordan/era-handling-refactor-2 branch 2 times, most recently from 721fd66 to 74966c0 Compare December 22, 2023 14:33
@Jimbo4350 Jimbo4350 force-pushed the jordan/era-handling-refactor-2 branch from 74966c0 to e999814 Compare December 22, 2023 14:34
@Jimbo4350 Jimbo4350 added this pull request to the merge queue Dec 22, 2023
Merged via the queue into main with commit 1c10a28 Dec 22, 2023
20 checks passed
@Jimbo4350 Jimbo4350 deleted the jordan/era-handling-refactor-2 branch December 22, 2023 15:02

4. Add new 'UseEra' instance and keep the deprecated era's instance.
@
instance UseEra BabbageEra where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add also a TypeError here e.g.:

instance TypeError (Text "BabbageEra no longer supported, use ConwayEra") => UseEra BabbageEra where

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...or maybe not. I guess the point is to have the project buildable, but also generate a deprecation warning.


4. Add new 'UseEra' instance and keep the deprecated era's instance.
@
instance UseEra BabbageEra where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...or maybe not. I guess the point is to have the project buildable, but also generate a deprecation warning.

( MinSupportedVersion <= version
, version <= MaxSupportedVersion
)
data BabbageEra
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the "lifecycle" of uninhabited era types? After forking to conway, will we remove the old era, or leave it for some time?

newhoggy added a commit that referenced this pull request Mar 11, 2024
…t-types-for-poll-commands

Command argument types for poll commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants