HORIZON HASKELLDocslts/ghc-10.0.x8174fa42026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

Moduleghc-10.0.0.20260917GHC2024

GHC.Parser.PostProcess

  • 12 types
  • 3 classes
  • 101 values
valuemkTyClD :: LTyClDecl (GhcPass p) -> LHsDecl (GhcPass p)
#

mkClassDecl builds a RdrClassDecl, filling in the names for tycon and datacon by deriving them from the name of the class. We fill in the names for the tycon and datacon corresponding to the class, by deriving them from the name of the class itself. This saves recording the names in the interface file (which would be equally good).

This rather gruesome function is used mainly by the parser.

Case #1. When parsing:

data T a = T | T1 Int

we parse the data constructors as types because of parser ambiguities, so then we need to change the type constr to a data constr

The exact-name case can occur when parsing:

data [] a = [] | a : [a]

For the exact-name case we return an original name.

Case #2. When parsing:

x = fn (forall a. a)   -- RequiredTypeArguments

we use setRdrNameSpace to set the namespace of forall-bound variables.

Function definitions are restructured here. Each is assumed to be recursive initially, and non recursive definitions are discovered by the dependency analyser.

Construct a GADT-style data constructor from the constructor names and their type. Some interesting aspects of this function:

  • This splits up the constructor type into its quantified type variables (if provided), context (if provided), argument types, and result type, and records whether this is a prefix or record GADT constructor. See Note [GADT abstract syntax] in GHC.Hs.Decls for more details.

Validate the context constraints and break up a context into a list of predicates.

    (Eq a, Ord b)        -->  [Eq a, Ord b]
    Eq a                 -->  [Eq a]
    (Eq a)               -->  [Eq a]
    (((Eq a)))           -->  [Eq a]
newtypenewtype PV a
#
Instances4Monad, Functor, Applicative, MonadP
  • Monad PVDefined in ghc-10.0.0.20260917 · GHC.Parser.PostProcess
  • Functor PVDefined in ghc-10.0.0.20260917 · GHC.Parser.PostProcess
  • Applicative PVDefined in ghc-10.0.0.20260917 · GHC.Parser.PostProcess
  • MonadP PVDefined in ghc-10.0.0.20260917 · GHC.Parser.PostProcess
classclass (b ~ Body b GhcPs, AnnoBody b) => DisambECP b where
#

Disambiguate constructs that may appear when we do not know ahead of time whether we are parsing an expression, a command, or a pattern. See Note [Ambiguous syntactic categories]

Associated types

  • type family Body b :: Type -> Type

    See Note [Body in DisambECP]

  • type family InfixOp b

    Infix operator representation

  • type family FunArg b

    Function argument representation

Methods

Instances3DisambECP
datadata PatBuilder p
#

See Note [Ambiguous syntactic categories] and Note [PatBuilder]

Instances10Outputable, DisambECP, Anno, Body, FunArg, InfixOp, …
classclass DisambTD b where
#

Disambiguate constructs that may appear when we do not know ahead of time whether we are parsing a type or a newtype/data constructor.

See Note [Ambiguous syntactic categories] for the general idea.

See Note [Parsing data constructors is hard] for the specific issue this particular class is solving.

Methods

Instances2DisambTD
valuemkTupleSyntaxTy
  1. :: EpToken "("
  2. -> [LocatedA (HsType GhcPs)]
  3. -> EpToken ")"
  4. -> P (HsType GhcPs)
#

Decide whether to parse tuple syntax (Int, Double) in a type as a type or data constructor, based on the extension ListTuplePuns. The case with an explicit promotion quote, '(Int, Double), is handled by mkExplicitTupleTy.

Decide whether to parse tuple con syntax (,) in a type as a type or data constructor, based on the extension ListTuplePuns. The case with an explicit promotion quote, '(,), is handled by the rule SIMPLEQUOTE sysdcon_nolist in atype.

valuemkListSyntaxTy0 :: EpToken "[" -> EpToken "]" -> SrcSpan -> P (HsType GhcPs)
#

Decide whether to parse list tycon syntax [] in a type as a type or data constructor, based on the extension ListTuplePuns. The case with an explicit promotion quote, '[], is handled by mkExplicitListTy.

Decide whether to parse list type syntax [Int] in a type as a type or data constructor, based on the extension ListTuplePuns. The case with an explicit promotion quote, '[Int], is handled by mkExplicitListTy.