Reputation: 1436
I am learning Haskell an come across something like the following:
data ABC :: * where
Empty :: ABC
Single :: Char -> ABC
what does the above mean? And what does it mean when we say "write a ABC representing something"?
Upvotes: 1
Views: 340
Reputation: 74354
This syntax is identical to the standard datatype syntax in Haskell. In particular, the type ABC
is the same as
data ABC = Empty | Single Char
The syntax including the where
clause is called "GADT syntax" and it offers some extra expressiveness by allowing clear syntax for "existential types" and "type equalities". Both of these are rather advanced topics, though. Stick with basic types until you get your water legs.
Upvotes: 2