title: Misconception on Type Classes and variable assignment in Haskell
body: <p>Very new to Haskell and trying to understand how type classes and variables interact.</p>
  
  <p>My first thing to play with was:</p>
  
  <pre><code>i :: a; i = 1
  </code></pre>
  
  <p>My expectation was that, since i was typed as generically as possible, I should be able to assign absolutely anything to it.  (I know that I probably can't do anything with variable i, but that wasn't important.)</p>
  
  <p>But, I was wrong.  The above gives an error and requires that it be:</p>
  
  <pre><code>i :: Num a =&gt; a; i = 1
  </code></pre>
  
  <p>After playing around a bit more I came up with the following:</p>
  
  <pre><code>g :: Num a =&gt; a -&gt; a; g a = a + 1
  g 1
  (returned 2)
  gg :: Num a =&gt; a; gg = g 1
  gg
  (returned 2)
  </code></pre>
  
  <p>Ok... so far so good.  Let's try a Fractional parameter.</p>
  
  <pre><code>g :: Num a =&gt; a -&gt; a; g a = a + 1
  g 1.3
  (returned 2.3)
  gg :: Num a =&gt; a; gg = g 1.3
  (error)
  </code></pre>
  
  <p>So, please... what is it about variables that causes this?  From a non-functional programming background, it "looks" like I have a function that returns a value with a type implementing Num and tried to assign it to a variable with a type implementing Num.  Yet, the assignment fails.</p>
  
  <p>I'm sure this is some basic misconception I have.  It's probably the same thing that prevents the first example from working. I really want to get it straightened out before I start making far more serious conceptual errors.</p>