title: Filter an infinite list of monadic values
body: <p>Perhaps this is obvious, but I can't seem to figure out how to best filter an infinite list of IO values. Here is a simplified example:</p>
  
  <pre><code>infinitelist :: [IO Int]
  
  predicate :: (a -&gt; Bool)
  
  -- how to implement this?
  mysteryFilter :: (a -&gt; Bool) -&gt; [IO a] -&gt; IO [a]
  
  -- or perhaps even this?
  mysteryFilter' :: (a -&gt; Bool) -&gt; [IO a] -&gt; [IO a]
  </code></pre>
  
  <p>Perhaps I have to use <code>sequence</code> in some way, but I want the evaluation to be lazy. Any suggestions? The essence is that for each <code>IO Int</code> in the output we might have to check several <code>IO Int</code> values in the input.</p>
  
  <p>Thank you!</p>