Type Constructor and Data Constructor in Haskell
data Color = Red | Green | Blue
The data Constructor is Red, Green, Blue
:t Red => Red::Color = function with return type Color
:t Green => Green::Color = function with return type Color
:t Color => Error, Color has no type
:kind Color => Color::* -- Color is a kind
Type Constructor and Data Constructor in Haskell
data Color = RGB Int Int Int
RGB is data Constructor
RGB is a function RGB::Int->Int->Int
:kind Color - Color is kind
Type Constructor
data Color a = Red a | Green a
Color is type Constructor
Recursive Data Type
-- list
Data List a = [] | a:[a]
-- Binary Tree
Data Tree a = Empty | Node a (Tree a) (Tree a)
-- Java Binary Tree
Node {
int a
Node left;
Node right;
}