
T is the type. A and B are the only constructors for values of that type. A
and B are not terms in the type language. T is not a term in the value
language.
It's simpler to consider a type without any fields in the constructor:
data Bool = True | False
True and False are values, Bool is the type. You can't use Bool as a
constructor, and you can't use True or False as a type.
When you add fields it can get a bit more confusing, because the fields of
a constructor are types, so it looks like "ValueConstructor1 FieldType1
FieldType2 | ValueConstructor2 FieldType3"
data PersonOrPlace = Person String | Place String
To make it more clear, here the types are annotated with <AngleBrackets>
and the constructors annotated with [SquareBrackets]:
data <PersonOrPlace> = [Person] <String> | [Place] <String>
On Tue, Jun 16, 2015 at 8:52 AM, Matt Williams wrote: Dear All, I am sure this is a common mistake, and I am happy to be pointed elsewhere
for reading. I have spent the last couple of days on the Haskell irc channel, which was
very helpful. However, one of the points of discussion left me confused. When we have a type, T, with constructors A and B (e.g. data T = A x y z | B x y) How do I understand the relationship between A, B and T? I had thought I
could use the sub-class relationship, but that doesn't seem to be true. Any other pointers very welcome. Matt _______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners