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

Support for unapplied get/set? #33

Open
kenbot opened this issue Mar 19, 2017 · 0 comments
Open

Support for unapplied get/set? #33

kenbot opened this issue Mar 19, 2017 · 0 comments
Labels

Comments

@kenbot
Copy link
Owner

kenbot commented Mar 19, 2017

A common Monocle idiom, currently unsupported by Goggles, is composing lens set/modify expressions before the object is applied. This returns an endofunction, with pleasing compositional properties. For instance:

val x: Item => Item = itemQtyLens.modify( _ + 1) andThen itemPriceLens.set(4)

It also aligns with the common FP intuition of "compose first, many times; execute last, once".

Is there some way to support this idiom in get/set modes without making everything weird and complicated? One way might be to allow a from[MyType] type hint (as per #31) in the left-most position instead of the source object, which would return an endofunction rather than the usual result. This might prove a confusing special case though.

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

No branches or pull requests

1 participant