ghc-9.12: The GHC API
Safe HaskellNone
LanguageGHC2021

GHC.HsToCore.Utils

Description

Utility functions for constructing Core syntax, principally for desugaring

Synopsis

Documentation

data EquationInfo Source #

Constructors

EqnMatch 

Fields

  • eqn_pat :: LPat GhcTc

    The first pattern of the equation

    NB: The location info is used to determine whether the pattern is generated or not. This helps us avoid warnings on patterns that GHC elaborated.

    NB: We have already applied decideBangHood to this pattern. See Note [decideBangHood] in GHC.HsToCore.Utils

  • eqn_rest :: EquationInfo

    The rest of the equation after its first pattern

EqnDone (MatchResult CoreExpr)

What to do after match

Instances

Instances details
Outputable EquationInfo Source # 
Instance details

Defined in GHC.HsToCore.Monad

data MatchResult a Source #

This is a value of type a with potentially a CoreExpr-shaped hole in it. This is used to deal with cases where we are potentially handling pattern match failure, and want to later specify how failure is handled.

Constructors

MR_Infallible (DsM a)

We represent the case where there is no hole without a function from CoreExpr, like this, because sometimes we have nothing to put in the hole and so want to be sure there is in fact no hole.

MR_Fallible (CoreExpr -> DsM a) 

Instances

Instances details
Applicative MatchResult Source #

Product is an "or" on fallibility---the combined match result is infallible only if the left and right argument match results both were.

This is useful for combining a bunch of alternatives together and then getting the overall fallibility of the entire group. See mkDataConCase for an example.

Instance details

Defined in GHC.HsToCore.Monad

Methods

pure :: a -> MatchResult a #

(<*>) :: MatchResult (a -> b) -> MatchResult a -> MatchResult b #

liftA2 :: (a -> b -> c) -> MatchResult a -> MatchResult b -> MatchResult c #

(*>) :: MatchResult a -> MatchResult b -> MatchResult b #

(<*) :: MatchResult a -> MatchResult b -> MatchResult a #

Functor MatchResult Source # 
Instance details

Defined in GHC.HsToCore.Monad

Methods

fmap :: (a -> b) -> MatchResult a -> MatchResult b #

(<$) :: a -> MatchResult b -> MatchResult a #

mkCoAlgCaseMatchResult Source #

Arguments

:: Id

Scrutinee

-> Type

Type of exp

-> NonEmpty (CaseAlt DataCon)

Alternatives (bndrs *include* tyvars, dicts)

-> MatchResult CoreExpr 

mkSelectorBinds Source #

Arguments

:: [[CoreTickish]]

ticks to add, possibly

-> LPat GhcTc

The pattern

-> HsMatchContextRn

Where the pattern occurs

-> CoreExpr

Expression to which the pattern is bound

-> DsM (Id, [(Id, CoreExpr)])

Id the rhs is bound to, for desugaring strict binds (see Note [Desugar Strict binds] in GHC.HsToCore.Binds) and all the desugared binds

decideBangHood Source #

Arguments

:: DynFlags 
-> LPat GhcTc

Original pattern

-> LPat GhcTc 

Use -XStrict to add a ! or remove a ~ See Note [decideBangHood]