[Haskell-beginners] Help with a data type declaration

emacstheviking objitsu at gmail.com
Tue Sep 29 15:10:56 UTC 2015


Is the definition of Branch correct though, shouldn't it be Branch (Tree a
b) (Tree a b) ...?


On 29 September 2015 at 16:10, emacstheviking <objitsu at gmail.com> wrote:

> a = left b = right
>
> That would at least make the sentiment clearer.
>
>
>
> On 29 September 2015 at 15:10, <jamb at hinojosa.com> wrote:
>
>> How can I interpret the following data type declaration? The book where I
>> am studying (and other sources I have read as well) only show more simple
>> examples. This is what I can say about it:
>>
>> * "Tree" is the name of the new type.
>> * "Branch" and "Leaf" are the type constructors.
>> * What is "a" and "b"?
>> * It seems to me that this type is kind of "recursively" defined but I do
>> not know exactly.
>>
>>
>> data Tree a b = Branch b (Tree a b) (Tree a b)
>>               | Leaf a
>>
>> I will very much appreciate your feedback.
>>
>> Regards,
>> JAMB
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150929/af5c94b3/attachment.html>


More information about the Beginners mailing list