e => (e)Moduleghc-lib-parser-9.14.1.20251220GHC2021
GHC.Hs.Utils
Here we collect a variety of helper functions that construct or analyse HsSyn. All these functions deal with generic HsSyn; functions which deal with the instantiated versions are located elsewhere:
Parameterised by Module ---------------- ------------- GhcPs/RdrName GHC.Parser.PostProcess GhcRn/Name GHC.Rename.* GhcTc/Id GHC.Tc.Zonk.Type
The mk* functions attempt to construct a not-completely-useless SrcSpan
from their components, compared with the nl* functions which
just attach noSrcSpan to everything.
Synopsis
- value mkHsPar
- value mkHsApp
- value mkHsAppWith
- value mkHsApps
- value mkHsAppsWith
- value mkHsSyntaxApps
- value mkHsAppType
- value mkHsAppTypes
- value mkHsCaseAlt
- value mkSimpleMatch
- value unguardedGRHSs
- value unguardedRHS
- value mkMatchGroup
- value mkLamCaseMatchGroup
- value mkMatch
- value mkPrefixFunRhs
- value mkHsLam
- value mkHsIf
- value mkHsWrap
- value mkLHsWrap
- value mkHsWrapCo
- value mkHsWrapCoR
- value mkLHsWrapCo
- value mkHsDictLet
- value mkHsLams
- value mkHsOpApp
- value mkHsDo
- value mkHsDoAnns
- value mkHsComp
- value mkHsCompAnns
- value mkHsWrapPat
- value mkLHsWrapPat
- value mkHsWrapPatCo
- value mkLHsPar
- value mkHsCmdWrap
- value mkLHsCmdWrap
- value mkHsCmdIf
- value mkConLikeTc
- value nlHsTyApp
- value nlHsTyApps
- value nlHsVar
- value nlHsDataCon
- value nlHsLit
- value nlHsApp
- value nlHsApps
- value nlHsSyntaxApps
- value nlHsIntLit
- value nlHsVarApps
- value nlHsDo
- value nlHsOpApp
- value nlHsLam
- value nlHsPar
- value nlHsIf
- value nlHsCase
- value nlList
- value mkLHsTupleExpr
- value mkLHsVarTuple
- value missingTupArg
- value mkLocatedList
- value nlAscribe
- value forgetUserRdr
- value noUserRdr
- value mkFunBind
- value mkVarBind
- value mkHsVarBind
- value mkSimpleGeneratedFunBind
- value mkTopFunBind
- value mkPatSynBind
- value isInfixFunBind
- value spanHsLocaLBinds
- value mkHsIntegral
- value mkHsFractional
- value mkHsIsString
- value mkHsString
- value mkHsStringFS
- value mkHsStringPrimLit
- value mkHsCharPrimLit
- value mkNPat
- value mkNPlusKPat
- value nlVarPat
- value nlLitPat
- value nlConVarPat
- value nlConVarPatName
- value nlConPat
- value nlConPatName
- value nlInfixConPat
- value nlNullaryConPat
- value nlWildConPat
- value nlWildPat
- value nlWildPatName
- value nlTuplePat
- value mkParPat
- value nlParPat
- value mkBigLHsVarTup
- value mkBigLHsTup
- value mkBigLHsVarPatTup
- value mkBigLHsPatTup
- value mkHsAppTy
- value mkHsAppKindTy
- value hsTypeToHsSigType
- value hsTypeToHsSigWcType
- value mkClassOpSigs
- value mkHsSigEnv
- value nlHsAppTy
- value nlHsAppKindTy
- value nlHsTyVar
- value nlHsFunTy
- value nlHsParTy
- value nlHsTyConApp
- value mkTransformStmt
- value mkTransformByStmt
- value mkBodyStmt
- value mkPsBindStmt
- value mkRnBindStmt
- value mkTcBindStmt
- value mkLastStmt
- value emptyTransStmt
- value mkGroupUsingStmt
- value mkGroupByUsingStmt
- value emptyRecStmt
- value emptyRecStmtName
- value emptyRecStmtId
- value mkRecStmt
- value unitRecStmtTc
- value mkLetStmt
- value isUnliftedHsBind
- value isUnliftedHsBinds
- value isBangedHsBind
- value collectLocalBinders
- value collectHsValBinders
- value collectHsBindListBinders
- value collectHsIdBinders
- value collectHsBindsBinders
- value collectHsBindBinders
- value collectMethodBinders
- value collectPatBinders
- value collectPatsBinders
- value collectLStmtsBinders
- value collectStmtsBinders
- value collectLStmtBinders
- value collectStmtBinders
- class CollectPass
- data CollectFlag
- data TyDeclBinders
- data LConsWithFields
- value hsLTyClDeclBinders
- value hsTyClForeignBinders
- value hsPatSynSelectors
- value getPatSynBinds
- value hsForeignDeclsBinders
- value hsGroupBinders
- value hsDataFamInstBinders
- data ImplicitFieldBinders
- value lStmtsImplicits
- value hsValBindsImplicits
- value lPatImplicits
- value lHsRecFieldsImplicits
- Packageghc-lib-parser-9.14.1.20251220
- Exports157
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceUtils.hs
Terms
A simple case alternative with a single pattern, no binds, no guards; pre-typechecking
Make a prefix, non-strict function HsMatchContext
A useful function for building OpApps. The operator is always a
variable, and we don't know the fixity yet.
Wrap in parens if hsExprNeedsParens appPrec says it needs them
So f x becomes (f x), but 3 stays as 3.
Type ascription: (e :: ty)
Bindings
Not infix, with place holders for coercion and free vars
Convenience function using mkFunBind. This is for generated bindings only, do not use for user-written code.
In Name-land, with empty bind_fvs
Return the SrcSpan encompassing the contents of any enclosed binds
Literals
Patterns
Wildcard pattern - after parsing
Wildcard pattern - after renaming
The Big equivalents for the source tuple expressions
The Big equivalents for the source tuple patterns
Types
Convert an LHsType to an LHsSigType.
Convert an LHsType to an LHsSigWcType.
Convert TypeSig to ClassOpSig. The former is what is parsed, but the latter is what we need in class/instance declarations
Stmts
Collecting binders
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 [isUnliftedHsBind]. For usage information, see Note [Strict binds checks] is GHC.HsToCore.Binds.
Is a binding a strict variable or pattern bind (e.g. !x = ...)?
Same as collectHsBindsBinders, but works over a list of bindings
Collect both Ids and pattern-synonym binders
Used exclusively for the bindings of an instance decl which are all
FunBinds
This class specifies how to collect variable identifiers from extension patterns in the given pass. Consumers of the GHC API that define their own passes should feel free to implement instances in order to make use of functions which depend on it.
In particular, Haddock already makes use of this, with an instance for its DocNameI pass so that
it can reuse the code in GHC for collecting binders.
Methods
collectXXPat :: CollectFlag p -> XXPat p -> [IdP p] -> [IdP p]collectXXHsBindsLR :: XXHsBindsLR p pR -> [IdP p] -> [IdP p]collectXSplicePat :: CollectFlag p -> XSplicePat p -> [IdP p] -> [IdP p]
Instances1CollectPass
IsPass p => CollectPass (GhcPass p)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Utils
Indicate if evidence binders and type variable binders have to be collected.
This type enumerates the modes of collecting bound variables | evidence | type | term | ghc | | binders | variables | variables | pass | -------------------------------------------- CollNoDictBinders | no | no | yes | any | CollWithDictBinders | yes | no | yes | GhcTc | CollVarTyVarBinders | no | yes | yes | GhcRn |
See Note [Dictionary binders in ConPatOut]
Constructors
CollNoDictBinders :: CollectFlag pDon't collect evidence binders
CollWithDictBinders :: CollectFlag (GhcPass 'Typechecked)Collect evidence binders
CollVarTyVarBinders :: CollectFlag (GhcPass 'Renamed)Collect variable and type variable binders, but no evidence binders
Constructors
TyDeclBinderstyDeclMainBinder :: !(LocatedA (IdP (GhcPass p)), TyConFlavour ())tyDeclATs :: ![(LocatedA (IdP (GhcPass p)), TyConFlavour ())]tyDeclOpSigs :: ![LocatedA (IdP (GhcPass p))]tyDeclConsWithFields :: !LConsWithFields p
A mapping from constructors to all of their fields.
See Note [Collecting record fields in data declarations].
Constructors
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]
Collects record pattern-synonym selectors only; the pattern synonym names are collected by collectHsValBinders.
See Note [SrcSpan for binders]
the SrcLoc returned are for the whole declarations, not just the names
Collecting implicit binders
All binders corresponding to a single implicit record field pattern.
See Note [Collecting implicit binders].
Constructors
ImplicitFieldBindersimplFlBndr_field :: NameThe Name of the record field
implFlBndr_binders :: [Name]The binders of the RHS of the record field pattern (in practice, always a singleton: see Note [Collecting implicit binders])
Collect all record wild card binders in the given pattern.
These are all the variables bound in all (possibly nested) record wildcard patterns appearing inside the pattern.
See Note [Collecting implicit binders].