title: Guards vs. if-then-else vs. cases in Haskell
body: <p>I have three functions that find the nth element of a list:</p>
  
  <pre><code>nthElement :: [a] -&gt; Int -&gt; Maybe a 
  nthElement [] a = Nothing
  nthElement (x:xs) a | a &lt;= 0 = Nothing
                      | a == 1 = Just x
                      | a &gt; 1 = nthElement xs (a-1)
  
  nthElementIf :: [a] -&gt; Int -&gt; Maybe a
  nthElementIf [] a = Nothing
  nthElementIf (x:xs) a = if a &lt;= 1
                          then if a &lt;= 0 
                               then Nothing
                               else Just x -- a == 1
                          else nthElementIf xs (a-1)                           
  
  nthElementCases :: [a] -&gt; Int -&gt; Maybe a
  nthElementCases [] a = Nothing
  nthElementCases (x:xs) a = case a &lt;= 0 of
                               True -&gt; Nothing
                               False -&gt; case a == 1 of
                                          True -&gt; Just x
                                          False -&gt; nthElementCases xs (a-1)
  </code></pre>
  
  <p>In my opinion, the first function is the best implementation because it is the most concise. But is there anything about the other two implementations that would make them preferable? And by extension, how would you choose between using guards, if-then-else statements, and cases?</p>