ghc-9.0.1: The GHC API
Safe HaskellNone
LanguageHaskell2010

GHC.Tc.Types

Description

Various types used during typechecking.

Please see GHC.Tc.Utils.Monad as well for operations on these types. You probably want to import it, instead of this module.

All the monads exported here are built on top of the same IOEnv monad. The monad functions like a Reader monad in the way it passes the environment around. This is done to allow the environment to be manipulated in a stack like fashion when entering expressions... etc.

For state that is global and should be returned at the end (e.g not part of the stack mechanism), you should use a TcRef (= IORef) to store them.

Synopsis

Documentation

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

type TcM = TcRn Source #

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

type RnM = TcRn Source #

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

type IfM lcl = TcRnIf IfGblEnv lcl Source #

type IfG = IfM () Source #

type TcRef a = IORef a Source #

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 Source #

Constructors

Env 

Fields

Instances

Instances details
Quasi TcM # 
Instance details

Defined in GHC.Tc.Gen.Splice

MonadUnique (IOEnv (Env gbl lcl)) # 
Instance details

Defined in GHC.Tc.Utils.Monad

MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) # 
Instance details

Defined in GHC.Tc.Utils.Env

MonadThings (IOEnv (Env DsGblEnv DsLclEnv)) # 
Instance details

Defined in GHC.HsToCore.Monad

ContainsModule gbl => ContainsModule (Env gbl lcl) # 
Instance details

Defined in GHC.Tc.Types

Methods

extractModule :: Env gbl lcl -> Module Source #

ContainsDynFlags (Env gbl lcl) # 
Instance details

Defined in GHC.Tc.Types

Methods

extractDynFlags :: Env gbl lcl -> DynFlags Source #

data TcGblEnv Source #

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

Constructors

TcGblEnv 

Fields

Instances

Instances details
Quasi TcM # 
Instance details

Defined in GHC.Tc.Gen.Splice

ContainsModule TcGblEnv # 
Instance details

Defined in GHC.Tc.Types

ContainsCostCentreState TcGblEnv # 
Instance details

Defined in GHC.Tc.Utils.Monad

MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) # 
Instance details

Defined in GHC.Tc.Utils.Env

data TcLclEnv Source #

Instances

Instances details
Quasi TcM # 
Instance details

Defined in GHC.Tc.Gen.Splice

MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) # 
Instance details

Defined in GHC.Tc.Utils.Env

data IfGblEnv Source #

Constructors

IfGblEnv 

data FrontendResult Source #

FrontendResult describes the result of running the frontend of a Haskell module. Currently one always gets a FrontendTypecheck, since running the frontend involves typechecking a program. hs-sig merges are not handled here.

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

data ImportAvails Source #

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

Constructors

ImportAvails 

Fields

  • imp_mods :: ImportedMods

    Domain is all directly-imported modules

    See the documentation on ImportedModsVal in GHC.Driver.Types 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 ModuleNameWithIsBoot

    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 :: Set 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 :: Set 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 [Tracking Trust Transitively] in GHC.Rename.Names

  • 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 [Trust Own Package] in GHC.Rename.Names

  • 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 Source #

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 WhereFrom Source #

Instances

Instances details
Outputable WhereFrom # 
Instance details

Defined in GHC.Tc.Types

data TcBinder Source #

Instances

Instances details
Outputable TcBinder # 
Instance details

Defined in GHC.Tc.Types

HasOccName TcBinder # 
Instance details

Defined in GHC.Tc.Types

data TcTyThing Source #

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

Instances

Instances details
Outputable TcTyThing # 
Instance details

Defined in GHC.Tc.Types

data IdBindingInfo Source #

IdBindingInfo describes how an Id is bound.

It is used for the following purposes: a) for static forms in checkClosedInStaticForm and b) to figure out when a nested binding can be generalised, in decideGeneralisationPlan.

Instances

Instances details
Outputable IdBindingInfo # 
Instance details

Defined in GHC.Tc.Types

data IsGroupClosed Source #

IsGroupClosed describes a group of mutually-recursive bindings

data CompleteMatch Source #

A list of conlikes which represents a complete pattern match. These arise from COMPLETE signatures.

Constructors

CompleteMatch 

Fields

Instances

Instances details
Outputable CompleteMatch # 
Instance details

Defined in GHC.Driver.Types

type CompleteMatchMap = UniqFM Name [CompleteMatch] Source #

