| Safe Haskell | Safe |
|---|---|
| Language | Haskell98 |
DDC.Type.DataDef
Contents
Description
Algebraic data type definitions.
- data DataDef n = DataDef {
- dataDefTypeName :: !n
- dataDefParams :: ![Bind n]
- dataDefCtors :: !(Maybe [DataCtor n])
- dataDefIsAlgebraic :: Bool
- kindOfDataDef :: DataDef n -> Kind n
- dataTypeOfDataDef :: DataDef n -> Type n
- dataCtorNamesOfDataDef :: DataDef n -> Maybe [n]
- makeDataDefAlg :: n -> [Bind n] -> Maybe [(n, [Type n])] -> DataDef n
- makeDataDefAbs :: n -> [Bind n] -> DataDef n
- data DataDefs n = DataDefs {
- dataDefsTypes :: !(Map n (DataType n))
- dataDefsCtors :: !(Map n (DataCtor n))
- data DataMode n
- = DataModeSmall ![n]
- | DataModeLarge
- emptyDataDefs :: DataDefs n
- insertDataDef :: Ord n => DataDef n -> DataDefs n -> DataDefs n
- unionDataDefs :: Ord n => DataDefs n -> DataDefs n -> DataDefs n
- fromListDataDefs :: Ord n => [DataDef n] -> DataDefs n
- data DataType n = DataType {
- dataTypeName :: !n
- dataTypeParams :: ![Bind n]
- dataTypeMode :: !(DataMode n)
- dataTypeIsAlgebraic :: Bool
- kindOfDataType :: DataType n -> Kind n
- lookupModeOfDataType :: Ord n => n -> DataDefs n -> Maybe (DataMode n)
- data DataCtor n = DataCtor {
- dataCtorName :: !n
- dataCtorTag :: !Integer
- dataCtorFieldTypes :: ![Type n]
- dataCtorResultType :: !(Type n)
- dataCtorTypeName :: !n
- dataCtorTypeParams :: ![Bind n]
- typeOfDataCtor :: DataCtor n -> Type n
Documentation
The definition of a single data type.
Constructors
| DataDef | |
Fields
| |
kindOfDataDef :: DataDef n -> Kind n Source #
Get the kind of the type constructor defined by a DataDef.
dataTypeOfDataDef :: DataDef n -> Type n Source #
Get the type associated with a data definition, that is, the type produced by the constructors.
dataCtorNamesOfDataDef :: DataDef n -> Maybe [n] Source #
Get the list of data constructor names that this type defines, or Nothing if there are too many to list.
Arguments
| :: n | Name of data type. |
| -> [Bind n] | Type parameters. |
| -> Maybe [(n, [Type n])] | Constructor names and field types,
or |
| -> DataDef n |
Shortcut for constructing a DataDef for an algebraic type.
Values of algebraic type can be deconstructed with case-expressions.
makeDataDefAbs :: n -> [Bind n] -> DataDef n Source #
Shortcut for constructing a DataDef for an abstract type.
Values of abstract type cannot be deconstructed with case-expressions.
Data type definition table
A table of data type definitions, unpacked into type and data constructors so we can find them easily.
Constructors
| DataDefs | |
Fields
| |
The mode of a data type records how many data constructors there are.
This can be set to Large for large primitive types like Int and Float.
In this case we don't ever expect them all to be enumerated
as case alternatives.
Constructors
| DataModeSmall ![n] | |
| DataModeLarge |
emptyDataDefs :: DataDefs n Source #
An empty table of data type definitions.
insertDataDef :: Ord n => DataDef n -> DataDefs n -> DataDefs n Source #
Insert a data type definition into some DataDefs.
Describes a data type constructor, used in the DataDefs table.
Constructors
| DataType | |
Fields
| |
kindOfDataType :: DataType n -> Kind n Source #
Get the kind of the type constructor defined by a DataDef.
lookupModeOfDataType :: Ord n => n -> DataDefs n -> Maybe (DataMode n) Source #
Yield the list of data constructor names for some data type,
or Nothing for large types with too many constructors to list.
Describes a data constructor, used in the DataDefs table.
Constructors
| DataCtor | |
Fields
| |