title: While loop in Haskell with a condition
body: <p>I'm having a little Haskell Situation over here. I'm trying to write two functions with monads.
  First one is supposed to iterate through a function as long as the condition is true for the input / output of the function. Second one is supposed to use the first one to take a number as input and write it as output until you enter a space.</p>
  
  <p>I'm stuck with this, any help?</p>
  
  <pre><code>module Test where
  
  while :: (a -&gt; Bool) -&gt; (a -&gt; IO a) -&gt; a -&gt; IO a
  while praed funktion x = do
                           f &lt;- praed (funktion x)
                           if f == True then do
                                               y &lt;- funktion x
                                               while praed funktion y
                           else return x
  
  
  
  power2 :: IO ()
  power2 = do putStr (Please enter a number.")
              i &lt;- getChar
              while praed funktion
              where praed x = if x /= ' ' then False else True
                    funktion = i
  </code></pre>