feat: LeanCtorLayout trait and lean_inductive! macro#8
Merged
samuelburnham merged 17 commits intomainfrom Apr 16, 2026
Merged
Conversation
Member
arthurpaulino
left a comment
There was a problem hiding this comment.
My first review pass focuses mainly on booleans, given the recent changes that happened on ix.
arthurpaulino
previously approved these changes
Apr 14, 2026
Member
arthurpaulino
left a comment
There was a problem hiding this comment.
Looks good!
I'll wait for argumentcomputer/ix#380 to be updated with this new approach
7f21c96 to
014d28a
Compare
LeanCtorLayout trait and lean_inductive! macro
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
LeanCtorLayouttrait for inductives and structures with aLAYOUTSarray that contains the number of objects, usizes, and scalar types (e.g. u64 or bool) for each inductive variant. TheLAYOUTSindex is the tag/variant index of the inductive:This allows the user to implement the trait as follows:
Or use the
lean_inductive!convenience macro, which also callslean_domain_type!to create theLeanPairwrapper type and generates getters and setters for every type inSingleCtorLayout:Then the user can write:
Users still have to know how many fields of a given size are in the Lean structure and the index of each one they want to access, but it's better than having to manually compute byte offsets for scalar values.