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

Default Value Lens #5

Open
iamnoah opened this issue Aug 5, 2014 · 2 comments
Open

Default Value Lens #5

iamnoah opened this issue Aug 5, 2014 · 2 comments

Comments

@iamnoah
Copy link
Owner

iamnoah commented Aug 5, 2014

Lens that calculates a default value if the value is undefined. Also can apply to whole objects. Setting a value sets the "real" value such that the default will no longer apply.

@iamnoah
Copy link
Owner Author

iamnoah commented Oct 13, 2014

Lens Laws:

 * 1. You get back what you put in.
    l.get(l.set(o, v)) === v

Passes

 * 2. Putting back what you got doesn't change anything:        
    l.set(o, l.get(o)) === o

Violates this one. o will be changed as the value will now be set.

 * 3. Setting twice is the same as setting once:
    l.set(l.set(o, v) v2) === l.set(o, v2)

Passes.

@iclanzan
Copy link

Putting back what you got doesn't change anything
Violates this one. o will be changed as the value will now be set.

Could be solved by having a setter that sets the value to undefined if the default is being set, right?

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

No branches or pull requests

2 participants