Open kenbot opened 7 years ago
@kenbot what's the get
in your example? Shouldn't it be x
as Some
is defined like:
final case class Some[+A](x: A) extends Option[A]
Get/set modes generate minimal getter/setter structure respectively. It just generates Getter(_.zeroArgMethod)
. They can get away with this because the use case is known; lens mode (or GenLens for that matter) need full lenses because the usecase is unknown.
Fwiw, per #26, lens mode will also auto-gen Isos where it can, eg single arg case classes.
Oh wait, my example is performing a set! That's clearly wrong.
Fixed, thanks.
In the same way that the
.name
syntax automatically navigates case-class-like fields with Lenses, it should be able to navigate ADTs insealed
class hierarchies with Prisms. This should be possible withgetKnownDirectSubclasses
.But using what syntax? We could use the name of the subclass, where it looks for a field by that name first, then looks for a subclass name:
Is that obvious enough to justify "you already know how to use it"? What else could it be?