title: Haskell filtering a nested list with data constructors
body: <p>Let's say I have the following data type</p>
  
  <pre><code>data Number = Positive Integer | Negative Integer
       deriving (Eq, Show)
  </code></pre>
  
  <p>I have a function definition of (NOTE THAT I CANNOT CHANGE THIS DEFINITION, OR WORK AROUND IT IN ANY WAY. I have to work with the nested list and modify it in some way)</p>
  
  <pre><code>removePos :: [[Number]] -&gt; [[Number]]
  </code></pre>
  
  <p>So we have a nested list of Number. An example would be</p>
  
  <pre><code>[[Positive 1, Negative 1], [Positive 2, Negative 2, Positive 1], [Positive 1]]
  </code></pre>
  
  <p>How can I write removePos so that it removes all lists in the nested list that contain Positive x, where x is A SPECIFIC Integer? The function is essentially looking at the first element in the first list, if it is Positive then remove all lists that contain Positive x.</p>
  
  <p>Essentially, if we took a look at the example above, the output would be</p>
  
  <pre><code>[[]]
  </code></pre>
  
  <p>Note that the user performs the following function call</p>
  
  <pre><code>removePos [[Positive 1, Negative 1], [Positive 2, Negative 2, Positive 1], [Positive 1]]
  </code></pre>
  
  <p>Since each list in the nested list above contains Positive 1, the output is simply an empty nested list (All lists with Positive x are removed). However, if the first element in the first list was Positive 10, the output would be</p>
  
  <pre><code>[[Positive 2, Negative 2, Positive 1], [Positive 1]]
  </code></pre>
  
  <p>(Because the first list would have [Positive 10, Negative 1], which would get removed)</p>
  
  <p>Any ideas?</p>
  
  <p>EDIT:</p>
  
  <p>For further examples, lets say I have a basket with bowls of fruits in it. The basket is the nested list, the bowls are lists within it. Now, I take a look in the basket. I check the first bowl. I look at the first fruit in the bowl, and determine that I don't want to eat that fruit from any of the bowls. So I throw out all bowls that contain that fruit, and give you back your basket.</p>