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

Recover withReverseSingleReferenceList nicely #554

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

towerofnix
Copy link
Member

The thing-coding utility function reverseSingleReference was removed one year ago (9d8616c) at about the same time we were implementing compositions in general (#256), so it was never ported compositional data code.

This PR recovers that function, now reverseSingleReferenceList and withReverseSingleReferenceList, as a composition. It's coded the same way as reverse reference lists and reverse contribution lists (#431) and in order to reduce code duplication, we've "cheaply" moved all the common details into a helper function which offers all boilerplate, up to calling templateCompositeFrom. This means fast reverse references (#383) and sorting by date (#536) are now part of shared and written-once code, withReverseList_template.

There are now three compositions directly based on that shared code:

  • withReverseReferenceList
  • withReverseContributionList
  • withReverseSingleReferenceList

In the future, the helper should be made into a proper composition of its own right, which accepts a compositional subroutine (#342). But that's a ways off, and these changes get essentially the same code-writing benefits via deduplication. It'll be easier to port the new functions over to the subroutine style, once ready, since the differences between these compositions are now laid out plainly.

reverseSingleReferenceList is still unused (as it was when we removed it), but we expect to use it to help represent more particular relationships between things in the near future.

@towerofnix towerofnix merged commit b0444ca into preview Sep 4, 2024
@towerofnix towerofnix deleted the reverse-single-reference branch September 4, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant