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

Use heterogeneous lists in code generated by Witty derive macros #937

Merged
merged 5 commits into from
Aug 4, 2023

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Aug 4, 2023

Motivation

The code generated by Witty derive macros is non-trivial and is mostly equivalent to the implementation for frunk's heterogeneous lists.

Proposal

Refactor the Witty derive macros to generate code that use heterogeneous lists instead of code to manually handle each field in a type. This reduces the amount of code generated, centralizes the more complex code in the implementations for frunk types and hopefully improves readability of the generated code.

Test Plan

The unit and integration tests that already exist cover the behavior which the refactoring must not change.

Links

This is an unexpected extra work related to of #906.

Release Plan

  • All good!
  • Need to bump the major/minor version number in the next release of the crates.
  • Need to update the developer manual.
  • This PR is adding or removing Cargo features.
  • Release is blocked and/or tracked by other issues (see links above)

Reviewer Checklist

  • The title and the summary of the PR are short and descriptive.
  • The proposed solution achieves the goals stated in the PR.
  • The test plan is reproducible and provides sufficient coverage.
  • The release plan is adequate.
  • The commits correspond to distinct logical changes.
  • The code follows the coding guidelines.
  • The proposed changes look correct.
  • The CI is passing.
  • All of the above!

Functions that will be used by all derive macros and are related to
generating code using heterogeneous lists.
Leverage heterogeneous lists to reduce the amount of code generated.
Allow generated code to use it to extract the discriminant from the flat
layout.
Leverage heterogeneous lists to reduce the amount of code generated.
Leverage heterogeneous lists to reduce the amount of code generated.
@jvff jvff added the refactor label Aug 4, 2023
@jvff jvff added this to the Devnet milestone Aug 4, 2023
@jvff jvff requested a review from ma2bd August 4, 2023 14:01
@jvff jvff self-assigned this Aug 4, 2023
Copy link
Contributor

@ma2bd ma2bd left a comment

Choose a reason for hiding this comment

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

Makes sense!

location = location.after::<i64>();

Ok(())
linera_witty::hlist![field0, field1, field2].store(memory, location)
Copy link
Contributor

Choose a reason for hiding this comment

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

The unit tests help a lot!

@jvff jvff merged commit 306eb1a into linera-io:main Aug 4, 2023
3 checks passed
@jvff jvff deleted the use-hlist-in-witty-derive-macros branch August 4, 2023 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants