title: GHC Prefer one specialization over another
body: <p>I have a Haskell typeclass function that looks like the following:</p>
  
  <pre><code>class Foo m where
     foo :: Num a =&gt; m a -&gt; a
  </code></pre>
  
  <p>I want to generate two specializations of <code>foo</code>, one for anytime that <code>m ~ X Int</code> and the other when <code>m ~ X Int, a ~ Int</code>. I wrote the following code for this:</p>
  
  <pre><code>instance Foo (X a) where
     {-# SPECIALIZE instance Foo (X Int) #-}
     foo = ...
     {-# SPECIALIZE foo :: X Int Int -&gt; Int #-}
  </code></pre>
  
  <p>From what I can tell, in the file that contains this code I am getting both specializations. However, in the module that is using <code>Foo</code> it seems to always point to the <em>less generic</em> specialization, i.e. <code>foo :: Num a =&gt; X Int a -&gt; a</code> even when <code>a ~ Int</code>.</p>
  
  <p>Is there a way to tell GHC to prefer the most specialized version of <code>foo</code> rather than the partially specialized version?</p>
  
  <p>Thanks.</p>