| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
DDC.Core.Tetra
- profile :: Profile Name
- lexModuleString :: String -> Int -> String -> [Located (Token Name)]
- lexExpString :: String -> Int -> String -> [Located (Token Name)]
- checkModule :: Module a Name -> Maybe (Error a)
- saltOfTetraModule :: Show a => Platform -> Config -> DataDefs Name -> KindEnv Name -> TypeEnv Name -> Module (AnTEC a Name) Name -> Either (Error a) (Module a Name)
- data Name
- = NameVar !String
- | NameCon !String
- | NameExt !Name !String
- | NameTyConTetra !TyConTetra
- | NameDaConTetra !DaConTetra
- | NameOpError !OpError !Bool
- | NameOpFun !OpFun
- | NameOpVector !OpVector !Bool
- | NamePrimTyCon !PrimTyCon
- | NamePrimArith !PrimArith !Bool
- | NamePrimCast !PrimCast !Bool
- | NameLitBool !Bool
- | NameLitNat !Integer
- | NameLitInt !Integer
- | NameLitSize !Integer
- | NameLitWord !Integer !Int
- | NameLitFloat !Double !Int
- | NameLitChar !Char
- | NameLitTextLit !Text
- | NameLitUnboxed !Name
- | NameHole
- data TyConTetra
- data DaConTetra = DaConTetraTuple Int
- data OpFun
- data OpVector
- data OpError = OpErrorDefault
- data PrimTyCon :: *
- pprPrimTyConStem :: PrimTyCon -> Doc
- data PrimArith :: *
- data PrimCast :: *
- readName :: String -> Maybe Name
- readTyConTetra :: String -> Maybe TyConTetra
- readDaConTetra :: String -> Maybe DaConTetra
- readOpFun :: String -> Maybe OpFun
- readOpVectorFlag :: String -> Maybe (OpVector, Bool)
- readOpErrorFlag :: String -> Maybe (OpError, Bool)
- readPrimTyCon :: String -> Maybe PrimTyCon
- readPrimTyConStem :: String -> Maybe PrimTyCon
- readPrimArithFlag :: String -> Maybe (PrimArith, Bool)
- readPrimCastFlag :: String -> Maybe (PrimCast, Bool)
- freshT :: Env Name -> Bind Name -> State Int Name
- freshX :: Env Name -> Bind Name -> State Int Name
- data Error a
Language profile
Program Lexing
lexModuleString :: String -> Int -> String -> [Located (Token Name)] Source #
Lex a string to tokens, using primitive names.
The first argument gives the starting source line number.
lexExpString :: String -> Int -> String -> [Located (Token Name)] Source #
Lex a string to tokens, using primitive names.
The first argument gives the starting source line number.
Checking
checkModule :: Module a Name -> Maybe (Error a) Source #
Perform Core Tetra specific checks on a module.
Conversion
Arguments
| :: Show a | |
| => Platform | Platform specification. |
| -> Config | Runtime configuration. |
| -> DataDefs Name | Data type definitions. |
| -> KindEnv Name | Kind environment. |
| -> TypeEnv Name | Type environment. |
| -> Module (AnTEC a Name) Name | Tetra module to convert. |
| -> Either (Error a) (Module a Name) | Salt module. |
Convert a Core Tetra module to Core Salt.
The input module needs to be:
well typed,
fully named with no deBruijn indices,
have all functions defined at top-level,
have type annotations on every bound variable and constructor,
be a-normalised,
have saturated function applications,
not have over-applied function applications,
have all supers in prenex form, with type parameters before value parameters.
If not then Error.
The output code contains: debruijn indices. These then need to be eliminated before it will pass the Salt fragment checks.
Names
Names of things used in Disciple Core Tetra.
Constructors
| NameVar !String | User defined variables. |
| NameCon !String | A user defined constructor. |
| NameExt !Name !String | An extended name. |
| NameTyConTetra !TyConTetra | Baked-in type constructors. |
| NameDaConTetra !DaConTetra | Baked-in data constructors. |
| NameOpError !OpError !Bool | Baked-in runtime error reporting. The flag indicates whether this is the boxed (False) or unboxed (True) version. |
| NameOpFun !OpFun | Baked-in function operators. |
| NameOpVector !OpVector !Bool | Baked-in vector operators. The flag indicates whether this is the boxed (False) or unboxed (True) version. |
| NamePrimTyCon !PrimTyCon | A primitive type constructor. |
| NamePrimArith !PrimArith !Bool | Primitive arithmetic, logic, comparison and bit-wise operators. The flag indicates whether this is the boxed (False) or unboxed (True) version. |
| NamePrimCast !PrimCast !Bool | Primitive numeric casting operators. The flat indicates whether this is the boxed (False) or unboxed (True) version. |
| NameLitBool !Bool | A boolean literal. |
| NameLitNat !Integer | A natural literal, with enough precision to count every heap object. |
| NameLitInt !Integer | An integer literal, with enough precision to count every heap object. |
| NameLitSize !Integer | An unsigned size literal, with enough precision to count every addressable byte of memory. |
| NameLitWord !Integer !Int | A word literal, with the given number of bits precision. |
| NameLitFloat !Double !Int | A floating point literal, with the given number of bits precision. |
| NameLitChar !Char | A character literal, These are special syntax for a Word32 expressing a Unicode codepoint. |
| NameLitTextLit !Text | A text literal (UTF-8 encoded)
Note that |
| NameLitUnboxed !Name | Wrapper to indicate an explicitly unboxed literal. |
| NameHole | Hole used during type inference. |
data TyConTetra Source #
Baked-in type constructors.
Constructors
| TyConTetraTuple Int |
|
| TyConTetraVector |
|
| TyConTetraU |
|
| TyConTetraF |
|
| TyConTetraC |
|
Instances
data DaConTetra Source #
Data Constructors.
Constructors
| DaConTetraTuple Int |
|
Instances
Operators for building function values and closures. The implicit versions work on functions of type (a -> b), while the explicit versions use expliciy closure types like C# (a -> b).
Constructors
| OpFunCurry Int | Partially apply a supecombinator to some arguments, producing an implicitly typed closure. |
| OpFunApply Int | Apply an implicitly typed closure to some more arguments. |
| OpFunCReify | Reify a function into an explicit functional value. |
| OpFunCCurry Int | Apply an explicit functional value to some arguments, producing an explicitly typed closure. |
| OpFunCExtend Int | Extend an explicitly typed closure with more arguments, producing a new closure. |
| OpFunCApply Int | Apply an explicitly typed closure to some arguments, possibly evaluating the contained function. |
Vector operators.
Constructors
| OpVectorAlloc | Allocate a new vector of a given length number of elements. |
| OpVectorLength | Get the length of a vector, in elements. |
| OpVectorRead | Read a value from a vector. |
| OpVectorWrite | Write a value to a vector. |
Operators for runtime error reporting.
Constructors
| OpErrorDefault | Raise an error due to inexhaustive case expressions. |
Primitive type constructors.
Constructors
| PrimTyConVoid |
|
| PrimTyConBool |
|
| PrimTyConNat |
|
| PrimTyConInt |
|
| PrimTyConSize |
|
| PrimTyConWord Int |
|
| PrimTyConFloat Int |
|
| PrimTyConVec Int |
|
| PrimTyConAddr |
|
| PrimTyConPtr |
|
| PrimTyConTextLit |
|
| PrimTyConTag |
|
pprPrimTyConStem :: PrimTyCon -> Doc #
Pretty print a primitive type constructor,
without the # suffix.
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 |
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. |
Name Parsing
readTyConTetra :: String -> Maybe TyConTetra Source #
Read the name of a baked-in type constructor.
readDaConTetra :: String -> Maybe DaConTetra Source #
Read the name of a baked-in data constructor.
readOpVectorFlag :: String -> Maybe (OpVector, Bool) Source #
Read a primitive vector operator, along with the flag that indicates whether this is the boxed or unboxed version.
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.
readPrimTyConStem :: String -> Maybe PrimTyCon #
Read a primitive type constructor, without the # suffix.
Name Generation
freshT :: Env Name -> Bind Name -> State Int Name Source #
Create a new type variable name that is not in the given environment.
freshX :: Env Name -> Bind Name -> State Int Name Source #
Create a new value variable name that is not in the given environment.
Errors
Fragment specific errors.
Constructors
| ErrorMainMissing | Main module does not export a |
| ErrorMainInvalidMode | Main module exports a |
| ErrorMainInvalidType (Type Name) | Main module exports a |