title: What is the difference between Pattern Matching and Guards?
body: <p>I am very new to Haskell and to functional programming in general. My question is pretty basic. What is the difference between Pattern Matching and Guards?</p>
  
  <p><strong>Function using pattern matching</strong></p>
  
  <pre><code>check :: [a] -&gt; String
  check [] = "Empty"
  check (x:xs) = "Contains Elements"
  </code></pre>
  
  <p><strong>Function using guards</strong></p>
  
  <pre><code>check_ :: [a] -&gt; String
  check_ lst
      | length lst &lt; 1 = "Empty"
      | otherwise = "Contains elements"
  </code></pre>
  
  <p>To me it looks like Pattern Matching and Guards are fundamentally the same. Both evaluate a condition, and if true will execute the expression hooked to it. Am I correct in my understanding?</p>
  
  <p>In this example I can either use pattern matching or guards to arrive at the same result. But something tells me I am missing out on something important here. Can we always replace one with the other?</p>
  
  <p>Could someone give examples where pattern matching is preferred over guards and vice versa? </p>