ghc-7.10.2: The GHC API

Safe Haskell | None
Language | Haskell2010

HsTypes

Synopsis

- data HsType name
  - = HsForAllTy HsExplicitFlag (Maybe SrcSpan) (LHsTyVarBndrs name) (LHsContext name) (LHsType name)
  - | HsTyVar name
  - | HsAppTy (LHsType name) (LHsType name)
  - | HsFunTy (LHsType name) (LHsType name)
  - | HsListTy (LHsType name)
  - | HsPArrTy (LHsType name)
  - | HsTupleTy HsTupleSort [LHsType name]
  - | HsOpTy (LHsType name) (LHsTyOp name) (LHsType name)
  - | HsParTy (LHsType name)
  - | HsIParamTy HsIPName (LHsType name)
  - | HsEqTy (LHsType name) (LHsType name)
  - | HsKindSig (LHsType name) (LHsKind name)
  - | HsQuasiQuoteTy (HsQuasiQuote name)
  - | HsSpliceTy (HsSplice name) (PostTc name Kind)
  - | HsDocTy (LHsType name) LHsDocString
  - | HsBangTy HsSrcBang (LHsType name)
  - | HsRecTy [LConDeclField name]
  - | HsCoreTy Type
  - | HsExplicitListTy (PostTc name Kind) [LHsType name]
  - | HsExplicitTupleTy [PostTc name Kind] [LHsType name]
  - | HsTyLit HsTyLit
  - | HsWrapTy HsTyWrapper (HsType name)
  - | HsWildcardTy
  - | HsNamedWildcardTy name
- type LHsType name = Located (HsType name)
- type HsKind name = HsType name
- type LHsKind name = Located (HsKind name)
- type HsTyOp name = (HsTyWrapper, name)
- type LHsTyOp name = HsTyOp (Located name)
- data HsTyVarBndr name
  - = UserTyVar name
  - | KindedTyVar (Located name) (LHsKind name)
- type LHsTyVarBndr name = Located (HsTyVarBndr name)
- data LHsTyVarBndrs name = HsQTvs {
  - hsq_kvs :: [Name]
  - hsq_tvs :: [LHsTyVarBndr name]
  }
- data HsWithBndrs name thing = HsWB {
  - hswb_cts :: thing
  - hswb_kvs :: PostRn name [Name]
  - hswb_tvs :: PostRn name [Name]
  - hswb_wcs :: PostRn name [Name]
  }
- data HsTupleSort
  - = HsUnboxedTuple
  - | HsBoxedTuple
  - | HsConstraintTuple
  - | HsBoxedOrConstraintTuple
- data HsExplicitFlag
  - = Qualified
  - | Implicit
  - | Explicit
- type HsContext name = [LHsType name]
- type LHsContext name = Located (HsContext name)
- data HsQuasiQuote id = HsQuasiQuote id SrcSpan FastString
- data HsTyWrapper = WpKiApps [Kind]
- data HsTyLit
  - = HsNumTy SourceText Integer
  - | HsStrTy SourceText FastString
- newtype HsIPName = HsIPName FastString
- hsIPNameFS :: HsIPName -> FastString
- type LBangType name = Located (BangType name)
- type BangType name = HsType name
- data HsBang
  - = HsNoBang
  - | HsSrcBang (Maybe SourceText) (Maybe Bool) Bool
  - | HsUnpack (Maybe Coercion)
  - | HsStrict
- type HsSrcBang = HsBang
- type HsImplBang = HsBang
- getBangType :: LHsType a -> LHsType a
- getBangStrictness :: LHsType a -> HsSrcBang
- data ConDeclField name = ConDeclField {
  - cd_fld_names :: [Located name]
  - cd_fld_type :: LBangType name
  - cd_fld_doc :: Maybe LHsDocString
  }
