1.For data xxx
,it will create a type named xxx
with type constructor xxx
,and create value constructor which can summon values related to type xxx
if assign right expression to it (i.e. = cons | cons2
)
2.For type XXX = XXXX
,it will create a type named XXX
which is equivalent with type XXXX
.
Examples for above:
-- Could create a type named `Maybe a` with type constructor `Maybe a`
-- And to supply of it,use the value constructor `Just` or `Nothing`,which could be thought as values.
data Maybe a = Just a | Nothing
-- Also create a type named `MaybeOfInt` with its type constructor,which actually represent the type named `Maybe Int`.
type MaybeOfInt = Maybe Int
Are these statements of what I think of Haskell’s data
and type
true?