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
So naturally now I want to be able to use typical optic compositions on the results.
This won't be able to replace the @optics annotation since it can't derive the equivalent Setter-type lenses, but it would make it easier to create optics on non-constructor parameters of data classes.
That's a great idea, and a great addition to Optics! If you're up for adding your snippet in a small PR that'd be awesome.
(because Getter is a functional interface?):
Since Getter<S, A> is a functional interface it matches anything of the shape (source: S) -> A. fun interface works like @FunctionalInterface in Java where you can pass anything of the same shape of the single abstract method.
@magneticflux- since some time we have an arrow-optics-reflect which allows turning any KProperty into a lens. If you have time to have a look and give feedback, that would be awesome!
What version are you currently using?
0.13.2
What would you like to see?
Having extension functions similar to the existing ones like
Getter<A,B> + Getter<B,C> -> Getter<A,C>
would be super handy.I found out that this code works (because
Getter
is a functional interface?):So naturally now I want to be able to use typical optic compositions on the results.
This won't be able to replace the
@optics
annotation since it can't derive the equivalentSetter
-type lenses, but it would make it easier to create optics on non-constructor parameters of data classes.I am currently using this snippet:
The text was updated successfully, but these errors were encountered: