Another optics question. Prism related.
I have a class such as this:
Copy code
@optics
sealed class Person {
abstract val name: String
@optics
data class Lazy(override val name: String, val days: Int) : Person()
@optics
data class Working(override val name: String, val hours: Int) : Person()
}
And a function to set the name
Copy code
fun setName(person: Person): Person {
return Person.lazy.name.set(
Person.working.name.set(person, newName),
newName
)
}
Is this the best solution, or can I use some nice trick here in