title: Ambiguous type variable `a0' arising from a use of `print'?
body: <p>While learning Haskell I'm trying to write a function that given a number will give its successor in a <a href="https://en.wikipedia.org/wiki/Collatz_conjecture" rel="nofollow noreferrer">Collatz sequence</a>:</p>
  
  <pre><code>next :: (Fractional a, Integral a) =&gt; a -&gt; a
  next x
      | odd x = x * 3 + 1
      | otherwise = x / 2
  </code></pre>
  
  <p>When I run <code>next 7</code> I get:</p>
  
  <pre><code>&lt;interactive&gt;:150:1: error:
  * Ambiguous type variable `a0' arising from a use of `print'
    prevents the constraint `(Show a0)' from being solved.
    Probable fix: use a type annotation to specify what `a0' should be.
    These potential instances exist:
      instance Show Ordering -- Defined in `GHC.Show'
      instance Show Integer -- Defined in `GHC.Show'
      instance Show a =&gt; Show (Maybe a) -- Defined in `GHC.Show'
      ...plus 22 others
      ...plus 12 instances involving out-of-scope types
      (use -fprint-potential-instances to see them all)
  * In a stmt of an interactive GHCi command: print it
  </code></pre>
  
  <p>Two questions:  </p>
  
  <ol>
  <li>Am I using the best class constraints in my signature?</li>
  <li>Assuming I am, how can I <code>show</code> the result of <code>next 7</code> ?</li>
  </ol>