title: Default instance implementations with "overlaps"
body: <p>I get error:</p>
  
  <pre><code> Duplicate instance declarations:
     instance [overlap ok] EnumTag a =&gt; Read a
       -- Defined at /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/intero/intero2932Xpa-TEMP.hs:110:27
     instance [overlap ok] StrTag a =&gt; Read a
       -- Defined at /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/intero/intero2932Xpa-TEMP.hs:121:27 (intero)
  </code></pre>
  
  <p>For this code:</p>
  
  <pre><code>class (Show a, Enum a) =&gt; EnumTag a where
    anyEnum :: a
  
  instance {-# OVERLAPS #-} EnumTag a =&gt; Read a where
    readPrec = RP.lift P.skipSpaces &gt;&gt; expectEnum
  instance {-# OVERLAPS #-} EnumTag a =&gt; Eq a where
    a == b | a == anyEnum || b == anyEnum = True
           | otherwise = fromEnum a == fromEnum b
  
  class StrTag a where
    anyStr :: a
    tagPrefix :: a -&gt; String -- ^ should be constant
    toStr :: String -&gt; a
  
  instance {-# OVERLAPS #-} StrTag a =&gt; Read a where
    readPrec = parens $ do
      RP.lift P.skipSpaces
      (RP.lift $ expectShown anyStr) &lt;++ RP.lift g
      where g = do
              Just s@(_:_) &lt;- L.stripPrefix tagPrefix &lt;$&gt; expectTag
              return $ toStr s
  </code></pre>
  
  <p>Why does it happen? <code>Read a</code> in 1st instance is valid only when <code>a</code> is <code>EnumTag</code>, in 2nd one - is valid only when <code>a</code> is <code>StrTag</code>.</p>
  
  <p>How can I fix this error and to create "default" instances for <code>EnumTag</code> and to <code>StrTag</code>, so client code will "inherit" those functionality (Read) simple, only with instantiation of <code>EnumTag</code> or <code>StrTag</code> ?</p>