e => (e)Moduleghc-9.10.3GHC2021
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.
- 4 types
- 1 class
- 150 values
- Packageghc-9.10.3
- Exports155
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceUtils.hs
Terms
60 declarationsA 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.
Bindings
8 declarationsNot 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
7 declarationsPatterns
20 declarationsWildcard pattern - after parsing
Wildcard pattern - after renaming
The Big equivalents for the source tuple expressions
The Big equivalents for the source tuple patterns
Types
12 declarationsConvert 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
16 declarationsCollecting binders
27 declarationsShould 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-9.10.3 · 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
5 declarationsAll 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].