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)]
- isCoArg :: CoreExpr -> Bool
- exprTypeOrKind :: CoreExpr -> Type
- endoFunType :: Monad m => CoreExpr -> m Type
- funArgResTypes :: Monad m => CoreExpr -> m (Type, Type)
- funsWithInverseTypes :: MonadCatch m => CoreExpr -> CoreExpr -> m (Type, Type)
- appCount :: CoreExpr -> Int
Generic Data Type
NOTE: Type
is not included in the sum type.
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.
GutsCore ModGuts | The module. |
ProgCore CoreProg | A program (a telescope of top-level binding groups). |
BindCore CoreBind | A binding group. |
DefCore CoreDef | A recursive definition. |
ExprCore CoreExpr | An expression. |
AltCore CoreAlt | A case alternative. |
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
isCoArg :: CoreExpr -> BoolSource
Returns True
iff the expression is a Coercion
expression at its top level.
exprTypeOrKind :: CoreExpr -> TypeSource
endoFunType :: Monad m => CoreExpr -> m TypeSource
Return the domain/codomain type of an endofunction expression.
funArgResTypes :: Monad m => CoreExpr -> m (Type, Type)Source
Return the domain and codomain types of a function expression.
funsWithInverseTypes :: MonadCatch m => CoreExpr -> CoreExpr -> m (Type, Type)Source
Check two expressions have types a -> b
and b -> a
, returning (a,b)
.