ducktape icon indicating copy to clipboard operation
ducktape copied to clipboard

Make configurations more lens-like

Open arainko opened this issue 1 year ago • 0 comments

Right now if we try to do this:

case class Person(age: Int, name: String)

Person(1, "Joe").into[Person].transform(Field.const(_.age, 23))

we'd be greeted with a pretty cryptic error due to the fact that underneath the covers the plan derived for a Person to Person transformation is actually just an identity (i.e. ducktape doesn't create a new Person from the ground up since that'd be wasteful).

We could actually support that use case if we were to derive a lazy 'alternative' plan when encountering an identity transformation which could then be used when traversing the plan in PlanConfigurer which would basically replace the identity transformation with the fallback plan.

arainko avatar Jul 06 '24 10:07 arainko