title: Finding maximum element in a list of tuples
body: <p>I am a complete beginner in Haskell. I have a list of tuples that I'm using in Haskell: the structure is like this <code>[(a,b),(c,d),(e,f),(g,h)]</code></p>
  
  <p>What I want is to return the maximum element in this tuple according to the second value:
  So if the list of tuples is <code>[(4,8),(9,10),(15,16),(10,4)]</code>, I want the maximum element to be <code>(15,16)</code>.</p>
  
  <p>But I have no idea how to do this. This is my attempt so far, </p>
  
  <pre><code>maximum' ::  (Ord a) =&gt; (Num a) =&gt; [(a,b)] -&gt; a  
  maximum' [] = error "maximum of empty list"  
  maximum' [(x,y)] = -1
  maximum' (x:xs)   
    | snd x &gt; snd(xs !! maxTail) = 0
    | otherwise = maxTail  
    where maxTail = maximum' xs + 1
  </code></pre>
  
  <p>And I get this error message which makes no sense for me:</p>
  
  <pre><code>newjo.hs:23:25:
  Could not deduce (a ~ Int)
  from the context (Ord a, Num a)
    bound by the type signature for
               maximum' :: (Ord a, Num a) =&gt; [(a, b)] -&gt; a
    at newjo.hs:19:14-47
    `a' is a rigid type variable bound by
        the type signature for maximum' :: (Ord a, Num a) =&gt; [(a, b)] -&gt; a
        at newjo.hs:19:14
  In the second argument of `(!!)', namely `maxTail'
  In the first argument of `snd', namely `(xs !! maxTail)'
  In the second argument of `(&gt;)', namely `snd (xs !! maxTail)'`
  </code></pre>
  
  <p>I need some help on how to do this.</p>