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

Create and use lenses for ProcessedTerm and Module #1866

Merged
merged 2 commits into from
May 28, 2024

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented May 27, 2024

Splitting out an independent refactoring to simplify #1865. There were many places in the code where we were pattern-matching on ProcessedTerm and/or Module, sometimes only to extract a single field, e.g.

ProcessedTerm (Module s _) _ _ <- maybeInitialCode

This was already getting a bit out of hand, and it also meant that any time we wanted to add an extra field to either ProcessedTerm or Module (as I will be doing in #1865), we would have to change every single such place in the code to add an extra wildcard pattern.

This PR is a refactoring to

  1. Derive lenses for all the fields of ProcessedTerm and Module, and
  2. Prefer extracting named fields via lenses over pattern-matching in most places in the code.

There were a few places in the code where we destructure a ProcessedTerm and use almost all the fields (e.g. when initializing a robot machine); I left those alone, first because extracting all the individual fields would be tedious, but more importantly because if we ever added any new fields in the future, it's likely we would actually want to use them in those contexts as well.

@byorgey byorgey requested a review from kostmo May 27, 2024 12:38
@byorgey byorgey mentioned this pull request May 27, 2024
@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label May 28, 2024
@mergify mergify bot merged commit 902ceda into main May 28, 2024
11 checks passed
@mergify mergify bot deleted the refactor/processedterm-module-fields branch May 28, 2024 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants