mbrandonw
01/27/2020, 2:25 PM@optics
to generate optics for generic data classes and sealed classes. The generated code has compiler errors. 1) is this right? and 2) are there alternatives to this besides writing the optics by hand?mbrandonw
01/27/2020, 9:16 PMpakoito
01/27/2020, 9:32 PMmbrandonw
01/27/2020, 10:07 PMsimon.vergauwen
01/28/2020, 6:54 AM@optics
myself yesterday successfully on 0.10.4
.
Could you provide some more details on the compile errors? Did you add a companion object
to all your data classes
and sealed classes
? Those markers need to be present to generate the code, and I saw yesterday the compile error was surrounded by other Gradle message, we should probably show a header or some whitelines around it to make it better visual.mbrandonw
01/28/2020, 1:59 PMmbrandonw
01/28/2020, 4:10 PM@optics
data class Foo<A>(
val value: A,
val timestamp: Int
) {
companion object
}
generates an optic that looks like this:
inline val `com`.`example`.`search_popular`.`Foo`.Companion.iso: arrow.optics.Iso<`com`.`example`.`search_popular`.`Foo`, arrow.core.Tuple2<`A`, `kotlin`.`Int`>> inline get()= arrow.optics.Iso(
get = { foo: `com`.`example`.`search_popular`.`Foo` -> arrow.core.Tuple2(foo.`value`, foo.`timestamp`) },
reverseGet = { tuple: arrow.core.Tuple2<`A`, `kotlin`.`Int`> -> `com`.`example`.`search_popular`.`Foo`(tuple.a, tuple.b) }
)
which does not properly give Foo
its generic.
are optics for generic types supposed to work?simon.vergauwen
01/29/2020, 8:05 AM@optics
for polymorphic products or sum typesmbrandonw
01/29/2020, 1:44 PMsimon.vergauwen
01/31/2020, 9:05 AMkapt
.
With Arrow-meta and the full Kotlin compiler support we can more easily also derive these more complex optics. So hopefully later this year we can support polymorphic optics automatically.mbrandonw
01/31/2020, 1:38 PM