title: Using Shapeless lenses to group by arbitrary field
body: <p>I am trying to learn Shapeless. I have created a very simple case class:</p>
  
  <pre><code>case class Holding(ticker: String, assetClass: String, units: Double, mktValue: Double)
  </code></pre>
  
  <p>I would like to be able to group on any arbitrary field, i.e. ticker or assetClass on a list of Holdings and sum on units and mktValue.</p>
  
  <p>This works:</p>
  
  <pre><code>val map = list.groupBy(lens[Holding] &gt;&gt; 'assetClass)
  </code></pre>
  
  <p>So, does this:</p>
  
  <pre><code>val mapped = Map( 'assetClass -&gt; (lens[Holding] &gt;&gt; 'assetClass), 'ticker -&gt; (lens[Holding] &gt;&gt; 'ticker))
  
  def makeLens(sym: Symbol) = {
     mapped.get(sym).get
  }
  
  val map = list.groupBy(makeLens('assetClass).get)
  </code></pre>
  
  <p>Creating a map to hold the lenses does not seem to follow the spirit of the 'scrap your bolierplate' approach. Is there  any way to do this:</p>
  
  <pre><code>val sym = 'assetClass
  val map = list.groupBy(lens[Holding] &gt;&gt; sym)
  </code></pre>
  
  <p>I need to be able to define a method as generically as possible that takes an arbitrary symbol and groups the list. Is that possible?</p>