title: Lenses and prisms with sum types
body: <p>This code won't compile.</p>
  
  <pre><code>{-# LANGUAGE TemplateHaskell #-}
  
  import Control.Lens
  
  data A = A { _a1 :: B, _a2 :: Int }
  makeLenses ''A
  
  data B = B1 { _b1 :: Int } | B2
  makeLenses ''B
  </code></pre>
  
  <p>The error is <code>amy.hs:5:21: Not in scope: type constructor or class ‘B’</code>. I have two questions.</p>
  
  <ol>
  <li>Is there a way to do something like this, or do I need to write my own lenses for <code>B</code>?</li>
  <li>Given an <code>A</code>, I would like to apply a function to the <code>b1</code> field, if that field exists. I think this is a job for prisms, but I haven't figured out how to do it.</li>
  </ol>