title: Haskell declaring an instance of Show class
body: <p>I am trying to wrap my mind around classes and data structures in Haskell, specifically declaring a type instance of it. I can get it to work with some classes and data types but not all of them so I must be missing something. Specifically I have the following data declaration:</p>
  
  <pre><code>data LinkedList a = End | Link a (LinkedList a)
  </code></pre>
  
  <p>I want to declare an instance of Show for that type so that the output looks something close to "el1, el2, el3, el4, ..."</p>
  
  <pre><code>instance Show LinkedList where
      show (End) = "."
      show (Link a b) = show a ++ "," ++ show b
  </code></pre>
  
  <p>As expected this doesn't work... Any idea why? I think I understand what "data" and "type" mean but I am not sure whether I am comfortable with classes and instances. Thank you</p>