julien-truffaut/Monocle — pull request #112 by adamw (2014-08-07 11:47:05+00:00)
Title: Exploring another option on defining lenses through macros

Hello,

I read about the addition of a macro annotation to define lenses today, and I'd like to propose one more alternative to creating lenses with macros.

The basic syntax is:

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

object Person extends LensSupport[Person] {
val name = lensFor(_.name)
val age = lensFor(_.age)
}
````

The main advantage of such a syntax is that it's IDE-friendly (everything can be auto-completed, including the name of the field, unlike in `mkLens`). You also don't have to repeat the name of the type (`Person`), for which the lens are created, as in `mkLens`.

The downside is that there needs to be some container object which extends `LensSupport` (through which the main type is captured).

What do you think?