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

GHC.Rename.Utils

Synopsis

Documentation

dupNamesErr :: Outputable n => (n -> SrcSpan) -> NonEmpty n -> RnM () Source #

checkTupSize :: Int -> TcM () Source #

Ensure that a boxed or unboxed tuple has arity no larger than mAX_TUPLE_SIZE.

checkCTupSize :: Int -> TcM () Source #

Ensure that a constraint tuple has arity no larger than mAX_CTUPLE_SIZE.

addFvRn :: FreeVars -> RnM (thing, FreeVars) -> RnM (thing, FreeVars) Source #

mapFvRn :: (a -> RnM (b, FreeVars)) -> [a] -> RnM ([b], FreeVars) Source #

mapMaybeFvRn :: (a -> RnM (b, FreeVars)) -> Maybe a -> RnM (Maybe b, FreeVars) Source #

checkUnusedRecordWildcard :: SrcSpan -> FreeVars -> Maybe [Name] -> RnM () Source #

Checks to see if we need to warn for -Wunused-record-wildcards or -Wredundant-record-wildcards

mkFieldEnv :: GlobalRdrEnv -> NameEnv (FieldLabelString, Parent) Source #

Make a map from selector names to field labels and parent tycon names, to be used when reporting unused record fields.

checkInferredVars Source #

Arguments

:: HsDocContext 
-> Maybe SDoc

The error msg if the signature is not allowed to contain manually written inferred variables.

-> LHsSigType GhcPs 
-> RnM () 

Throw an error message if a user attempts to quantify an inferred type variable in a place where specificity cannot be observed. For example, forall {a}. [a] -> [a] would be rejected to the inferred type variable {a}, but forall a. [a] -> [a] would be accepted. See Note [Unobservably inferred type variables].

noNestedForallsContextsErr :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) Source #

Examines a non-outermost type for foralls or contexts, which are assumed to be nested. For example, in the following declaration:

instance forall a. forall b. C (Either a b)

The outermost forall a is fine, but the nested forall b is not. We invoke noNestedForallsContextsErr on the type forall b. C (Either a b) to catch the nested forall and create a suitable error message. noNestedForallsContextsErr returns Just err_msg if such a forall or context is found, and returns Nothing otherwise.

This is currently used in the following places:

  • In GADT constructor types (in rnConDecl). See Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts) in GHC.Hs.Type.
  • In instance declaration types (in rnClsIntDecl and rnSrcDerivDecl in GHC.Rename.Module and renameSig in GHC.Rename.Bind). See Note [No nested foralls or contexts in instance types] in GHC.Hs.Type.