Safe Haskell | Safe-Inferred |
---|
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.
DataDef | |
|
kindOfDataDef :: DataDef n -> Kind nSource
Get the kind of the type constructor defined by a DataDef
.
dataTypeOfDataDef :: DataDef n -> Type nSource
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.
:: 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 nSource
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.
DataDefs | |
|
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.
Show n => Show (DataMode n) |
emptyDataDefs :: DataDefs nSource
An empty table of data type definitions.
insertDataDef :: Ord n => DataDef n -> DataDefs n -> DataDefs nSource
Insert a data type definition into some DataDefs.
fromListDataDefs :: Ord n => [DataDef n] -> DataDefs nSource
Describes a data type constructor, used in the DataDefs
table.
DataType | |
|
kindOfDataType :: DataType n -> Kind nSource
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.
DataCtor | |
|
typeOfDataCtor :: DataCtor n -> Type nSource
Get the type of DataCtor