What's the difference between type and data type in Haskell?
I'm a little confused as to the difference between a type and a data type in Haskell.
From the literature I have encountered I got the impression they were different concepts.
Solution 1:
Type and data type refer to exactly the same concept.
The Haskell keywords type
and data
are different, though: data
allows you to introduce a new algebraic data type, while type
just makes a type synonym.
See the Haskell wiki for details.
Solution 2:
The terms are sometimes mixed, but usually a "data type" refers to a type introduced using the data
keyword, which has constructors you can pattern match on. These are also called algebraic data types".
Just "type" is a more general term which also includes types created using newtype
, function types and so on.