title: Lists of data types: "could not deduce (a ~ SomeType) from the context (SomeTypeclass a)"
body: <p>I have the following problem with Haskell's type system: I am trying to declare a data type and return a list containing elements of this type from a function. Unfortunately, even a minimal testcase such as</p>
  
  <pre><code>data SampleType = SampleTypeConstructor
  
  instance Show SampleType where
      show x = "(SampleType)"
  
  stList :: (Show a) =&gt; [a]
  stList = [(SampleTypeConstructor)]
  
  main = do {
      putStrLn (show stList)
  }
  </code></pre>
  
  <p>fails with the following error message from both ghc-7.0.2 and ghc-7.1.20110327:</p>
  
  <pre><code>tcase.hs:7:12:
      Could not deduce (a ~ SampleType)
      from the context (Show a)
        bound by the type signature for stList :: Show a =&gt; [a]
        at tcase.hs:7:1-34
        `a' is a rigid type variable bound by
            the type signature for stList :: Show a =&gt; [a] at tcase.hs:7:1
      In the expression: (SampleTypeConstructor)
      In the expression: [(SampleTypeConstructor)]
      In an equation for `stList': stList = [(SampleTypeConstructor)]
  </code></pre>