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

Fix unexpected behavior of Lens.withDefault #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blacktaxi
Copy link
Member

This tracks #17

The issue is that Lens.withDefault with unexpectedly use an undefined value in place of a value passed into a Lens.set when it is equal to the default value provided.

It makes sense, as it is more lawful (in lens laws terms) to remove a value when set to default. Although technically, the current implementation is not lawful either, because { a: 5, b: undefined } is not strictly equal to { a: 5 }.

I see these options:

  1. Change Lens.withDefault to actually modify the data structure even when set to a default value.
  2. Leave Lens.withDefault as it is and implement a separate lens with this new behavior.

Bonus option: if we decide to keep current Lens.withDefault, fix it to be truly lawful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant