title: Idiomatic way to do conditional list comprehension
body: <p>I just started learning Haskell and I can't seem to find a good solution to create a list conditionally.</p>
  
  <p>Basically, what I want is to do list comprehension with an <code>if/else</code> but without the <code>else</code> part. I am certain this is possible, I guess I am just using the wrong keywords on my googling quest.</p>
  
  <p>A very stupid example in Python which I want to Haskellize:</p>
  
  <pre class="lang-py prettyprint-override"><code>[x for x in range(11) if x &gt; 5]
  </code></pre>
  
  <p>In Haskell, as far as I understand we cannot omit <code>else</code> blocks like I did in the Python example. How should I do something like this? Does something like <em>nothing</em> exists which I can add to the <code>else</code>-block in list comprehension, like so:</p>
  
  <pre class="lang-hs prettyprint-override"><code>[if x &gt; 5 then x else Nothing | x &lt;- [0..10]]
  </code></pre>
  
  <p>I actually came across <em>Nothing</em> in Haskell, though I haven't figure it out yet. It certainly doesn't seem to do what I hoped. Basically I don't want an <code>else</code> in my list comprehension, but if it's a necessary evil I want to insert nothing in the <code>else</code> block.</p>
  
  <p>I can think of a bunch of hacks to get similar functionality very inefficiently:</p>
  
  <ul>
  <li><code>filter</code> the list after creating it, e.g. <code>filter (&gt;5) [0..10]</code></li>
  <li>create a list of lists using list comprehension, for which I can create an empty list in the else block and then <code>concat</code> them, e.g. <code>concat [if x &gt; 5 then [x] else [] | x &lt;- [0..10]]</code></li>
  </ul>
  
  <p>These ideas all seem <em>really</em> ugly, though. </p>
  
  <p><sub>Ofcourse in practice I don't want to create conditional lists with such trivial conditions.</sub></p>