- type LConDeclField name = Located (ConDeclField name)
- pprConDeclFields :: OutputableBndr name => [LConDeclField name] -> SDoc
- mkHsQTvs :: [LHsTyVarBndr RdrName] -> LHsTyVarBndrs RdrName
- hsQTvBndrs :: LHsTyVarBndrs name -> [LHsTyVarBndr name]
- isHsKindedTyVar :: HsTyVarBndr name -> Bool
- hsTvbAllKinded :: LHsTyVarBndrs name -> Bool
- mkExplicitHsForAllTy :: [LHsTyVarBndr RdrName] -> LHsContext RdrName -> LHsType RdrName -> HsType RdrName
- mkImplicitHsForAllTy :: LHsType RdrName -> HsType RdrName
- mkQualifiedHsForAllTy :: LHsContext RdrName -> LHsType RdrName -> HsType RdrName
- mkHsForAllTy :: HsExplicitFlag -> [LHsTyVarBndr RdrName] -> LHsContext RdrName -> LHsType RdrName -> HsType RdrName
- flattenTopLevelLHsForAllTy :: LHsType name -> LHsType name
- flattenTopLevelHsForAllTy :: HsType name -> HsType name
- flattenHsForAllTyKeepAnns :: HsType name -> ([AddAnn], HsType name)
- hsExplicitTvs :: LHsType Name -> [Name]
- hsTyVarName :: HsTyVarBndr name -> name
- mkHsWithBndrs :: thing -> HsWithBndrs RdrName thing
- hsLKiTyVarNames :: LHsTyVarBndrs Name -> [Name]
- hsLTyVarName :: LHsTyVarBndr name -> name
- hsLTyVarNames :: LHsTyVarBndrs name -> [name]
- hsLTyVarLocName :: LHsTyVarBndr name -> Located name
- hsLTyVarLocNames :: LHsTyVarBndrs name -> [Located name]
- splitLHsInstDeclTy_maybe :: LHsType name -> Maybe (LHsTyVarBndrs name, HsContext name, Located name, [LHsType name])
- splitHsClassTy_maybe :: HsType name -> Maybe (name, [LHsType name])
- splitLHsClassTy_maybe :: LHsType name -> Maybe (Located name, [LHsType name])
- splitHsFunType :: LHsType Name -> ([LHsType Name], LHsType Name)
- splitHsAppTys :: LHsType n -> [LHsType n] -> (LHsType n, [LHsType n])
- hsTyGetAppHead_maybe :: LHsType n -> Maybe (n, [LHsType n])
- mkHsAppTys :: OutputableBndr n => LHsType n -> [LHsType n] -> HsType n
- mkHsOpTy :: LHsType name -> Located name -> LHsType name -> HsType name
- isWildcardTy :: HsType a -> Bool
- isNamedWildcardTy :: HsType a -> Bool
- pprParendHsType :: OutputableBndr name => HsType name -> SDoc
- pprHsForAll :: OutputableBndr name => HsExplicitFlag -> LHsTyVarBndrs name -> LHsContext name -> SDoc
- pprHsForAllExtra :: OutputableBndr name => HsExplicitFlag -> Maybe SrcSpan -> LHsTyVarBndrs name -> LHsContext name -> SDoc
- pprHsContext :: OutputableBndr name => HsContext name -> SDoc
- pprHsContextNoArrow :: OutputableBndr name => HsContext name -> SDoc
- pprHsContextMaybe :: OutputableBndr name => HsContext name -> Maybe SDoc

# Documentation

data HsType name Source

Constructors

HsForAllTy HsExplicitFlag (Maybe SrcSpan) (LHsTyVarBndrs name) (LHsContext name) (LHsType name) | `AnnKeywordId` : `AnnForall`, `AnnDot`,`AnnDarrow`
HsTyVar name | `AnnKeywordId` : None
HsAppTy (LHsType name) (LHsType name) | `AnnKeywordId` : None
HsFunTy (LHsType name) (LHsType name) | `AnnKeywordId` : `AnnRarrow`,
HsListTy (LHsType name) | `AnnKeywordId` : `AnnOpen` `'['`, `AnnClose` `']'`
HsPArrTy (LHsType name) | `AnnKeywordId` : `AnnOpen` `'[:'`, `AnnClose` `':]'`
HsTupleTy HsTupleSort [LHsType name] | `AnnKeywordId` : `AnnOpen` `'(' or '(#'`, `AnnClose` `')' or '#)'`
HsOpTy (LHsType name) (LHsTyOp name) (LHsType name) | `AnnKeywordId` : None
HsParTy (LHsType name) | `AnnKeywordId` : `AnnOpen` `'('`, `AnnClose` `')'`
HsIParamTy HsIPName (LHsType name) |
    (?x :: ty)
`AnnKeywordId` : `AnnDcolon`
HsEqTy (LHsType name) (LHsType name) |
    ty1 ~ ty2
`AnnKeywordId` : `AnnTilde`
HsKindSig (LHsType name) (LHsKind name) |
    (ty :: kind)
