kenbot / goggles

Pleasant, yet principled Scala optics DSL
MIT License
195 stars 7 forks source link

lens mode .name should generate Isos where possible #26

Open kenbot opened 7 years ago

kenbot commented 7 years ago

Using the .name syntax, get and set modes generate the most general possible optics, Getters and Setters respectively. This means that more code can participate, such as no-arg methods with no copy method. Because we already know what we want to do with it (ie "get", "set"), there is no need for more capable optics to be selected.

Conversely, lens mode produces an optic; we don't know how the user will use it. Therefore, we should choose maximally capable, specific optics, rather than constrained generic ones. Currently, Lenses will be generated.

In lens mode, where a target value is known to be isomorphic to the source object (ie a one-argument case class), then an Iso should be generated instead of a Lens.

kenbot commented 7 years ago

Descoping from 1.1; it's not urgent, and it is still uncertain how much work it might entail.