ghc-8.0.2: The GHC API

Safe HaskellNone




type TcRnIf a b = IOEnv (Env a b) #

type TcM = TcRn #

Historical "type-checking monad" (now it's just TcRn).

type RnM = TcRn #

Historical "renaming monad" (now it's just TcRn).

type IfM lcl = TcRnIf IfGblEnv lcl #

type IfL = IfM IfLclEnv #

type IfG = IfM () #

type TcRef a = IORef a #

Type alias for IORef; the convention is we'll use this for mutable bits of data in TcGblEnv which are updated during typechecking and returned at the end.

data Env gbl lcl #





ContainsModule gbl => ContainsModule (Env gbl lcl) # 


extractModule :: Env gbl lcl -> Module #

ContainsDynFlags (Env gbl lcl) # 


extractDynFlags :: Env gbl lcl -> DynFlags #

data TcGblEnv #

TcGblEnv describes the top-level of the module at the point at which the typechecker is finished work. It is this structure that is handed on to the desugarer For state that needs to be updated during the typechecking phase and returned at end, use a TcRef (= IORef).




data IfGblEnv #



data FrontendResult #

FrontendResult describes the result of running the frontend of a Haskell module. Usually, you'll get a FrontendTypecheck, since running the frontend involves typechecking a program, but for an hs-boot merge you'll just get a ModIface, since no actual typechecking occurred.

This data type really should be in HscTypes, but it needs to have a TcGblEnv which is only defined here.

data ImportAvails #

ImportAvails summarises what was imported from where, irrespective of whether the imported things are actually used or not. It is used:

  • when processing the export list,
  • when constructing usage info for the interface file,
  • to identify the list of directly imported modules for initialisation purposes and for optimised overlap checking of family instances,
  • when figuring out what things are really unused




  • imp_mods :: ImportedMods

    Domain is all directly-imported modules

    See the documentaion on ImportedModsVal in HscTypes for the meaning of the fields.

    We need a full ModuleEnv rather than a ModuleNameEnv here, because we might be importing modules of the same name from different packages. (currently not the case, but might be in the future).

  • imp_dep_mods :: ModuleNameEnv (ModuleName, IsBootInterface)

    Home-package modules needed by the module being compiled

    It doesn't matter whether any of these dependencies are actually used when compiling the module; they are listed if they are below it at all. For example, suppose M imports A which imports X. Then compiling M might not need to consult X.hi, but X is still listed in M's dependencies.

  • imp_dep_pkgs :: [UnitId]

    Packages needed by the module being compiled, whether directly, or via other modules in this package, or via modules imported from other packages.

  • imp_trust_pkgs :: [UnitId]

    This is strictly a subset of imp_dep_pkgs and records the packages the current module needs to trust for Safe Haskell compilation to succeed. A package is required to be trusted if we are dependent on a trustworthy module in that package. While perhaps making imp_dep_pkgs a tuple of (UnitId, Bool) where True for the bool indicates the package is required to be trusted is the more logical design, doing so complicates a lot of code not concerned with Safe Haskell. See Note [RnNames . Tracking Trust Transitively]

  • imp_trust_own_pkg :: Bool

    Do we require that our own package is trusted? This is to handle efficiently the case where a Safe module imports a Trustworthy module that resides in the same package as it. See Note [RnNames . Trust Own Package]

  • imp_orphs :: [Module]

    Orphan modules below us in the import tree (and maybe including us for imported modules)

  • imp_finsts :: [Module]

    Family instance modules below us in the import tree (and maybe including us for imported modules)

plusImportAvails :: ImportAvails -> ImportAvails -> ImportAvails #

Union two ImportAvails

This function is a key part of Import handling, basically for each import we create a separate ImportAvails structure and then union them all together with this function.

data TcTyThing #

A typecheckable thing available in a local context. Could be AGlobal TyThing, but also lexically scoped variables, etc. See TcEnv for how to retrieve a TyThing given a Name.

data PArrBuiltin #




data DsMetaVal #


DsBound Id 
DsSplice (HsExpr Id) 

data SpliceType #



type ThLevel = Int #

noCompleteSig :: Maybe TcSigInfo -> Bool #

No signature or a partial signature

type Xi = Type #

type Cts = Bag Ct #

andCts :: Cts -> Cts -> Cts #

listToCts :: [Ct] -> Cts #

ctsElts :: Cts -> [Ct] #

consCts :: Ct -> Cts -> Cts #

snocCts :: Cts -> Ct -> Cts #

extendCtsList :: Cts -> [Ct] -> Cts #

superClassesMightHelp :: Ct -> Bool #

True if taking superclasses of givens, or of wanteds (to perhaps expose more equalities or functional dependencies) might help to solve this constraint. See Note [When superclases help]

getUserTypeErrorMsg :: Ct -> Maybe Type #

A constraint is considered to be a custom type error, if it contains custom type errors anywhere in it. See Note [Custom type errors in constraints]

ctLoc :: Ct -> CtLoc #

setCtLoc :: Ct -> CtLoc -> Ct #

ctFlavour :: Ct -> CtFlavour #

Get the flavour of the given Ct

ctEqRel :: Ct -> EqRel #

Get the equality relation for the given Ct

mkTcEqPredLikeEv :: CtEvidence -> TcType -> TcType -> TcType #

Makes a new equality predicate with the same role as the given evidence.

mkGivens :: CtLoc -> [EvId] -> [Ct] #

ctEvEqRel :: CtEvidence -> EqRel #

Get the equality relation relevant for a CtEvidence

tyCoVarsOfCt :: Ct -> TcTyCoVarSet #

Returns free variables of constraints as a non-deterministic set

tyCoVarsOfCts :: Cts -> TcTyCoVarSet #

Returns free variables of a bag of constraints as a non-deterministic set. See Note [Deterministic FV] in FV.

tyCoVarsOfCtList :: Ct -> [TcTyCoVar] #

Returns free variables of constraints as a deterministically ordered. list. See Note [Deterministic FV] in FV.

tyCoVarsOfCtsList :: Cts -> [TcTyCoVar] #

Returns free variables of a bag of constraints as a deterministically odered list. See Note [Deterministic FV] in FV.

toDerivedCt :: Ct -> Ct #

Convert a Wanted to a Derived

toDerivedWC :: WantedConstraints -> WantedConstraints #

Convert all Wanteds into Deriveds (ignoring insolubles)

tyCoVarsOfWC :: WantedConstraints -> TyCoVarSet #

Returns free variables of WantedConstraints as a non-deterministic set. See Note [Deterministic FV] in FV.

tyCoVarsOfWCList :: WantedConstraints -> [TyCoVar] #

Returns free variables of WantedConstraints as a deterministically ordered list. See Note [Deterministic FV] in FV.

exprCtOrigin :: HsExpr Name -> CtOrigin #

Extract a suitable CtOrigin from a HsExpr

matchesCtOrigin :: MatchGroup Name (LHsExpr Name) -> CtOrigin #

Extract a suitable CtOrigin from a MatchGroup

grhssCtOrigin :: GRHSs Name (LHsExpr Name) -> CtOrigin #

Extract a suitable CtOrigin from guarded RHSs

data ErrorThing #

A thing that can be stored for error message generation only. It is stored with a function to zonk and tidy the thing.


Outputable a => ErrorThing a (Maybe Arity) (TidyEnv -> a -> TcM (TidyEnv, a)) 

mkErrorThing :: Outputable a => a -> ErrorThing #

Make an ErrorThing that doesn't need tidying or zonking

errorThingNumArgs_maybe :: ErrorThing -> Maybe Arity #

Retrieve the # of arguments in the error thing, if known

data TypeOrKind #

Flag to see whether we're type-checking terms or kind-checking types



data TcEvDest #

A place for type-checking evidence to go after it is generated. Wanted equalities are always HoleDest; other wanteds are always EvVarDest.


EvVarDest EvVar

bind this var to the evidence

HoleDest CoercionHole

fill in this hole with the evidence See Note [Coercion holes] in TyCoRep


toKindLoc :: CtLoc -> CtLoc #

Take a CtLoc and moves it to the kind level

ctEvRole :: CtEvidence -> Role #

Get the role relevant for a CtEvidence

data TcPlugin #




data TcPluginResult #


TcPluginContradiction [Ct]

The plugin found a contradiction. The returned constraints are removed from the inert set, and recorded as insoluable.

TcPluginOk [(EvTerm, Ct)] [Ct]

The first field is for constraints that were solved. These are removed from the inert set, and the evidence for them is recorded. The second field contains new work, that should be processed by the constraint solver.

unsafeTcPluginTcM :: TcM a -> TcPluginM a #

This function provides an escape for direct access to the TcM monad. It should not be used lightly, and the provided TcPluginM API should be favoured instead.

getEvBindsTcPluginM_maybe :: TcPluginM (Maybe EvBindsVar) #

Access the EvBindsVar carried by the TcPluginM during constraint solving. Returns Nothing if invoked during tcPluginInit or tcPluginStop.

type CtFlavourRole = (CtFlavour, EqRel) #

Whether or not one Ct can rewrite another is determined by its flavour and its equality relation. See also Note [Flavours with roles] in TcSMonad

ctEvFlavourRole :: CtEvidence -> CtFlavourRole #

Extract the flavour, role, and boxity from a CtEvidence

ctFlavourRole :: Ct -> CtFlavourRole #

Extract the flavour, role, and boxity from a Ct

type TcId = Id #

type TcIdSet = IdSet #

data Hole #

An expression or type hole


ExprHole UnboundVar

Either an out-of-scope variable or a "true" hole in an expression (TypedHoles)

TypeHole OccName

A hole in a type (PartialTypeSignatures)