`AnnKeywordId` : `AnnOpen` `'('`, `AnnDcolon`,`AnnClose` `')'`
HsQuasiQuoteTy (HsQuasiQuote name) | `AnnKeywordId` : None
HsSpliceTy (HsSplice name) (PostTc name Kind) | `AnnKeywordId` : `AnnOpen` `'$('`, `AnnClose` `')'`
HsDocTy (LHsType name) LHsDocString | `AnnKeywordId` : None
HsBangTy HsSrcBang (LHsType name) | `AnnKeywordId` : `AnnOpen` `'{-# UNPACK' or '{-# NOUNPACK'`, `AnnClose` `'#-}'` `AnnBang` `'!'`
HsRecTy [LConDeclField name] | `AnnKeywordId` : `AnnOpen` `'{'`, `AnnClose` `'}'`
HsCoreTy Type | `AnnKeywordId` : None
HsExplicitListTy (PostTc name Kind) [LHsType name] | `AnnKeywordId` : `AnnOpen` `"'["`, `AnnClose` `']'`
HsExplicitTupleTy [PostTc name Kind] [LHsType name] | `AnnKeywordId` : `AnnOpen` `"'("`, `AnnClose` `')'`
HsTyLit HsTyLit | `AnnKeywordId` : None
HsWrapTy HsTyWrapper (HsType name) | `AnnKeywordId` : None
HsWildcardTy | `AnnKeywordId` : None
HsNamedWildcardTy name | `AnnKeywordId` : None

Instances

DataId name => Data (HsType name) |
OutputableBndr name => Outputable (HsType name) |

type LHsType name Source

Arguments

= Located (HsType name) | May have `AnnKeywordId` : `AnnComma` when in a list

type HsKind name = HsType name Source

type LHsKind name Source

Arguments

= Located (HsKind name) | `AnnKeywordId` : `AnnDcolon`

type HsTyOp name = (HsTyWrapper, name) Source

type LHsTyOp name = HsTyOp (Located name) Source

data HsTyVarBndr name Source

Constructors

UserTyVar name |
KindedTyVar (Located name) (LHsKind name) | `AnnKeywordId` : `AnnOpen`, `AnnDcolon`, `AnnClose`

Instances

DataId name => Data (HsTyVarBndr name) |
OutputableBndr name => Outputable (HsTyVarBndr name) |

type LHsTyVarBndr name = Located (HsTyVarBndr name) Source

data LHsTyVarBndrs name Source

Constructors

HsQTvs |
Fields hsq_kvs :: [Name] hsq_tvs :: [LHsTyVarBndr name]

Instances

DataId name => Data (LHsTyVarBndrs name) |
Monoid (LHsTyVarBndrs name) |
OutputableBndr name => Outputable (LHsTyVarBndrs name) |

data HsWithBndrs name thing Source

Constructors

HsWB |
Fields hswb_cts :: thing hswb_kvs :: PostRn name [Name] hswb_tvs :: PostRn name [Name] hswb_wcs :: PostRn name [Name]

Instances

(Data name, Data thing, Data (PostRn name [Name])) => Data (HsWithBndrs name thing) |
Outputable thing => Outputable (HsWithBndrs name thing) |

data HsTupleSort Source

Constructors

HsUnboxedTuple |
HsBoxedTuple |
HsConstraintTuple |
HsBoxedOrConstraintTuple |

Instances

Data HsTupleSort |

data HsExplicitFlag Source

Constructors

Qualified |
Implicit |
Explicit |

Instances

Data HsExplicitFlag |

type HsContext name = [LHsType name] Source

type LHsContext name Source

Arguments

= Located (HsContext name) | `AnnKeywordId` : `AnnUnit`

data HsQuasiQuote id Source

Constructors

HsQuasiQuote id SrcSpan FastString |

Instances

Data id => Data (HsQuasiQuote id) |
OutputableBndr id => Outputable (HsQuasiQuote id) |

data HsTyWrapper Source

Constructors

WpKiApps [Kind] |

Instances

Data HsTyWrapper |

data HsTyLit Source

Constructors

HsNumTy SourceText Integer |
HsStrTy SourceText FastString |

Instances

Data HsTyLit |
Outputable HsTyLit |

newtype HsIPName Source

These names are used early on to store the names of implicit parameters. They completely disappear after type-checking.

Constructors

HsIPName FastString |

Instances

Eq HsIPName |
Data HsIPName |
OutputableBndr HsIPName |
Outputable HsIPName |

hsIPNameFS :: HsIPName -> FastString Source

type LBangType name = Located (BangType name) Source

type BangType name = HsType name Source

data HsBang Source

Constructors

HsNoBang |
HsSrcBang (Maybe SourceText) (Maybe Bool) Bool |
HsUnpack (Maybe Coercion) |
HsStrict |

Instances

Data HsBang |
Outputable HsBang |

type HsSrcBang = HsBang Source

type HsImplBang = HsBang Source

getBangType :: LHsType a -> LHsType a Source

getBangStrictness :: LHsType a -> HsSrcBang Source

data ConDeclField name Source

Constructors

ConDeclField | `AnnKeywordId` : `AnnDcolon`
Fields cd_fld_names :: [Located name] cd_fld_type :: LBangType name cd_fld_doc :: Maybe LHsDocString

Instances

DataId name => Data (ConDeclField name) |

type LConDeclField name Source

Arguments

