title: Couldn't match expected type `a' with actual type `[a]'
body: <p>I was able to execute the following code flawlessly</p>
  
  <pre><code>myLast :: [a] -&gt; a
  myLast [] = error "Can't call myLast on an empty list!"
  myLast (x:_) = x
  </code></pre>
  
  <p>but I'm getting this error <code>Couldn't match expected type `a' with actual type `[a]'. `a' is a rigid type variable bound by the type signature for myLast :: [a] -&gt; a</code> for the following code:</p>
  
  <pre><code>myLast :: [a] -&gt; a
  myLast [] = error "Can't call myLast on an empty list!"
  myLast (_:x) = x
  </code></pre>
  
  <p>I'm a beginner in Haskell and the error message is too greek and latin for me. From what I can understand, the compiler is not able infer the type in the second case. Can someone point me to what is actually happening here?</p>