ddc-core-tetra-0.4.1.1: Disciplined Disciple Compiler intermediate language.

Safe HaskellNone

DDC.Core.Tetra.Prim

Contents

Synopsis

Names and lexing.

data Name Source

Names of things used in Disciple Core Tetra.

Constructors

NameVar String

User defined variables.

NameCon String

A user defined constructor.

NameTyConTetra TyConTetra

Baked-in type constructors.

NameDaConTetra DaConTetra

Baked-in data constructors.

NameOpStore OpStore

Baked-in operators.

NamePrimTyCon PrimTyCon

A primitive type constructor.

NamePrimArith PrimArith

Primitive arithmetic, logic, comparison and bit-wise operators.

NamePrimCast PrimCast

Primitive numeric casting operators.

NameLitBool Bool

A boolean literal.

NameLitNat Integer

A natural literal.

NameLitInt Integer

An integer literal.

NameLitWord Integer Int

A word literal.

NameHole

Hole used during type inference.

isNameHole :: Name -> BoolSource

Check whether a name is NameHole.

isNameLit :: Name -> BoolSource

Check whether a name represents some literal value.

readName :: String -> Maybe NameSource

Read the name of a variable, constructor or literal.

takeTypeOfLitName :: Name -> Maybe (Type Name)Source

Get the type associated with a literal name.

takeTypeOfPrimOpName :: Name -> Maybe (Type Name)Source

Take the type of a primitive operator.

Baked-in type constructors.

data TyConTetra Source

Baked-in type constructors.

Constructors

TyConTetraRef

Ref#. Mutable reference.

TyConTetraTuple Int

TupleN#. Tuples.

TyConTetraB

B#. Boxing type constructor. Used to represent boxed numeric values.

TyConTetraU

U#. Unboxed type constructor. Used to represent unboxed numeric values.

readTyConTetra :: String -> Maybe TyConTetraSource

Read the name of a baked-in type constructor.

kindTyConTetra :: TyConTetra -> Type NameSource

Take the kind of a baked-in type constructor.

Baked-in data constructors.

data DaConTetra Source

Data Constructors.

Constructors

DaConTetraTuple Int

TN#. Tuple data constructors.

readDaConTetra :: String -> Maybe DaConTetraSource

Read the name of a baked-in data constructor.

typeDaConTetra :: DaConTetra -> Type NameSource

Yield the type of a baked-in data constructor.

Baked-in store operators.

data OpStore Source

Mutable References.

Constructors

OpStoreAllocRef

Allocate a reference.

OpStoreReadRef

Read a reference.

OpStoreWriteRef

Write to a reference.

readOpStore :: String -> Maybe OpStoreSource

Read a primitive store operator.

typeOpStore :: OpStore -> Type NameSource

Take the type of a primitive store operator.

Primitive type constructors.

data PrimTyCon

Primitive type constructors.

Constructors

PrimTyConVoid

Void# the Void type has no values.

PrimTyConBool

Bool# unboxed booleans.

PrimTyConNat

Nat# natural numbers. Enough precision to count every object in the heap, but NOT enough precision to count every byte of memory.

PrimTyConInt

Int# signed integers. Enough precision to count every object in the heap, but NOT enough precision to count every byte of memory. If N is the total number of objects that can exist in the heap, then the range of Int# is at least (-N .. +N) inclusive.

PrimTyConWord Int

WordN# machine words of the given width.

PrimTyConFloat Int

FloatN# floating point numbers of the given width.

PrimTyConVec Int

VecN# a packed vector of N values. This is intended to have kind (Data -> Data), so we use concrete vector types like Vec4.

PrimTyConAddr

Addr# a relative or absolute machine address. Enough precision to count every byte of memory. Unlike pointers below, an absolute Addr# need not refer to memory owned by the current process.

PrimTyConPtr

Ptr# should point to a well-formed object owned by the current process.

PrimTyConTag

Tag# data constructor tags. Enough precision to count every possible alternative of an enumerated type.

PrimTyConString

String# of UTF8 characters.

These are primitive until we can define our own unboxed types.

readPrimTyCon :: String -> Maybe PrimTyCon

Read a primitive type constructor.

Words are limited to 8, 16, 32, or 64 bits.

Floats are limited to 32 or 64 bits.

kindPrimTyCon :: PrimTyCon -> Kind NameSource

Yield the kind of a type constructor.

Primitive arithmetic operators.

data PrimArith

Primitive arithmetic, logic, and comparison opretors. We expect the backend/machine to be able to implement these directly.

For the Shift Right operator, the type that it is used at determines whether it is an arithmetic (with sign-extension) or logical (no sign-extension) shift.

Constructors

PrimArithNeg

Negation

PrimArithAdd

Addition

PrimArithSub

Subtraction

PrimArithMul

Multiplication

PrimArithDiv

Division

PrimArithMod

Modulus

PrimArithRem

Remainder

PrimArithEq

Equality

PrimArithNeq

Negated Equality

PrimArithGt

Greater Than

PrimArithGe

Greater Than or Equal

PrimArithLt

Less Than

PrimArithLe

Less Than or Equal

PrimArithAnd

Boolean And

PrimArithOr

Boolean Or

PrimArithShl

Shift Left

PrimArithShr

Shift Right

PrimArithBAnd

Bit-wise And

PrimArithBOr

Bit-wise Or

PrimArithBXOr

Bit-wise eXclusive Or

readPrimArith :: String -> Maybe PrimArith

Read a primitive operator.

typePrimArith :: PrimArith -> Type NameSource

Take the type of a primitive arithmetic operator.

Primitive numeric casts.

data PrimCast

Primitive cast between two types.

The exact set of available casts is determined by the target platform. For example, you can only promote a Nat# to a Word32# on a 32-bit system. On a 64-bit system the Nat# type is 64-bits wide, so casting it to a Word32# would be a truncation.

Constructors

PrimCastConvert

Convert a value to a new representation with the same precision.

PrimCastPromote

Promote a value to one of similar or larger width, without loss of precision.

PrimCastTruncate

Truncate a value to a new width, possibly losing precision.

typePrimCast :: PrimCast -> Type NameSource

Take the type of a primitive numeric cast operator.