= Located (ConDeclField name) | May have `AnnKeywordId` : `AnnComma` when in a list

pprConDeclFields :: OutputableBndr name => [LConDeclField name] -> SDoc Source

mkHsQTvs :: [LHsTyVarBndr RdrName] -> LHsTyVarBndrs RdrName Source

hsQTvBndrs :: LHsTyVarBndrs name -> [LHsTyVarBndr name] Source

isHsKindedTyVar :: HsTyVarBndr name -> Bool Source

Does this `HsTyVarBndr` come with an explicit kind annotation?

hsTvbAllKinded :: LHsTyVarBndrs name -> Bool Source

Do all type variables in this `LHsTyVarBndr` come with kind annotations?

mkExplicitHsForAllTy :: [LHsTyVarBndr RdrName] -> LHsContext RdrName -> LHsType RdrName -> HsType RdrName Source

mkImplicitHsForAllTy :: LHsType RdrName -> HsType RdrName Source

mkImplicitHsForAllTy is called when we encounter f :: type Wrap around a HsForallTy if one is not there already.

mkQualifiedHsForAllTy :: LHsContext RdrName -> LHsType RdrName -> HsType RdrName Source

mkHsForAllTy :: HsExplicitFlag -> [LHsTyVarBndr RdrName] -> LHsContext RdrName -> LHsType RdrName -> HsType RdrName Source

Smart constructor for HsForAllTy, which populates the extra-constraints field if a wildcard is present in the context.

flattenTopLevelLHsForAllTy :: LHsType name -> LHsType name Source

When a sigtype is parsed, the type found is wrapped in an Implicit HsForAllTy via mkImplicitHsForAllTy, to ensure that a signature always has a forall at the outer level. For Api Annotations this nested structure is important to ensure that all `forall` and `.` locations are retained. From the renamer onwards this structure is flattened, to ease the renaming and type checking process.

flattenTopLevelHsForAllTy :: HsType name -> HsType name Source

flattenHsForAllTyKeepAnns :: HsType name -> ([AddAnn], HsType name) Source

hsExplicitTvs :: LHsType Name -> [Name] Source

hsTyVarName :: HsTyVarBndr name -> name Source

mkHsWithBndrs :: thing -> HsWithBndrs RdrName thing Source

hsLKiTyVarNames :: LHsTyVarBndrs Name -> [Name] Source

hsLTyVarName :: LHsTyVarBndr name -> name Source

hsLTyVarNames :: LHsTyVarBndrs name -> [name] Source

hsLTyVarLocName :: LHsTyVarBndr name -> Located name Source

hsLTyVarLocNames :: LHsTyVarBndrs name -> [Located name] Source

splitLHsInstDeclTy_maybe :: LHsType name -> Maybe (LHsTyVarBndrs name, HsContext name, Located name, [LHsType name]) Source

splitHsClassTy_maybe :: HsType name -> Maybe (name, [LHsType name]) Source

splitLHsClassTy_maybe :: LHsType name -> Maybe (Located name, [LHsType name]) Source

splitHsFunType :: LHsType Name -> ([LHsType Name], LHsType Name) Source

splitHsAppTys :: LHsType n -> [LHsType n] -> (LHsType n, [LHsType n]) Source

hsTyGetAppHead_maybe :: LHsType n -> Maybe (n, [LHsType n]) Source

mkHsAppTys :: OutputableBndr n => LHsType n -> [LHsType n] -> HsType n Source

mkHsOpTy :: LHsType name -> Located name -> LHsType name -> HsType name Source

isWildcardTy :: HsType a -> Bool Source

isNamedWildcardTy :: HsType a -> Bool Source

pprParendHsType :: OutputableBndr name => HsType name -> SDoc Source

pprHsForAll :: OutputableBndr name => HsExplicitFlag -> LHsTyVarBndrs name -> LHsContext name -> SDoc Source

pprHsForAllExtra :: OutputableBndr name => HsExplicitFlag -> Maybe SrcSpan -> LHsTyVarBndrs name -> LHsContext name -> SDoc Source

Version of `pprHsForAll` that can also print an extra-constraints wildcard, e.g. `_ => a -> Bool` or `(Show a, _) => a -> String`. This underscore will be printed when the 'Maybe SrcSpan' argument is a `Just` containing the location of the extra-constraints wildcard. A special function for this is needed, as the extra-constraints wildcard is removed from the actual context and type, and stored in a separate field, thus just printing the type will not print the extra-constraints wildcard.

pprHsContext :: OutputableBndr name => HsContext name -> SDoc Source

pprHsContextNoArrow :: OutputableBndr name => HsContext name -> SDoc Source

pprHsContextMaybe :: OutputableBndr name => HsContext name -> Maybe SDoc Source