title: How can I define a while loop as a higher-order function in Haskell?
body: <p>I am facing the following problem, could someone give me some hints? thanks so much!</p>
  
  <p>Define higher-order function <code>while</code>, in which the condition and the operation work over values of type <code>a</code>. Its type should be </p>
  
  <pre><code>whileG :: (a -&gt; IO Bool) -&gt; (a -&gt; IO a) -&gt; (a -&gt;IO a)
  </code></pre>