Skip to content

Comments

Add deriveEnum for Plinth#7456

Merged
zliu41 merged 2 commits intomasterfrom
bezirg/derive-enum
Dec 4, 2025
Merged

Add deriveEnum for Plinth#7456
zliu41 merged 2 commits intomasterfrom
bezirg/derive-enum

Conversation

@bezirg
Copy link
Contributor

@bezirg bezirg commented Nov 26, 2025

Pre-submit checklist:

  • Branch
    • Tests are provided (if possible)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
    • Changelog fragments have been written (if appropriate)
    • Relevant tickets are mentioned in commit messages
    • Formatting, PNG optimization, etc. are updated
  • PR
    • (For external contributions) Corresponding issue exists and is linked in the description
    • Targeting master unless this is a cherry-pick backport
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

@SeungheonOh
Copy link
Collaborator

With regards to enums, it would also be nice to have a variant of mkIsData for enum types where it will encode each constructors as integer instead of Constr n [], but it's a bit off topic

@bezirg
Copy link
Contributor Author

bezirg commented Dec 1, 2025

With regards to enums, it would also be nice to have a variant of mkIsData for enum types where it will encode each constructors as integer instead of Constr n [], but it's a bit off topic

Interesting idea. I don't know if the plutus core spec though has to be modified to account for this optimization.

@bezirg bezirg force-pushed the bezirg/derive-enum branch 2 times, most recently from a9ecb70 to 47ec226 Compare December 1, 2025 17:19
@bezirg bezirg marked this pull request as ready for review December 1, 2025 17:20
@bezirg bezirg requested review from SeungheonOh, Unisay and kwxm December 1, 2025 17:20
@bezirg
Copy link
Contributor Author

bezirg commented Dec 1, 2025

With regards to enums, it would also be nice to have a variant of mkIsData for enum types where it will encode each constructors as integer instead of Constr n [], but it's a bit off topic

I think I will add it in another PR as deriveEnumData ''ADT

@bezirg bezirg force-pushed the bezirg/derive-enum branch 2 times, most recently from 3e5d463 to d8cb9f1 Compare December 3, 2025 10:53
PlutusTx.Lift.TestInstances
PlutusTx.Lift.TH
PlutusTx.Lift.THUtils
PlutusTx.Enum.TH
Copy link
Contributor

Choose a reason for hiding this comment

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

cabal-fmt re-orders modules alphabetically, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is cabal-fmt part of CI? I will run it manually

@bezirg bezirg requested a review from zliu41 December 4, 2025 16:52
@bezirg bezirg force-pushed the bezirg/derive-enum branch from d8cb9f1 to 33e1ac2 Compare December 4, 2025 18:42
Copy link
Member

@zliu41 zliu41 left a comment

Choose a reason for hiding this comment

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

LGTM

@zliu41 zliu41 merged commit d893955 into master Dec 4, 2025
1 of 2 checks passed
@zliu41 zliu41 deleted the bezirg/derive-enum branch December 4, 2025 23:52
@SeungheonOh
Copy link
Collaborator

Interesting idea. I don't know if the plutus core spec though has to be modified to account for this optimization.

This is completely independent from core spec since it just changes how we generate some code.

On the side note we can probably make a smart version of current TH helper that decides most efficient representation like Constr vs List vs I

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.

4 participants