title: Haskell - Use Just or no Just made difference, but I don't know why
body: <p>I've found such code in the book "Real World Haskell", p68</p>
  
  <pre><code>data Tree a = Node a (Tree a) (Tree a)
              | Empty
                deriving (Show)
  
  nodeAreSame (Node a _ _) (Node b _ _)
              | a == b = Just a
  nodeAreSame _ _ = Nothing
  </code></pre>
  
  <p>My question is: What job did the <code>Just</code> data constructor do? When I delete it, I will get  error message such like</p>
  
  <pre><code>(in ghci)
  ......
  &lt;Main *&gt; nodeAreSame (Node 3 Empty Empty) (Node 3 Empty Empty))  
  
  &lt;interactive&gt;:1:16:  
      No instance for (Num (Maybe a))
  ......
  </code></pre>
  
  <p>But when I try to compare the type difference between "Just" and "No Just" version:</p>
  
  <pre><code>nodeAreSameJust   :: (Eq t) =&gt; Tree t -&gt; Tree t -&gt; Maybe t
  
  nodeAreSameNoJust :: (Eq a) =&gt; Tree (Maybe a) -&gt; Tree (Maybe a) -&gt; Maybe a
  </code></pre>
  
  <p>So what is the key point here? Does it means when I put a var with type <code>a</code> in the node, the function will not output a node with type <code>a</code>, so it get an error?</p>