title: Recursive implementation of Euclid's Algorithm - Type Error
body: <p>This is the code (Euclid's algorithm for GCD). Of course there is <code>Prelude.gcd</code> but as an exercise I am implementing my own.</p>
  
  <pre><code>selfGCD :: Integral f =&gt; f -&gt; f -&gt; f  
  selfGCD a b = if b == 0 then
          return a
      else 
          return (selfGCD a (mod a b))
  </code></pre>
  
  <p>Using <b>ghci</b>, I get the following error:</p>
  
  <pre><code>two.hs:32:25:  
  Couldn't match type `f' with `m0 f'  
    `f' is a rigid type variable bound by  
        the type signature for selfGCD :: Integral f =&gt; f -&gt; f -&gt; f  
        at two.hs:31:1  
  In the return type of a call of `return'  
  In the expression: return a  
  In the expression:  
    if b == 0 then return a else return (selfGCD a (mod a b))  
  
  two.hs:34:25:  
  Couldn't match type `f' with `m1 f'  
    `f' is a rigid type variable bound by  
        the type signature for selfGCD :: Integral f =&gt; f -&gt; f -&gt; f  
        at two.hs:31:1  
  In the return type of a call of `return'  
  In the expression: return (selfGCD a (mod a b))  
  In the expression:  
    if b == 0 then return a else return (selfGCD a (mod a b))  
  </code></pre>
  
  <p>How can I rectify the problem?</p>