Q:

Counting number of Nodes in tree Haskell

I am new to Haskell and still bit confused on some syntax pieces (coming from C/C++).
I have this Tree data type (below) and constructor for t2 
data Tree a b = Leaf a                                                          
              | Node b (Tree a b) (Tree a b)                                    
     deriving (Eq, Show)

 t2 :: Tree Bool Int                                                             
 t2 = Node 17 (Node 2 (Leaf True)                                                
                      (Node 7 (Leaf False)                                       
                              (Leaf False)))                                     
              (Leaf True)

I need to write a function that will go through and count the nodes of the tree 
 sizeTree :: Tree a b -> Int

I am confused about why does sizeTree pass in an 'a' and 'b' for the function. Is it because there is a Leaf for 'a' and a Node for 'b'? I understand that this will need to be a recursively called but where should I start?

A:

Several of the comments have already addressed your confusion over the type signature, but I'll try another way to look at, in a bit more detail than a comment allows.
We can compare this type signature:
sizeTree :: Tree a b -> Int

with that of a function on lists, say the length function:
length :: [a] -> Int 

This function doesn't "take an a" as an argument, it takes a [a], which stands for a list whose elements are of type a. The crucial thing is that a  can stand for any type - indeed it is legal to write it explicitly as forall a. [a] -> Int, which makes clear that the function works on any list type. That is, the one length function can be applied to a list of Ints, or a list of Chars (that is, a String), or a list of lists of pairs of a Double and a list of Integers - hopefully you get the idea. You probably take this for granted, that you can call length [1,2,3] and length "hello" and have them both work - but, given Haskell's strong type system, this only works because of polymorphic types.
Exactly the same is going on with Tree. This is actually a "type family", like lists - it's not a type in itself, there are no values of type Tree. But there are values of types Tree Int Char or Tree String (Int, Double), and anything else you can think of which uses two "concrete types" to stand for the a and b. And by declaring a function sizeTree :: Tree a b -> Int - explicitly sizeTree :: forall a. forall b. Tree a b -> Int - you ensure that it works for any of these infinitely many different concrete types.
As for writing the function itself, again it's similar to lists. The list type, although inbuilt to Haskell, has essentially two constructors, one for the empty list, and one which takes an element and an existing list (you can define the equivalent type yourself as data List a = Null | Cons a (List a) - which means you can pattern match on these two constructors, to do:
length Null = 0
length (Cons _ l) = 1 + length l

or, using the built-in "syntactic sugar" for Haskell's native list type:
length [] = 0
length (_:l) = 1 + length l

(if you're confused by the _, it stands for any value of the appropriate type, and means that in this case we don't care about it's value, I could have given it any name if you'd preferred, say x, and it would have meant exactly the same thing.)
Hopefully this is enough background to help you understand what is happening, and fill out the start given to you by @Rusi - because those are the two constructors of your Tree a b type so you need to define the function on both of these. Further hint: the one for the Node constructor will involve recursive calls to sizeTree, just as the second line of the length definition also uses a recursive call.
Any further questions, please feel free to ask.

