title: Haskell: How to use random integer from randomRIO in a function that returns a boolean
body: <p>I am new to Haskell and i'm having a problem with using the IO Int from randomRIO function. My goal is to get a random Int value, say r, and to return True if r &lt; x or false otherwise, but i don't know how to do it.</p>
  
  <p>my function should look like:</p>
  
  <pre><code>randomCompare :: Int-&gt;Bool
  
  randomCompare x
  
    | x &lt; r = True -- somehow i want to r &lt;- randomRIO(start,end) 
  
    | otherwise = False                
  </code></pre>
  
  <p>I know there is a designed intention with keeping IO vals in context for purity etc.. but i don't see why using a random number for a Boolean function should be "bad".</p>
  
  <p>Thanks.</p>