title: How to use bind (>>=) on function with multiple variables
body: <p>I am a newbie to haskell and functional programming. This might be a very simple thing, but I haven't found an answer while searching.</p>
  
  <p>I have this function main here:</p>
  
  <pre><code>main :: IO ()
  main = print =&lt;&lt; (`rnd_select` 6) =&lt;&lt; readNumbers
  
  readNumbers :: IO [(Int,Int,Int)]
  readNumbers = makeTriples . map rInt . words &lt;$&gt; readFile "somefile"
  
  rInt :: String -&gt; Int
  rInt = read
  
  makeTriples :: [a] -&gt; [(a,a,a)]
  makeTriples [] = []
  makeTriples (x:y:z:zs) = (x,y,z) : makeTriples zs
  
  rnd_select :: [a] -&gt; Int -&gt; IO [a]
  rnd_select _  0 = return []
  rnd_select [] _ = return []
  rnd_select xs count = do r &lt;- randomRIO (0, (length xs)-1)
                           rest &lt;- rnd_select (removeAt (r+1) xs) (count-1)
                           return ((xs!!r) : rest)
  
  removeAt :: Int -&gt; [a] -&gt; [a]
  removeAt _ [] = []
  removeAt 1 (x:xs) = xs
  removeAt k (x:xs) = let r = removeAt (k - 1) xs in x:r
  </code></pre>
  
  <p>This is wrapped in the IO-monad and that is what makes it hard when i want to use functions on the values.</p>
  
  <p>Here i use the bind function to apply the input to the rnd_select function:</p>
  
  <pre><code>(`rnd_select` 6) =&lt;&lt; readNumbers
  </code></pre>
  
  <p>But in order to do that I have to partially apply it to a value.</p>
  
  <p>I don't think it looks very good and I don't know how I would do it if the function had more variables.</p>
  
  <p>So I want to know if there is a nicer way to apply values to functions such as these?</p>