rt
05/29/2020, 2:16 PMraulraja
05/29/2020, 3:42 PMraulraja
05/29/2020, 3:42 PMrt
05/29/2020, 4:02 PMimport arrow.optics.optics
import arrow.optics.dsl.*
@optics data class G<A>(val x: A) {
companion object
}
@optics data class X(val x: Int) {
companion object
}
fun main() {
val gx = G<X>.x.x
}
fails with
e: G$$optics.kt: (7, 112): One type argument expected for class G<A>
where generated code is e.g.
inline val `G`.Companion.iso: arrow.optics.Iso<`G`, `A`> inline get()= arrow.optics.Iso(
get = { g: `G` -> g.x },
reverseGet = { `G`(it) }
)
Should i file an issue?rt
05/29/2020, 4:03 PMrt
05/29/2020, 4:09 PMdata class G<A>(val a: A) {
companion object {
fun <A> a(): Lens<G<A>, A> = Lens(
{ it.a },
{ ga, xx -> ga.copy(a = xx) }
)
}
}
@optics data class X(val x: Int) {
companion object
}
fun main() {
assert(G.a<X>().compose(X.x).get(G(X(1))) == 1)
}
so i guess i'm OK since i can type in the boilerplate once (for the "higher-kinded" adt). I mean, once per every field, which is still unfortunate but i guess meh, I can live with that 🙂raulraja
05/29/2020, 4:15 PMraulraja
05/29/2020, 4:15 PMraulraja
05/29/2020, 4:16 PMrt
05/29/2020, 4:16 PMraulraja
05/29/2020, 4:16 PMraulraja
05/29/2020, 4:17 PMrt
05/29/2020, 4:17 PMrt
05/29/2020, 4:18 PMrt
05/29/2020, 4:18 PMsimon.vergauwen
05/29/2020, 5:27 PMkapt
and its complexity.
This is something I’d really love to support using compiler plugins!raulraja
05/29/2020, 5:51 PM