title: How to extract terms of specific data constructor from a list in Haskell
body: <p>A common problem I got in Haskell is to extract all terms in a list belonging to a specific data constructor and I'm wondering if there are any better ways than the way I'm doing it at the moment.</p>
  
  <p>Let's say you got</p>
  
  <pre><code>data Foo = Bar | Goo
  </code></pre>
  
  <p>, the list</p>
  
  <pre><code>foos = [Bar, Goo, Bar, Bar, Goo]
  </code></pre>
  
  <p>and wish to extract all <code>Goo</code>s from <code>foos</code>. At the moment I usually do something like</p>
  
  <pre><code>goos = [Goo | Goo &lt;- foos]
  </code></pre>
  
  <p>and all is well. The problem is when <code>Goo</code> got a bunch of fields and I'm forced to write something like</p>
  
  <pre><code>goos = [Goo a b c d e f | Goo a b c d e f &lt;- foos]
  </code></pre>
  
  <p>which is far from ideal. How you do usually handle this problem?</p>