title: Type error with rank-n types and lenses
body: <p>I have a simple polymorphic datatype <code>Foo</code></p>
  
  <pre><code>{-# LANGUAGE TemplateHaskell #-}
  import Control.Lens
  
  data Foo c = 
      Foo {
          _bar :: c,
          _baz :: c,
          _quux :: c
      }   
  
  makeLenses ''Foo
  </code></pre>
  
  <p>The generated lenses are, of course, polymorphic in <code>c</code>. The type from GHCi is:</p>
  
  <pre><code>*Main&gt; :t bar
  bar :: Functor f =&gt; (c0 -&gt; f c0) -&gt; Foo c0 -&gt; f (Foo c0)
  </code></pre>
  
  <p>I made a datatype <code>Blah</code> to wrap around the lens. This works fine in simple cases (with the <code>RankNTypes</code> extension, of course):</p>
  
  <pre><code>data Blah = Blah (forall c . Lens' (Foo c) c)
  
  orange :: Blah
  orange = Blah bar
  </code></pre>
  
  <p>But anything slightly more complicated doesn't work, for example</p>
  
  <pre><code>cheese :: [Blah]
  cheese = map Blah [bar]
  </code></pre>
  
  <p>This last piece of code gives an error from GHC:</p>
  
  <pre><code>    Couldn't match type ‘(c0 -&gt; f0 c0) -&gt; Foo c0 -&gt; f0 (Foo c0)’
                    with ‘forall c (f :: * -&gt; *).
                          Functor f =&gt;
                          (c -&gt; f c) -&gt; Foo c -&gt; f (Foo c)’
      Expected type: ((c0 -&gt; f0 c0) -&gt; Foo c0 -&gt; f0 (Foo c0)) -&gt; Blah
        Actual type: (forall c. Lens' (Foo c) c) -&gt; Blah
      In the first argument of ‘map’, namely ‘Blah’
      In the expression: map Blah [bar]
  </code></pre>
  
  <p>It seems like the <code>forall c f .</code> has disappeared from <code>‘(c0 -&gt; f0 c0) -&gt; Foo c0 -&gt; f0 (Foo c0)’</code> but I don't understand why.</p>
  
  <p>Why does this not compile, and what can I do to get something like this to work?</p>