You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
The text was updated successfully, but these errors were encountered:
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.The text was updated successfully, but these errors were encountered: