title: Get the element at index "elemIndex" in a list
body: <p>Basically I'm trying to get the n'th element in a list using the value from the <code>elementIndex</code> function.
  Here is my code:</p>
  
  <pre><code>import Data.List
  import Data.Maybe
  
  names = ["Molly", "Jack", "Perrie", "Adele", "Jake", "Lily", "Lawrence", "Ethan"] :: [String]
  ages = [5,1,8,9,6,4,7,3] :: [Int]
  
  getAge :: String -&gt; [String] -&gt; [Int] -&gt; Maybe Int
  getAge name names ages = getIntAtIndex index ages
      where
          index = elemIndex name names
  
  getIntAtIndex :: Maybe Int -&gt; [Int] -&gt; Maybe Int
  getIntAtIndex n [] = Nothing
  getIntAtIndex n (x:xs)
          | (isNothing n) or (n &lt; 0) = Nothing
          | n == 0 = Just x
          | otherwise = getIntAtIndex (n-1) xs
  </code></pre>
  
  <p><code>getAge</code> searches a <code>name</code> in <code>names</code> and returns the age from the same <code>index</code> in <code>ages</code>.
  but when I try to load the file in <code>ghci</code> I get:</p>
  
  <pre><code>Prelude&gt; :l test.hs
  [1 of 1] Compiling Main             ( test.hs, interpreted )
  
  test.hs:15:11:
      Couldn't match expected type `(t0 Bool -&gt; Bool) -&gt; Bool -&gt; Bool'
                  with actual type `Bool'
      The function `isNothing' is applied to three arguments,
      but its type `Maybe Int -&gt; Bool' has only one
      In the expression: (isNothing n) or (n &lt; 0)
      In a stmt of a pattern guard for
                     an equation for `getIntAtIndex':
        (isNothing n) or (n &lt; 0)
  Failed, modules loaded: none.
  </code></pre>
  
  <p>I've already tried the <code>!! operator</code> but it only accepts Int, so I added the function <code>getIntAtIndex</code> in order to acheive this.
  Could someone point me where is the error? Because I can't see it.</p>
  
  <p>I would expect <code>getAge "Jack" names</code> to return <code>1</code> and <code>getAge "Bill" names</code> to return <code>Nothing</code></p>
  
  <p>Thanks</p>