title: Scala type bounds & variance
body: <p>I am trying to get a better understanding of the following behaviour:</p>
  
  <pre><code>scala&gt; class C[-A, +B &lt;: A]
  &lt;console&gt;:7: error: contravariant type A occurs in covariant position
                      in type &gt;: Nothing &lt;: A of type B
         class C[-A, +B &lt;: A]
                      ^
  </code></pre>
  
  <p>However the following works:</p>
  
  <pre><code>scala&gt; class C[-A, +B &lt;% A]
  defined class C
  </code></pre>
  
  <p>I can see that there could be issues from the variance of the bounding and bounded variables being opposite, though I have am not clear on what the specific problem is.
  I am even less clear on why changing the type bound to a view bound makes things ok. In the absence of applicable implicit conversions I would expect the two definitions to be have largely the same effect. If anything I would expect a view bound to provide more opportunities for mischief.</p>
  
  <p>For a bit of background I defining classes that are in some ways like functions, and I wanted to do something like </p>
  
  <pre><code>CompositeFunc[-A, +B &lt;: C, -C, +D] (f1 : BaseFunc[A, B], f2 : BaseFunc[C, D]) 
    extends BaseFunc[A, D]
  </code></pre>
  
  <p>Arguably </p>
  
  <pre><code>CompositeFunc[-A, +B &lt;% C, -C, +D] (f1 : BaseFunc[A, B], f2 : BaseFunc[C, D]) 
    extends BaseFunc[A, D]
  </code></pre>
  
  <p>is actually preferable, but I would still like to better understand what is going on here.</p>