This Wikipedia article is a good read for getting the concepts right: https://en.wikipedia.org/wiki/Algebraic_data_type

On 29 September 2015 at 20:57, Karl Voelker <karl@karlv.net> wrote:
On Tue, Sep 29, 2015, at 07:10 AM, jamb@hinojosa.com wrote:
> * "Tree" is the name of the new type.
> * "Branch" and "Leaf" are the type constructors.
> * What is "a" and "b"?

"Tree" is not quite the name of a type. It is the name of a type
constructor - in other words, it is a "type-level function". This also
explains "a" and "b" - they are the parameters to the type constructor
(which means they are "type variables").

To get a type, you have to apply the type constructor. So, for example,
"Tree Char Int" is a type.

"Branch" and "Leaf" are not type constructors - they are *data*
constructors.

> * It seems to me that this type is kind of "recursively" defined but I
> do not know exactly.

Yes. It's recursive because a value of type "Tree a b" can be built up
from other values of type "Tree a b" (if you use the "Branch"
constructor).

-Karl
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners



--
Regards

Sumit Sahrawat