6.8.1
Included in GHC2024
, GHC2021
and Haskell2010
Allow definition of empty data
types.
With the EmptyDataDecls
extension, GHC lets you declare a data type with no constructors.
You only need to enable this extension if the language youâre using is Haskell 98, in which a data type must have at least one constructor. Haskell 2010 relaxed this rule to allow data types with no constructors, and thus EmptyDataDecls
is enabled by default when the language is Haskell 2010.
For example:
data S -- S :: Type data T a -- T :: Type -> Type
Syntactically, the declaration lacks the â= constrsâ part. The type can be parameterised over types of any kind, but if the kind is not Type
then an explicit kind annotation must be used (see Explicitly-kinded quantification).
Such data types have only one value, namely bottom. Nevertheless, they can be useful when defining âphantom typesâ.
In conjunction with the EmptyDataDeriving
extension, empty data declarations can also derive instances of standard type classes (see Deriving instances for empty data types).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4