title: Predicate application on an argument for Haskell pattern matching
body: <p>I am developing a function in Haskell whose argument is a list of pairs. Recursively, this list will be split further until a base case is satisfied based on a predefined predicate.  Usually, for simpler data types e.g. lists , literals could be used for base case matching, such as '[ ]'. How can I apply pattern matching using a boolean predicate?  </p>
  
  <p>The only way I came up with is using if else statement. But apparently this would lead to obvious problem.</p>
  
  <p>The pattern</p>
  
  <pre><code>pure_instances [(_,_)] = True
  pure_instances ((c1,_):(c2,attrs):xs) = (c1 == c2) &amp;&amp; (pure_instances ((c2,attrs):xs))
  </code></pre>
  
  <p>The method</p>
  
  <pre><code>build_tree list  = if (pure_instances list) then (Leaf get_label list) else (build_tree list) 
  build_ tree list = ...
  </code></pre>