HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

  • Packageghc-9.10.3
  • Exports65
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceMake.hs

Constructing normal syntax

12 declarations

Bind a binding group over an expression, using a let or case as appropriate (see GHC.Core#let_can_float_invariant)

valuemkCoreLets :: [CoreBind] -> CoreExpr -> CoreExpr
#

Bind a list of binding groups over an expression. The leftmost binding group becomes the outermost group in the resulting expression

valuemkCoreApps
  1. :: CoreExpr

    function

  2. -> [CoreExpr]

    arguments

  3. -> CoreExpr
#

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

valuemkCoreLams :: [CoreBndr] -> CoreExpr -> CoreExpr
#

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

valuemkWildValBinder :: Mult -> Type -> Id
#

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

valuesortQuantVars :: [Var] -> [Var]
#

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 declarations

Floats

4 declarations

Constructing small tuples

6 declarations
valuemkCoreVarTupTy :: [Id] -> Type
#

Build the type of a small tuple that holds the specified variables One-tuples are flattened; see Note [Flattening one-tuples]

valuemkCoreTup :: [CoreExpr] -> CoreExpr
#

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]

Constructing big tuples

7 declarations
valuemkChunkified
  1. :: ([a] -> a)

    "Small" constructor function, of maximum input arity mAX_TUPLE_SIZE

  2. -> [a]

    Possible "big" list of things to construct from

  3. -> a

    Constructed thing made possible by recursive decomposition

#

Lifts a "small" constructor into a "big" constructor by recursive decomposition

valuechunkify :: [a] -> [[a]]
#

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

valuemkBigCoreVarTup :: [Id] -> CoreExpr
#

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

valuemkBigCoreTup :: [CoreExpr] -> CoreExpr
#

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 declarations
valuemkBigTupleSelector
  1. :: [Id]

    The Ids to pattern match the tuple against

  2. -> Id

    The Id to select

  3. -> Id

    A variable of the same type as the scrutinee

  4. -> CoreExpr

    Scrutinee

  5. -> CoreExpr

    Selector expression

#

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])

valuemkBigTupleSelectorSolo
  1. :: [Id]

    The Ids to pattern match the tuple against

  2. -> Id

    The Id to select

  3. -> Id

    A variable of the same type as the scrutinee

  4. -> CoreExpr

    Scrutinee

  5. -> CoreExpr

    Selector expression

#

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.

valuemkBigTupleCase
  1. :: MonadUnique m
  2. => [Id]

    The tuple identifiers to pattern match on; Bring these into scope in the body

  3. -> CoreExpr

    Body of the case

  4. -> CoreExpr

    Scrutinee

  5. -> 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 declarations

Constructing Maybe expressions

2 declarations

Error Ids

11 declarations