ddc-core-simpl-0.4.2.1: Disciplined Disciple Compiler code transformations.

Safe HaskellNone
LanguageHaskell98

DDC.Core.Transform.Boxing

Description

Manage representation of numeric values in a module.

Note: Boxing and Partial Application
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unlike in Haskell, we do not allow explictly unboxed types in the source program because we don't want to deal with partial applications of functions to unboxed values. With our current setup we always have a version of each function that accepts boxed values, so we never need to do generic application involving unboxed values. Fast-path function specialisations that take unboxed parameters should be created separately, and not replace the existing slow-path, fully boxed version. Taking this approach is possible in a strict language because the boxed and unboxed values have the same semantic meaning. Boxing of values does not imply "lifting" of the associated semantic domain.

Synopsis

Documentation

data Rep Source

Representation of the values of some type.

Constructors

RepNone

These types don't contain any values.

RepBoxed

Values of this type are uncomitted to a particular representation, they just describe a set of logical values.

RepUnboxed

Values of this type are represented in unboxed form.

data Config a n Source

Constructors

Config 

Fields

configRepOfType :: Type n -> Maybe Rep

Get the representation of this type.

configConvertRepType :: Rep -> Type n -> Maybe (Type n)

Get the type for a different representation of the given one.

configConvertRepExp :: Rep -> a -> Type n -> Exp a n -> Maybe (Exp a n)

Convert a value between representations.

configValueTypeOfLitName :: n -> Maybe (Type n)

Take the type of a literal name, if there is one.

configValueTypeOfPrimOpName :: n -> Maybe (Type n)

Take the type of a primitive operator name, if it is one. The primops can be polytypic, but must have prenex rank-1 types.

configValueTypeOfForeignName :: n -> Maybe (Type n)

Take the type of a foreign function name, if it is one. The function can be polymorphic, but must have a prenex rank-1 type.

configUnboxLitName :: n -> Maybe n

Convert a literal name to its unboxed version.

configUnboxPrimOpName :: n -> Maybe n

Covnert a primop name to its unboxed version.

boxingModule :: (Show a, Show n, Pretty n, Ord n) => Config a n -> Module a n -> Module a n Source

Manage boxing in a module.