title: Haskell type classes hierarchy
body: <p>I have 2 classes:</p>
  
  <pre><code>class (IsColor (ColorType a)) =&gt; ColorList a where
      type ColorType a :: *
      foreground :: a -&gt; (ColorType a)
      background :: a -&gt; (ColorType a)
  
  class (ColorList (ThemeColorList a)) =&gt; Theme a where
      type ThemeColorList a :: *
      renderTheme :: a -&gt; b
  </code></pre>
  
  <p>I have function dosomething with type signature:</p>
  
  <pre><code> dosomething :: (IsColor a) =&gt; a -&gt; Int
  </code></pre>
  
  <p>I define instance of Theme class for data type SimpleTheme:</p>
  
  <pre><code>data SimpleTheme a = SimpleTheme a
  
  instance (ColorList a) =&gt; Theme (SimpleTheme a) where
      type ThemeColorList (SimpleTheme a) = a
      renderTheme theme = dosomething $ background theme
  </code></pre>
  
  <p>If in renderTheme I do something with background or foreground, I get compilation error:</p>
  
  <pre><code>Could not deduce (IsColor (ColorType (SimpleTheme a)))
        arising from a use of ‘dosomething’
      from the context (ColorList (ThemeColorList (SimpleTheme a)),
                        ColorList a)
        bound by the instance declaration at
  </code></pre>
  
  <p>How to solve problem?</p>