ddc-core-0.4.3.1: Disciplined Disciple Compiler core language and type checker.

Safe HaskellSafe
LanguageHaskell98

DDC.Type.DataDef

Contents

Description

Algebraic data type definitions.

Synopsis

Documentation

data DataDef n Source #

The definition of a single data type.

Constructors

DataDef 

Fields

Instances

SpreadT DataDef Source # 

Methods

spreadT :: Ord n => TypeEnv n -> DataDef n -> DataDef n Source #

Show n => Show (DataDef n) Source # 

Methods

showsPrec :: Int -> DataDef n -> ShowS #

show :: DataDef n -> String #

showList :: [DataDef n] -> ShowS #

NFData n => NFData (DataDef n) Source # 

Methods

rnf :: DataDef n -> () #

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.

makeDataDefAlg Source #

Arguments

:: n

Name of data type.

-> [Bind n]

Type parameters.

-> Maybe [(n, [Type n])]

Constructor names and field types, or Nothing if there are too many to list.

-> 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

data DataDefs n Source #

A table of data type definitions, unpacked into type and data constructors so we can find them easily.

Constructors

DataDefs 

Fields

Instances

SpreadT DataDefs Source # 

Methods

spreadT :: Ord n => TypeEnv n -> DataDefs n -> DataDefs n Source #

Show n => Show (DataDefs n) Source # 

Methods

showsPrec :: Int -> DataDefs n -> ShowS #

show :: DataDefs n -> String #

showList :: [DataDefs n] -> ShowS #

Ord n => Monoid (DataDefs n) Source # 

Methods

mempty :: DataDefs n #

mappend :: DataDefs n -> DataDefs n -> DataDefs n #

mconcat :: [DataDefs n] -> DataDefs n #

data DataMode n Source #

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 

Instances

Show n => Show (DataMode n) Source # 

Methods

showsPrec :: Int -> DataMode n -> ShowS #

show :: DataMode n -> String #

showList :: [DataMode n] -> ShowS #

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.

unionDataDefs :: Ord n => DataDefs n -> DataDefs n -> DataDefs n Source #

Union two DataDef tables.

fromListDataDefs :: Ord n => [DataDef n] -> DataDefs n Source #

Build a DataDefs table from a list of DataDef

data DataType n Source #

Describes a data type constructor, used in the DataDefs table.

Constructors

DataType 

Fields

Instances

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.

data DataCtor n Source #

Describes a data constructor, used in the DataDefs table.

Constructors

DataCtor 

Fields

Instances

SpreadT DataCtor Source # 

Methods

spreadT :: Ord n => TypeEnv n -> DataCtor n -> DataCtor n Source #

Show n => Show (DataCtor n) Source # 

Methods

showsPrec :: Int -> DataCtor n -> ShowS #

show :: DataCtor n -> String #

showList :: [DataCtor n] -> ShowS #

NFData n => NFData (DataCtor n) Source # 

Methods

rnf :: DataCtor n -> () #

typeOfDataCtor :: DataCtor n -> Type n Source #

Get the type of DataCtor