If I have a Haskell ADT such as:
data Foo
= A Int Double
| B Bool [Integer]
| C (Maybe String) Float
the A
, B
, and C
are referred to as data constructors; and sometimes as value constructors. But what is the correct name for:
B Bool [Integer]
; andDouble
in A
, or
the [Integer]
in B
?Reading Section 4.2 from the Haskell98 Report ( http://www.haskell.org/onlinereport/decls.html ):
B Bool [Integer]
is probably most correctly called a "constructor declaration" (for the constructor called B
)Double
in A
are called field declarations (though simply calling it a field should be OK too).data Foo = A Int Double
^^ Type Constructor "data Foo"
^ value Constructor "A"
^^ Component "Int" and "Double"
A | B is usually referred to as alternatives or cases. Sorry for the crappy diagram.
Source: Real World Haskell ch3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With