Safe Haskell | None |
---|---|
Language | Haskell98 |
Core Public API (provisional)
Intended for constructing basic Core Programs. This module does not offer any way to inspect the built Core Programs (on purpose), but the EHXX.Core module does.
Invariants: - Constructor applications (mkCon) always have to be fully saturated. (Should we handle this internally?) - Haskell constructor names must be unambigous per module (mkHSCTag) - TODO Tag ordering ?? What exactly are the invariants?
TODO Use AbstractCore instead of directly using the Constructors in the implementation
- data EHCOpts
- defaultEHCOpts :: EHCOpts
- data CModule
- data CImport
- data CDeclMeta
- data CDataCon
- data CExpr
- data CBind
- data CAlt
- data CPat
- data CPatFld
- data CTag
- data HsName
- mkUniqueHsName :: String -> [String] -> String -> HsName
- mkHsName :: [String] -> String -> HsName
- mkHsName1 :: String -> HsName
- addHsNamePrefix :: String -> HsName -> HsName
- acoreUnit :: EHCOpts -> CExpr
- acoreInt :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => EHCOpts -> Int -> e
- acoreBuiltinInteger :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => EHCOpts -> Integer -> e
- acoreBuiltinString :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => EHCOpts -> String -> e
- acoreBuiltinError :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => EHCOpts -> String -> e
- acoreBuiltinUndefined :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => EHCOpts -> e
- acoreVar :: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt => HsName -> expr
- acoreLet1Plain :: (Eq bcat, AbstractCore e m b bound boundmeta bcat mbind t p pr pf a) => HsName -> e -> e -> e
- acoreLet1Strict :: (Eq bcat, AbstractCore e m b bound boundmeta bcat mbind t p pr pf a) => HsName -> e -> e -> e
- acoreLetRec :: (Eq bcat, AbstractCore e m b bound boundmeta bcat mbind t p pr pf a) => [b] -> e -> e
- acoreCaseDflt :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => e -> [a] -> Maybe e -> e
- acoreAlt :: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt => pat -> expr -> alt
- acorePatCon :: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt => CTag -> patrest -> [patfld] -> pat
- acorePatRestEmpty :: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt => patrest
- acorePatFldBind :: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt => (HsName, expr) -> bind -> patfld
- acoreLam :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => [HsName] -> e -> e
- acoreApp :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => e -> [e] -> e
- acoreTagTup :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => CTag -> [e] -> e
- acoreBind1 :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => HsName -> e -> b
- acoreBind1Nm1 :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => HsName -> b
- makeModule :: HsName -> [CImport] -> [CDeclMeta] -> CExpr -> CModule
- makeImport :: HsName -> CImport
- makeMetaData :: HsName -> [CDataCon] -> CDeclMeta
- makeMetaDataCon :: HsName -> Int -> Int -> CDataCon
- makeMain :: HsName -> CExpr
Documentation
defaultEHCOpts :: EHCOpts Source
The default EHC options.
Core AST
The datatypes making up a Core program.
Haskell name representation, exports of constructors only intented for internal use
Names
Names in UHC have to be of the form P1.P2....Pn.Ident . All names in module M must have the form M.Ident . Datatype and constructor names have to start with an uppercase letter, functions with a lowercase letter.
:: String | Name prefix. Used to distinguish names generated by different API consumers, but may also be used to differentiate between different varieties by one API consumer. Use reverse-dns notation if possible, e.g. "nl.uu.agda.identOfVarietyA" |
-> [String] | The module prefix. |
-> String | The name to make unique. |
-> HsName |
Creates a new Core name. All names generated with this function live in the "Core API" namespace and will not collide with names in other namespaces. Names in the "Core API" namespace cannot be called from Haskell code.
Use this function to create names used only inside Core code generated by your own Compiler, e.g. module-scoped or local functions.
Creates a new Core name. The generated name lives in the default namespace, hence may clash with Haskell-defined names.
mkHsName1 :: String -> HsName Source
Creates a new Core name. The generated name lives in the default namespace, hence may clash with Haskell-defined names.
addHsNamePrefix :: String -> HsName -> HsName Source
Adds an additional prefix to a HsName
. This can be used to derive a new
unique name from an existing name.
Construction functions
Constants
acoreInt :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => EHCOpts -> Int -> e Source
Creates an Int
constant.
Creates a Core Integer
constant.
Creates a string expression. The expression represents a packed String, which can be passed to Haskell generated Core functions.
:: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a | |
=> EHCOpts | |
-> String | The error message. |
-> e |
Generates an error expression, failing with the given string when evaluated. (error
in haskell)
acoreBuiltinUndefined :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => EHCOpts -> e Source
Generates an undefined expression, failing when evaluated. (undefined
in haskell)
Variables
acoreVar :: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt => HsName -> expr Source
Creates a variable expression.
Let Bindings
:: (Eq bcat, AbstractCore e m b bound boundmeta bcat mbind t p pr pf a) | |
=> HsName | The identifier. |
-> e | The expression to bind. |
-> e | The body. |
-> e |
Creates a (non-recursive) let binding.
:: (Eq bcat, AbstractCore e m b bound boundmeta bcat mbind t p pr pf a) | |
=> HsName | The identifer. |
-> e | The expression to bind. Will be evaluated to WHNF, before the body is evaluated. |
-> e | The body. |
-> e |
Creates a let binding, which is strict in the bound expression.
:: (Eq bcat, AbstractCore e m b bound boundmeta bcat mbind t p pr pf a) | |
=> [b] | The bindings. |
-> e | The body. |
-> e |
Creates a let binding, where the bindings may be mutually recursive.
Case
Scrutinizes an expression and executes the appropriate alternative. The scrutinee of a case statement is required to be in WHNF (weak head normal form).
:: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a | |
=> e | The scrutinee. Required to be in WHNF. |
-> [a] | The alternatives. |
-> Maybe e | The default value. (TODO what is the behaviour if it is Nothing?) |
-> e |
A Case expression, possibly with a default value.
:: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt | |
=> pat | The pattern with which to match the case scrutinee. |
-> expr | The value of this alternative. |
-> alt |
Creates an alternative of a case statement.
:: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt | |
=> CTag | The constructor to match. |
-> patrest | ??? |
-> [patfld] | ??? |
-> pat |
Matches the case scrutinee with the given constructor tag.
acorePatRestEmpty :: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt => patrest Source
patrest, empty TODO what does it mean?
:: AbstractCore expr metaval bind bound boundmeta bindcateg metabind ty pat patrest patfld alt | |
=> (HsName, expr) | lbl, offset ??? |
-> bind | ?? |
-> patfld |
TODO ??? pat field
Abstraction
Application
:: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a | |
=> e | The lambda to apply. |
-> [e] | The arguments (the empty list is allowed). |
-> e |
Applies the first expression to all given arguments.
Datatypes
acoreTagTup :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => CTag -> [e] -> e Source
Creates a new tuple/record with the given values.
Binds/Bounds
acoreBind1 :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => HsName -> e -> b Source
acoreBind1Nm1 :: AbstractCore e m b bound boundmeta bcat mbind t p pr pf a => HsName -> b Source
Module
:: HsName | The name of the module. |
-> [CImport] | The imports (only direct imports, not transitive ones). |
-> [CDeclMeta] | The meta information. |
-> CExpr | The body of the module. |
-> CModule |
Creates a module.
Creates the metadata for one datatype.
:: HsName | The fully qualified name of the constructor. |
-> Int | The tag of this constructor. |
-> Int | The arity of this constructor. |
-> CDataCon |
Creates the metadata for one constructor.