Hi, I have a question regarding Optics I was readi...
# arrow
m
Hi, I have a question regarding Optics I was reading https://arrow-kt.io/docs/optics/dsl/ and wanted to try the first examle (Street, Address, Company, Employee data classes) but it doesn't work as in the documentation. When I leave the example as is, I get the error:
error: @optics annotated class com.example.Player needs to declare companion object.
In my build.gradle I added the following dependencies:
Copy code
implementation("io.arrow-kt:arrow-optics:0.13.2")
    kapt("io.arrow-kt:arrow-meta:0.13.2")
Am I doing something wrong or is this just missing in the example code snippet? In this question https://stackoverflow.com/questions/58243913/arrowkt-optics-annotation-not-generating-code they use arrow 0.10.0 and here it is still required and it looks to me, that back then it was still in the documentaion. So I would guess, that the companion object isn't required anymore in 0.13.2. Or am I wrong?
s
AFIK the companion object is still required, the optics functions are added as an extension function to the companion object.... annotation processors can't create one if it doesn't exist (limitation by Kotlin)
s
Yes, that’s correct. Hopefully soon with proper compiler plugins we can provide a large and powerful synthetic api with a super lean binary.
m
ahh .. alright .. might not be bad to add this to the documentation. It just felt so wrong to change an example from the documentation when you just start something new!
s
100% agreed! We try to prevent this all over the Arrow documentation. Which pages did you encounter this on?
m