ghc-8.8.1: The GHC API

RdrHsSyn

Synopsis

# Documentation

mkTyClD :: LTyClDecl (GhcPass p) -> LHsDecl (GhcPass p) Source #

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. 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.

Replaces constraint tuple names with corresponding boxed ones.

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

Take a type-family instance declaration and turn it into a type-family default equation for a class declaration. We parse things as the former and use this function to convert to the latter

We use the Either monad because this also called from Convert.

The P () we return corresponds represents an action which will add some necessary paren annotations to the parsing context. Naturally, this is not something that the Convert use cares about.

Yield a parse error if we have a function applied directly to a do block etc. and BlockArguments is not enabled.

Arguments

 :: Located (SourceText, Int) precedence -> Located (OrdList (Located RdrName)) operators -> P ()

Check if a fixity is valid. We support bypassing the usual bound checks for some special operators.

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]


If the flag MonadComprehensions is set, return a MonadComp context, otherwise use the usual ListComp context

Essentially a wrapper for a RuleBndr GhcPs

Constructors

 RuleTyTmVar (Located RdrName) (Maybe (LHsType GhcPs))

Check if the gadt_constrlist is empty. Only raise parse error for data T where to avoid affecting existing error message, see #8258.

Hint about bang patterns, assuming BangPatterns is off.

data TyEl Source #

Either an operator or an operand.

Constructors

 TyElOpr RdrName TyElOpd (HsType GhcPs) TyElKindApp SrcSpan (LHsType GhcPs) TyElTilde TyElBang TyElUnpackedness ([AddAnn], SourceText, SrcUnpackedness) TyElDocPrev HsDocString

#### Instances

Instances details
 # Instance detailsDefined in RdrHsSyn Methods

mergeOps :: [Located TyEl] -> P (LHsType GhcPs) Source #

Merge a reversed and non-empty soup of operators and operands into a type.

User input: F x y + G a b * X Input to mergeOps: [X, *, b, a, G, +, y, x, F] Output corresponds to what the user wrote assuming all operators are of the same fixity and right-associative.

It's a bit silly that we're doing it at all, as the renamer will have to rearrange this, and it'd be easier to keep things separate.

See Note [Parsing data constructors is hard]

Merge a reversed and non-empty soup of operators and operands into a data constructor.

User input: C !A B -- ^ doc Input to mergeDataCon: ["doc", B, !, A, C] Output: (C, PrefixCon [!A, B], "doc")

See Note [Parsing data constructors is hard] See Note [isFunLhs vs mergeDataCon]

Constructors

 ImpExpAbs ImpExpAll ImpExpList [Located ImpExpQcSpec] ImpExpAllWith [Located ImpExpQcSpec]

Constructors

 ImpExpQcName (Located RdrName) ImpExpQcType (Located RdrName) ImpExpQcWildcard

Constructors

 Sum ConTag Arity (LHsExpr GhcPs) Tuple [LHsTupArg GhcPs]