Bind a binding group over an expression, using a let or case as
appropriate (see GHC.Core#let_can_float_invariant)
Moduleghc-9.10.3GHC2021
GHC.Core.Make
Handy functions for creating much Core syntax
- 2 types
- 63 values
- Packageghc-9.10.3
- Exports65
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceMake.hs
Constructing normal syntax
12 declarationsBind a list of binding groups over an expression. The leftmost binding group becomes the outermost group in the resulting expression
Construct an expression which represents the application of one expression to the other
Construct an expression which represents the application of a number of expressions to another. The leftmost expression in the list is applied first
Construct an expression which represents the application of a number of expressions to that of a data constructor expression. The leftmost expression in the list is applied first
Create a lambda where the given expression has a number of variables bound over it. The leftmost binder is that bound by the outermost lambda in the result
Make a case expression whose case binder is unused The alts and res_ty should not have any occurrences of WildId
Make a wildcard binder. This is typically used when you need a binder that you expect to use only at a *binding* site. Do not use it at occurrence sites because it has a single, fixed unique, and it's very easy to get into difficulties with shadowing. That's why it is used so little.
See Note [WildCard binders] in GHC.Core.Opt.Simplify.Env
Sort the variables, putting type and covars first, in scoped order, and then other Ids
It is a deterministic sort, meaning it doesn't look at the values of Uniques. For explanation why it's important See Note [Unique Determinism] in GHC.Types.Unique.
Constructing boxed literals
15 declarationsCreate a CoreExpr which will evaluate to a Word with the given value
Create a CoreExpr which will evaluate to the given Int
Create a CoreExpr which will evaluate to the given Int
Create a CoreExpr which will evaluate to the given Int. Don't check
that the number is in the range of the target platform Int
Create a CoreExpr which will evaluate to the given Integer
Create a CoreExpr which will evaluate to the given Natural
Create a CoreExpr which will evaluate to the given Float
Create a CoreExpr which will evaluate to the given Double
Create a CoreExpr which will evaluate to the given Char
Create a CoreExpr which will evaluate to the given String
Create a CoreExpr which will evaluate to a string morally equivalent to the given FastString
Constructors
Floats
4 declarationsInstances1Outputable
Outputable FloatBindDefined in ghc-9.10.3 · GHC.Core.Make
Applies the floats from right to left. That is wrapFloats [b1, b2, …, bn]
u = let b1 in let b2 in … in let bn in u
Constructing small tuples
6 declarationsBuild the type of a small tuple that holds the specified variables One-tuples are flattened; see Note [Flattening one-tuples]
Build a small tuple holding the specified expressions One-tuples are flattened; see Note [Flattening one-tuples]
Build a small unboxed tuple holding the specified expressions. Do not include the RuntimeRep specifiers; this function calculates them for you. Does not flatten one-tuples; see Note [Flattening one-tuples]
Build an unboxed sum.
Alternative number ("alt") starts from 1.
Make a core tuple of the given boxity; don't flatten 1-tuples
The unit expression
Constructing big tuples
7 declarationsmkChunkified :: ([a] -> a)"Small" constructor function, of maximum input arity mAX_TUPLE_SIZE
-> [a]Possible "big" list of things to construct from
-> aConstructed thing made possible by recursive decomposition
Lifts a "small" constructor into a "big" constructor by recursive decomposition
Split a list into lists that are small enough to have a corresponding tuple arity. The sub-lists of the result all have length <= mAX_TUPLE_SIZE But there may be more than mAX_TUPLE_SIZE sub-lists
Build a big tuple holding the specified variables One-tuples are flattened; see Note [Flattening one-tuples] Arguments don't have to have kind Type
Build the type of a big tuple that holds the specified variables One-tuples are flattened; see Note [Flattening one-tuples]
Build the type of a big tuple that holds the specified type of thing One-tuples are flattened; see Note [Flattening one-tuples]
Build a "big" tuple holding the specified expressions One-tuples are flattened; see Note [Flattening one-tuples] Arguments don't have to have kind Type; ones that do not are boxed This function crashes (in wrapBox) if given a non-Type argument that it doesn't know how to box.
Deconstructing big tuples
3 declarationsmkBigTupleSelector Builds a selector which scrutinises the given expression and extracts the one name from the list given. If you want the no-shadowing rule to apply, the caller is responsible for making sure that none of these names are in scope.
If there is just one Id in the tuple, then the selector is just the identity.
If necessary, we pattern match on a "big" tuple.
A tuple selector is not linear in its argument. Consequently, the case
expression built by mkBigTupleSelector must consume its scrutinee Many
times. And all the argument variables must have multiplicity Many.
mkBigTupleSelectorSolo is like mkBigTupleSelector but one-tuples are NOT flattened (see Note [Flattening one-tuples])
Builds a selector which scrutinises the given expression and extracts the one name from the list given. If you want the no-shadowing rule to apply, the caller is responsible for making sure that none of these names are in scope.
If there is just one Id in the tuple, then the selector is just the identity.
If necessary, we pattern match on a "big" tuple.
A tuple selector is not linear in its argument. Consequently, the case
expression built by mkBigTupleSelector must consume its scrutinee Many
times. And all the argument variables must have multiplicity Many.
mkBigTupleCase :: MonadUnique m=> [Id]The tuple identifiers to pattern match on; Bring these into scope in the body
-> CoreExprBody of the case
-> CoreExprScrutinee
-> m CoreExpr
A generalization of mkBigTupleSelector, allowing the body of the case to be an arbitrary expression.
To avoid shadowing, we use uniques to invent new variables.
If necessary we pattern match on a "big" tuple.
Constructing list expressions
5 declarationsMakes a list [] for lists of the specified type
Makes a list (:) for lists of the specified type
Make a list containing the given expressions, where the list has the given type
mkFoldrExpr Make a fully applied foldr expression
mkBuildExpr Make a build expression applied to a locally-bound worker function
Constructing Maybe expressions
2 declarationsMakes a Nothing for the specified type
Makes a Just from a value of the specified type