title: Can I specialize a Foldable instance method based on the typeclass of a?
body: <p>I have a <code>Foldable</code> container for <code>a</code>s. One of the methods provided by the <code>Foldable</code> typeclass in <code>BasicPrelude</code> is <code>elem :: (Eq a) =&gt; a -&gt; t a -&gt; Bool</code>. Now, for my container, I can implement <code>elem</code> more efficiently than the default provided that my <code>a</code> is an <code>Ord</code> instance, but only in that case.</p>
  
  <p>Now, I would like to have the more efficient <code>elem</code> available if possible, preferably with the same signature (i.e. 'transparently'). However, I can only see one way of doing this, which is to require an <code>(Ord a)</code> constraint on the <code>Foldable</code> instance for my container, which makes no sense in the general case. </p>
  
  <p>Is it possible for me to have a specialized <code>elem</code> only for cases where <code>a</code> is an <code>Ord</code>, and a general <code>elem</code> for others somehow? I don't mind use of GHC extensions if that's what it takes.</p>