title: Using Haskell's "Maybe", type declarations [beginner's question]
body: <p>I've started experimenting with Haskell and have a problem. qqq is a function that should print one string if called with "Nothing" and print other things if called with "Just something".</p>
  
  <p>The first attempt seems like working:</p>
  
  <pre><code>qqq Nothing = print "There isn't anything to be printed."
  qqq (Just x) = print "There is something to be printed." &gt;&gt; print x
  
  main :: IO ()
  main = qqq (Just 43)
  </code></pre>
  
  <p>But:</p>
  
  <ul>
  <li>when I try to make <code>main = qqq (Nothing)</code> it fails ("Ambiguous type variable `a0' in the constraint: (Show a0) arising from a use of 'qqq'")</li>
  <li>When I want to add type signature if fails:</li>
  <li><ul>
  <li><code>qqq :: Maybe x =&gt; x -&gt; IO ()</code> -> <code>Type constructor 'Maybe' used as a class</code> -> But isn't it?</li>
  </ul></li>
  <li><ul>
  <li><code>qqq :: (Maybe x) -&gt; IO ()</code>. Now the signature itself looks like succeed. But <code>main = qqq (Just 43)</code> starts failing with that mysterious <code>(Show a0)</code> error like in <code>main = qqq (Nothing)</code> case.</li>
  </ul></li>
  </ul>
  
  <p>Questions:</p>
  
  <ol>
  <li>Why calling qqq with <code>Nothing</code> is so different than calling with <code>Just 43</code>?</li>
  <li>What is <code>(Show a0)</code>? It is mentioned only in error messages. Any attempts to use it lead to something like "Show not in the scope".</li>
  <li>What is correct type signature for this? How to make Haskell print type signature it deduced? Expecting something like:</li>
  </ol>
  
  
  
  <pre><code>f 0 = 2
  f x = (f (x-1)) + 3
  
  main = print get_type_as_string(f)
  -- prints "Number -&gt; Number"
  </code></pre>