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

Rename AnyEraInEon to EraInEon #289

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

newhoggy
Copy link
Collaborator

@newhoggy newhoggy commented Oct 2, 2023

Changelog

- description: |
    Rename `AnyEraInEon` to `EraInEon`
# 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

This simplifies the type name. The Any prefix is not needed to understand what the type does.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • The change log section in the PR description has been filled in
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • round trip tests
    • integration tests
      See Running tests for more details
  • The version bounds in .cabal files are updated
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
    • Code builds on Linux, MacOS and Windows for ghc-8.10.7 and ghc-9.2.7
  • Self-reviewed the diff

@@ -163,38 +162,24 @@ maybeEon =
-- ----------------------------------------------------------------------------
-- Era and eon existential types

data AnyEraInEon eon where
AnyEraInEon
data EraInEon eon where
Copy link
Contributor

@carbolymer carbolymer Oct 2, 2023

Choose a reason for hiding this comment

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

I think Any prefix was useful here, we were using it to denote an existential.

Copy link
Collaborator Author

@newhoggy newhoggy Oct 3, 2023

Choose a reason for hiding this comment

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

I originally thought of Any as representing the existential, but it doesn't have to be the only way to represent the existential.

We can review some examples:

data AnyConsensusModeParams where
  AnyConsensusModeParams :: ConsensusModeParams mode -> AnyConsensusModeParams

data AnyConsensusMode where
  AnyConsensusMode :: ConsensusMode mode -> AnyConsensusMode

data AnyScriptLanguage where
     AnyScriptLanguage :: ScriptLanguage lang -> AnyScriptLanguage

data AnyPlutusScriptVersion where
     AnyPlutusScriptVersion :: PlutusScriptVersion lang -> AnyPlutusScriptVersion

I think in all the above cases, the Any prefix fits because they match the pattern AnyX where X is the thing we are quantifying over.

These however, I think are different:

data AnyEraInMode mode where
     AnyEraInMode :: EraInMode era mode -> AnyEraInMode mode

data AnyEraInEon eon where
  AnyEraInEon
    :: ( Typeable era
       , Typeable (eon era)
       , Eon eon )
    => eon era
    -> AnyEraInEon eon

We are not quantifying over EraInMode or EraInEon, we are just quantifying over the era. The Eon part or the Mode part continues to be parameterised.

I think in these cases, it is appropriate to just call it EraInMode or EraInEon where pattern XInY means quantifying X for a given Y.

data AnyScriptWitness era where
     AnyScriptWitness :: ScriptWitness witctx era -> AnyScriptWitness era

This one is a bit special. The only way it makes sense for me is if it were named ScriptWitnessInAnyWitnessContext, so it doesn't follow either of the two conventions above.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still not convinced and I think in your example both are the same - in both cases in AnyEraInMode mode and AnyEraInEon eon we're quantifying over eras.

Copy link
Contributor

@carbolymer carbolymer left a comment

Choose a reason for hiding this comment

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

Either we should remove Any prefixes from all existentials, or leave it as it is.

@carbolymer carbolymer dismissed their stale review October 2, 2023 13:40

not blocking if you guys feel that's the way

@newhoggy
Copy link
Collaborator Author

newhoggy commented Oct 3, 2023

Okay. Making the call to merge since I'm leaning towards the change and have the casting vote.

@newhoggy newhoggy added this pull request to the merge queue Oct 3, 2023
Merged via the queue into main with commit fa58de8 Oct 3, 2023
20 checks passed
@newhoggy newhoggy deleted the newhoggy/rename-AnyEraInEon-to-EraInEon branch October 3, 2023 12:22
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.

None yet

3 participants