I think the simplest answer here is that =
doesn’t have any one meaning in particular — it is simply the syntax which the Haskell designers decided to use for data types. There is no particular relationship between the =
used in function definitions and the =
used in ADT definitions; both constructions are used to declare something on the LHS using some sort of specification on the RHS, but that’s about it. The two constructions have more differences than similarities.
As it happens, modern Haskell doesn’t necessarily require the use of =
when defining an ADT. The GADTSyntax
and GADTs
GHCI language extensions enable ‘GADT syntax’, which is an alternate method to define ADTs. It looks like this:
data DataType a where
Data :: a -> DataType a
Datum :: DataType a
This illustrates that the use of =
is not necessarily a mandatory part of type declarations: it is simply one convention amongst many.
(As to why the Haskell designers chose to use the convention with =
, I’m not entirely sure. Possibly it might have been by analogy with type synonyms, like type Synonym = Maybe Int
, in which =
does have similarities to its use in function definitions, in that the RHS expresses a type which is then assigned the name on the LHS.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…