ghc-8.8.1: The GHC API
Safe HaskellNone
LanguageHaskell2010

HsUtils

Synopsis

Documentation

mkHsCaseAlt :: LPat (GhcPass p) -> Located (body (GhcPass p)) -> LMatch (GhcPass p) (Located (body (GhcPass p))) Source #

A simple case alternative with a single pattern, no binds, no guards; pre-typechecking

unguardedGRHSs :: Located (body (GhcPass p)) -> GRHSs (GhcPass p) (Located (body (GhcPass p))) Source #

unguardedRHS :: SrcSpan -> Located (body (GhcPass p)) -> [LGRHS (GhcPass p) (Located (body (GhcPass p)))] Source #

mkMatchGroup :: XMG name (Located (body name)) ~ NoExt => Origin -> [LMatch name (Located (body name))] -> MatchGroup name (Located (body name)) Source #

mkPrefixFunRhs :: Located id -> HsMatchContext id Source #

Make a prefix, non-strict function HsMatchContext

nlHsTyApps :: IdP (GhcPass id) -> [Type] -> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id) Source #

typeToLHsType :: Type -> LHsType GhcPs Source #

Converting a Type to an HsType RdrName This is needed to implement GeneralizedNewtypeDeriving.

Note that we use getRdrName extensively, which generates Exact RdrNames rather than strings.

Constructing general big tuples

GHCs built in tuples can only go up to mAX_TUPLE_SIZE in arity, but we might concievably want to build such a massive tuple as part of the output of a desugaring stage (notably that for list comprehensions).

We call tuples above this size "big tuples", and emulate them by creating and pattern matching on >nested< tuples that are expressible by GHC.

Nesting policy: it's better to have a 2-tuple of 10-tuples (3 objects) than a 10-tuple of 2-tuples (11 objects), so we want the leaves of any construction to be big.

If you just use the mkBigCoreTup, mkBigCoreVarTupTy, mkTupleSelector and mkTupleCase functions to do all your work with tuples you should be fine, and not have to worry about the arity limitation at all.

mkChunkified Source #

Arguments

:: ([a] -> a)

"Small" constructor function, of maximum input arity mAX_TUPLE_SIZE

-> [a]

Possible "big" list of things to construct from

-> a

Constructed thing made possible by recursive decomposition

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

chunkify :: [a] -> [[a]] Source #

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

isInfixFunBind :: HsBindLR id1 id2 -> Bool Source #

If any of the matches in the FunBind are infix, the FunBind is considered infix.

mkParPat :: LPat (GhcPass name) -> LPat (GhcPass name) Source #

nlParPat :: LPat (GhcPass name) -> LPat (GhcPass name) Source #

mkHsSigEnv :: forall a. (LSig GhcRn -> Maybe ([Located Name], a)) -> [LSig GhcRn] -> NameEnv a Source #

mkBindStmt :: XBindStmt (GhcPass idL) (GhcPass idR) (Located (bodyR (GhcPass idR))) ~ NoExt => LPat (GhcPass idL) -> Located (bodyR (GhcPass idR)) -> StmtLR (GhcPass idL) (GhcPass idR) (Located (bodyR (GhcPass idR))) Source #

mkLastStmt :: Located (bodyR (GhcPass idR)) -> StmtLR (GhcPass idL) (GhcPass idR) (Located (bodyR (GhcPass idR))) Source #

mkRecStmt :: [LStmtLR (GhcPass idL) GhcPs bodyR] -> StmtLR (GhcPass idL) GhcPs bodyR Source #

isUnliftedHsBind :: HsBind GhcTc -> Bool Source #

Should we treat this as an unlifted bind? This will be true for any bind that binds an unlifted variable, but we must be careful around AbsBinds. See Note [Unlifted id check in isUnliftedHsBind]. For usage information, see Note [Strict binds check] is DsBinds.

isBangedHsBind :: HsBind GhcTc -> Bool Source #

Is a binding a strict variable or pattern bind (e.g. !x = ...)?

collectLStmtsBinders :: [LStmtLR (GhcPass idL) (GhcPass idR) body] -> [IdP (GhcPass idL)] Source #

collectStmtsBinders :: [StmtLR (GhcPass idL) (GhcPass idR) body] -> [IdP (GhcPass idL)] Source #

collectLStmtBinders :: LStmtLR (GhcPass idL) (GhcPass idR) body -> [IdP (GhcPass idL)] Source #

collectStmtBinders :: StmtLR (GhcPass idL) (GhcPass idR) body -> [IdP (GhcPass idL)] Source #

hsLTyClDeclBinders :: Located (TyClDecl pass) -> ([Located (IdP pass)], [LFieldOcc pass]) Source #

Returns all the binding names of the decl. The first one is guaranteed to be the name of the decl. The first component represents all binding names except record fields; the second represents field occurrences. For record fields mentioned in multiple constructors, the SrcLoc will be from the first occurrence.

Each returned (Located name) has a SrcSpan for the whole declaration. See Note [SrcSpan for binders]