ghc-9.4.0.20220623: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.HsToCore.Utils

Description

Utility functions for constructing Core syntax, principally for desugaring

Synopsis

Documentation

data EquationInfo Source #

Constructors

EqnInfo 

Fields

  • eqn_pats :: [Pat GhcTc]

    The patterns for an equation

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

  • eqn_orig :: Origin

    Was this equation present in the user source?

    This helps us avoid warnings on patterns that GHC elaborated.

    For instance, the pattern -1 :: Word gets desugared into W# -1## :: Word, but we shouldn't warn about an overflowed literal for both of these cases.

  • eqn_rhs :: 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 falliblity---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 falliblity of the entire group. See mkDataConCase for an example.

Instance details

Defined in GHC.HsToCore.Monad

Functor MatchResult Source # 
Instance details

Defined in GHC.HsToCore.Monad

Methods

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

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

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

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