title: How do you match against the type "Either a b"?
body: <p>The purpose for this particular portion of code is to make the <code>size</code> function more efficient than simply counting all the elements in <code>elems</code>.  I've settled on summing the two types that make up the list, but I can't seem to create the signature of the size function.</p>
  
  <pre><code>instance (Finite a, Finite b) =&gt; Finite (Either a b) where
      elems = combineLists [Left x | x &lt;- elems] [Right x | x &lt;-elems]
      size ??? = (size a) + (size b)
  </code></pre>
  
  <p>From Prelude, we know that <code>Either a b = Left a | Right b</code>.</p>
  
  <p>The first thing I tried was to match <code>Either</code>, but of course it is a type, so that doesn't work.  Next, I tried <code>((Left a) | (Right b))</code>, but no go on that either. Nothing else seems to match the type <code>Either a b</code>.</p>
  
  <p>I was able to get <code>size (Left a)</code> to compile, but since it's missing the <code>b</code> component, I receive the error: </p>
  
  <pre><code>Ambiguous type variable `b' in the constraint:
    `Finite b' arising from a use of `size' at &lt;interactive&gt;:1:0-12
  </code></pre>
  
  <p>which of course makes sense in the context, but I really have no clue how to match <code>Either a b</code>.</p>
  
  <p>Anybody have any thoughts?</p>