title: Haskell/HSpec: Understanding error message
body: <p>I have the following function that is supposed to return the last but one element of a list:</p>
  
  <pre><code>myButLast :: [a] -&gt; a
  myButLast [] = error "List has less than one element!"
  myButLast [x] = error "List has less than one element!"
  myButLast [x,_] = x
  myButLast (_:xs) = myButLast xs
  </code></pre>
  
  <p>It works for all special cases when I load it into <code>ghci</code>, but when I try to test it using <code>HSpec</code>, I get an error when running this spec:</p>
  
  <pre><code>main :: IO ()
  main = hspec $ do
  
    describe "myButLast" $ do
  
      -- removed other specs --
  
      it "throws an error when called with a singleton list" $
        myButLast [1] `shouldThrow` anyErrorCall
  </code></pre>
  
  <p>This is the error message:</p>
  
  <pre><code>No instance for (Num (IO a0)) arising from the literal `1'
      Possible fix: add an instance declaration for (Num (IO a0))
      In the expression: 1
      In the first argument of `myButLast', namely `[1]'
      In the first argument of `shouldThrow', namely `myButLast [1]'
  </code></pre>
  
  <p>Interestingly, the compiler does not complain when test <code>myButLast []</code> instead of <code>myButLast [1]</code>, although the results of both expressions are defined exactly the same.</p>