-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
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.
joshuaconner