A map keyed by the completeMatchTyCon which has type Name.

data ThStage Source #

Instances

Instances details
Outputable ThStage # 
Instance details

Defined in GHC.Tc.Types

data SpliceType Source #

Constructors

Typed 
Untyped 

data ForeignSrcLang Source #

Foreign formats supported by GHC via TH

Constructors

LangC

C

LangCxx

C++

LangObjc

Objective C

LangObjcxx

Objective C++

LangAsm

Assembly language (.s)

RawObject

Object (.o)

Instances

Instances details
Eq ForeignSrcLang 
Instance details

Defined in GHC.ForeignSrcLang.Type

Show ForeignSrcLang 
Instance details

Defined in GHC.ForeignSrcLang.Type

Generic ForeignSrcLang 
Instance details

Defined in GHC.ForeignSrcLang.Type

Associated Types

type Rep ForeignSrcLang :: Type -> Type Source #

type Rep ForeignSrcLang 
Instance details

Defined in GHC.ForeignSrcLang.Type

type Rep ForeignSrcLang = D1 ('MetaData "ForeignSrcLang" "GHC.ForeignSrcLang.Type" "ghc-boot-th-9.0.1" 'False) ((C1 ('MetaCons "LangC" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LangCxx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LangObjc" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "LangObjcxx" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LangAsm" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RawObject" 'PrefixI 'False) (U1 :: Type -> Type))))

data TcSigInfo Source #

Instances

Instances details
Outputable TcSigInfo # 
Instance details

Defined in GHC.Tc.Types

hasCompleteSig :: TcSigFun -> Name -> Bool Source #

No signature or a partial signature

type TcId = Id Source #

data NameShape Source #

A NameShape is a substitution on Names that can be used to refine the identities of a hole while we are renaming interfaces (see GHC.Iface.Rename). Specifically, a NameShape for ns_module_name A, defines a mapping from {A.T} (for some OccName T) to some arbitrary other Name.

The most intruiging thing about a NameShape, however, is how it's constructed. A NameShape is *implied* by the exported AvailInfos of the implementor of an interface: if an implementor of signature <H> exports M.T, you implicitly define a substitution from {H.T} to M.T. So a NameShape is computed from the list of AvailInfos that are exported by the implementation of a module, or successively merged together by the export lists of signatures which are joining together.

It's not the most obvious way to go about doing this, but it does seem to work!

NB: Can't boot this and put it in NameShape because then we start pulling in too many DynFlags things.

getPlatform :: TcM Platform Source #

Get target platform

data TcPlugin Source #

Constructors

forall s. TcPlugin 

Fields

data TcPluginResult Source #

Constructors

TcPluginContradiction [Ct]

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

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.

data TcPluginM a Source #

Instances

Instances details
Monad TcPluginM # 
Instance details

Defined in GHC.Tc.Types

Methods

(>>=) :: TcPluginM a -> (a -> TcPluginM b) -> TcPluginM b Source #

(>>) :: TcPluginM a -> TcPluginM b -> TcPluginM b Source #

return :: a -> TcPluginM a Source #

Functor TcPluginM # 
Instance details

Defined in GHC.Tc.Types

Methods

fmap :: (a -> b) -> TcPluginM a -> TcPluginM b Source #

(<$) :: a -> TcPluginM b -> TcPluginM a Source #

MonadFail TcPluginM # 
Instance details

Defined in GHC.Tc.Types

Methods

fail :: String -> TcPluginM a Source #

Applicative TcPluginM # 
Instance details

Defined in GHC.Tc.Types

Methods

pure :: a -> TcPluginM a Source #

(<*>) :: TcPluginM (a -> b) -> TcPluginM a -> TcPluginM b Source #

liftA2 :: (a -> b -> c) -> TcPluginM a -> TcPluginM b -> TcPluginM c Source #

(*>) :: TcPluginM a -> TcPluginM b -> TcPluginM b Source #

(<*) :: TcPluginM a -> TcPluginM b -> TcPluginM a Source #

unsafeTcPluginTcM :: TcM a -> TcPluginM a Source #

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 :: TcPluginM EvBindsVar Source #

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

lintGblEnv :: DynFlags -> TcGblEnv -> (Bag SDoc, Bag SDoc) Source #

Check the TcGblEnv for consistency. Currently, only checks axioms, but should check other aspects, too.