title: Haskell- find element in a list
body: <p>I want to write a function that takes a number <code>i</code> and a list of numbers <code>xs</code> and
  returns the position of <code>i</code> in the list <code>xs</code>, counting the first position as 1. If <code>i</code> does
  not occur in <code>xs</code>, then <code>position</code> returns 0.</p>
  
  <p>So far I have this:</p>
  
  <pre><code>import Data.List
  position :: Int -&gt; [Int] -&gt; Int
  position i xs 
     | i `elem` xs = i `elemIndex` xs
     | otherwise = 0
  </code></pre>
  
  <p>But when I compile, it gives the following error:</p>
  
  <blockquote>
    <p>Couldn't match expected type ‘Int’ with actual type ‘Maybe Int’</p>
  </blockquote>
  
  <p>I know that <code>elemIndex</code> returns a <code>Maybe Int</code> type and I defined my function to return <code>Int</code> but I don't know how to change it. Any ideas?</p>