Safe Haskell | None |
---|
- data Core
- data CoreProg
- data CoreDef = Def Id CoreExpr
- type CoreTickish = Tickish Id
- defsToRecBind :: [CoreDef] -> CoreBind
- defToIdExpr :: CoreDef -> (Id, CoreExpr)
- progToBinds :: CoreProg -> [CoreBind]
- bindsToProg :: [CoreBind] -> CoreProg
- bindToIdExprs :: CoreBind -> [(Id, CoreExpr)]
- isType :: CoreExpr -> Bool
- typeExprToType :: CoreExpr -> Maybe Type
- exprTypeOrKind :: CoreExpr -> Type
- appCount :: CoreExpr -> Int
Generic Data Type
NOTE: Type
is not included in the generic datatype.
However, we could have included it and provided the facility for descending into types.
We have not done so because
(a) we do not need that functionality, and
(b) the types are complicated and we're not sure that we understand them.
Core is the sum type of all nodes in the AST that we wish to be able to traverse.
All Node
instances in HERMIT define their Generic
type to be Core
.
A program is a telescope of nested binding groups.
That is, each binding scopes over the remainder of the program.
In GHC Core, programs are encoded as [CoreBind
].
This data type is isomorphic.
type CoreTickish = Tickish IdSource
Conversions to/from Core
defsToRecBind :: [CoreDef] -> CoreBindSource
Convert a list of recursive definitions into an (isomorphic) recursive binding group.
defToIdExpr :: CoreDef -> (Id, CoreExpr)Source
Convert a definition to an identifier/expression pair.
progToBinds :: CoreProg -> [CoreBind]Source
Get the list of bindings in a program.
bindsToProg :: [CoreBind] -> CoreProgSource
Build a program from a list of bindings. Note that bindings earlier in the list are considered scope over bindings later in the list.
bindToIdExprs :: CoreBind -> [(Id, CoreExpr)]Source
Extract the list of identifier/expression pairs from a binding group.
Utilities
exprTypeOrKind :: CoreExpr -> TypeSource