Setup the initial typechecking environment
Moduleghc-9.14.1GHC2021
GHC.Tc.Utils.Monad
Functions for working with the typechecker environment (setters, getters...).
Contents
- Initialisation
- Simple accessors
- Arrow scopes
- Unique supply
- Accessing input/output
- Debugging
- Typechecker global environment
- Error management
- Usage environment
- Shared error message stuff: renamer and typechecker
- Context management for the type checker
- Diagnostic message generation (type checker)
- Type constraints
- Template Haskell context
- Safe Haskell context
- Stuff for the renamer's local env
- Stuff for interface decls
- Stuff for cost centres.
- Zonking
- Complete matches
- Types etc.
Synopsis
- value initTc
- value initTcWithGbl
- value initTcInteractive
- value initTcRnIf
- value discardResult
- value getTopEnv
- value updTopEnv
- value updTopEnvIO
- value getGblEnv
- value updGblEnv
- value setGblEnv
- value getLclEnv
- value updLclEnv
- value updLclCtxt
- value setLclEnv
- value restoreLclEnv
- value updTopFlags
- value getEnvs
- value setEnvs
- value updEnvs
- value restoreEnvs
- value xoptM
- value doptM
- value goptM
- value woptM
- value setXOptM
- value setWOptM
- value unsetXOptM
- value unsetGOptM
- value unsetWOptM
- value whenDOptM
- value whenGOptM
- value whenWOptM
- value whenXOptM
- value unlessXOptM
- value getGhcMode
- value withoutDynamicNow
- value getEpsVar
- value getEps
- value updateEps
- value updateEps_
- value getHpt
- value getEpsAndHug
- value newArrowScope
- value escapeArrowScope
- value newUnique
- value newUniqueSupply
- value newName
- value newNameAt
- value cloneLocalName
- value newSysName
- value newSysLocalId
- value newSysLocalIds
- value newTcRef
- value readTcRef
- value writeTcRef
- value updTcRef
- value updTcRefM
- value traceTc
- value traceRn
- value traceOptTcRn
- value dumpOptTcRn
- value dumpTcRn
- value getNamePprCtx
- value printForUserTcRn
- value traceIf
- value traceOptIf
- value debugTc
- value getIsGHCi
- value getGHCiMonad
- value getInteractivePrintName
- value tcHscSource
- value tcIsHsBootOrSig
- value tcIsHsig
- value tcSelfBootInfo
- value getGlobalRdrEnv
- value getRdrEnvs
- value getImports
- value getFixityEnv
- value extendFixityEnv
- value getDeclaredDefaultTys
- value addDependentFiles
- value getSrcSpanM
- value setSrcSpan
- value setSrcSpanA
- value addLocM
- value inGeneratedCode
- value setInGeneratedCode
- value wrapLocM
- value wrapLocFstM
- value wrapLocFstMA
- value wrapLocSndM
- value wrapLocSndMA
- value wrapLocM_
- value wrapLocMA_
- value wrapLocMA
- value getErrsVar
- value setErrsVar
- value addErr
- value failWith
- value failAt
- value addErrAt
- value addErrs
- value checkErr
- value checkErrAt
- value addMessages
- value discardWarnings
- value mkDetailedMessage
- value tcCollectingUsage
- value tcScalingUsage
- value tcEmitBindingUsage
- value recoverM
- value mapAndRecoverM
- value mapAndReportM
- value foldAndRecoverM
- value attemptM
- value tryTc
- value askNoErrs
- value discardErrs
- value tryTcDiscardingErrs
- value tryTcDiscardingErrs'
- value checkNoErrs
- value whenNoErrs
- value ifErrsM
- value failIfErrsM
- value getErrCtxt
- value setErrCtxt
- value addErrCtxt
- value addErrCtxtM
- value addLandmarkErrCtxt
- value addLandmarkErrCtxtM
- value popErrCtxt
- value getCtLocM
- value setCtLocM
- value mkCtLocEnv
- value addErrTc
- value addErrTcM
- value failWithTc
- value failWithTcM
- value checkTc
- value checkTcM
- value checkJustTc
- value checkJustTcM
- value failIfTc
- value failIfTcM
- value mkErrCtxt
- value addTcRnDiagnostic
- value addDetailedDiagnostic
- value mkTcRnMessage
- value reportDiagnostic
- value reportDiagnostics
- value warnIf
- value diagnosticTc
- value diagnosticTcM
- value addDiagnosticTc
- value addDiagnosticTcM
- value addDiagnostic
- value addDiagnosticAt
- value newTcEvBinds
- value newNoTcEvBinds
- value cloneEvBindsVar
- value addTcEvBind
- value addTcEvBinds
- value addTopEvBinds
- value getTcEvBindsMap
- value setTcEvBindsMap
- value updTcEvBinds
- value getTcEvTyCoVars
- value chooseUniqueOccTc
- value getConstraintVar
- value setConstraintVar
- value emitConstraints
- value emitStaticConstraints
- value emitSimple
- value emitSimples
- value emitImplication
- value emitImplications
- value ensureReflMultiplicityCo
- value emitDelayedErrors
- value emitHole
- value emitHoles
- value emitNotConcreteError
- value discardConstraints
- value captureConstraints
- value tryCaptureConstraints
- value pushLevelAndCaptureConstraints
- value pushTcLevelM_
- value pushTcLevelM
- value getTcLevel
- value setTcLevel
- value isTouchableTcM
- value getLclTypeEnv
- value setLclTypeEnv
- value traceTcConstraints
- value emitNamedTypeHole
- data IsExtraConstraint
- value emitAnonTypeHole
- value recordThUse
- value recordThNeededRuntimeDeps
- value keepAlive
- value getThLevel
- value getCurrentAndBindLevel
- value setThLevel
- value addModFinalizersWithLclEnv
- value recordUnsafeInfer
- value finalSafeMode
- value fixSafeInstances
- value getLocalRdrEnv
- value setLocalRdrEnv
- value mkIfLclEnv
- value initIfaceTcRn
- value initIfaceCheck
- value initIfaceLcl
- value initIfaceLclWithSubst
- value initIfaceLoad
- value initIfaceLoadModule
- value getIfModule
- value failIfM
- value forkM
- value setImplicitEnvM
- value withException
- value withIfaceErr
- value getCCIndexM
- value getCCIndexTcM
- value liftZonkM
- value newZonkAnyType
- value localAndImportedCompleteMatches
- value getCompleteMatchesTcM
- Packageghc-9.14.1
- Exports228
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceMonad.hs
Initialisation
Run a TcM action in the context of an existing GblEnv.
Simple accessors
Do it flag is true
Update the external package state. Returns the second result of the modifier function.
This is an atomic operation and forces evaluation of the modified EPS in order to avoid space leaks.
Update the external package state.
This is an atomic operation and forces evaluation of the modified EPS in order to avoid space leaks.
Arrow scopes
Unique supply
Accessing input/output
Debugging
Dump if the given DumpFlag is set.
Like logInfoTcRn, but for user consumption
Typechecker global environment
Error management
Mark the inner computation as being done inside generated code.
See Note [Error contexts in generated code]
Usage environment
tcCollectingUsage thing_inside runs thing_inside and returns the usage
information which was collected as part of the execution of
thing_inside. Careful: tcCollectingUsage thing_inside itself does not
report any usage information, it's up to the caller to incorporate the
returned usage information into the larger context appropriately.
tcScalingUsage mult thing_inside runs thing_inside and scales all the
usage information by mult.
Shared error message stuff: renamer and typechecker
Drop elements of the input that fail, so the result list can be shorter than the argument list
Apply the function to all elements on the input list If all succeed, return the list of results Otherwise fail, propagating all errors
The accumulator is not updated if the action fails
Context management for the type checker
Add a fixed message to the error context. This message should not do any tidying.
Add a message to the error context. This message may do tidying.
Add a fixed landmark message to the error context. A landmark message is always sure to be reported, even if there is a lot of context. It also doesn't count toward the maximum number of contexts reported.
Variant of addLandmarkErrCtxt that allows for monadic operations and tidying.
Diagnostic message generation (type checker)
A variation of addDiagnostic that takes a function to produce a TcRnDsMessage
given some additional context about the diagnostic.
Display a warning if a condition is met.
Display a warning if a condition is met.
Display a diagnostic if a condition is met.
Display a diagnostic in the current context.
Display a diagnostic in a given context.
Display a diagnostic for the current source location, taken from the TcRn monad.
Display a diagnostic for a given source location.
Type constraints
Creates an EvBindsVar incapable of holding any bindings. It still tracks covar usages (see comments on ebv_tcvs in GHC.Tc.Types.Evidence), thus must be made monadically
Add a collection of binding to the TcEvBinds by side effect
Throw out any constraints emitted by the thing_inside
The name says it all. The returned TcLevel is the *inner* TcLevel.
Instances1Outputable
Outputable IsExtraConstraintDefined in ghc-9.14.1 · GHC.Tc.Utils.Monad
Template Haskell context
Adds the given modFinalizers to the global environment and set them to use the current local environment.
Safe Haskell context
Mark that safe inference has failed See Note [Safe Haskell Overlapping Instances Implementation] although this is used for more than just that failure case.
Figure out the final correct safe haskell mode
Switch instances to safe instances if we're in Safe mode.
Stuff for the renamer's local env
Stuff for interface decls
initIfaceLoad can be used when there's no chance that the action will
call typecheckIface when inside a module loop and hence tcIfaceGlobal.
This is used when we are doing to call typecheckModule on an ModIface,
if it's part of a loop with some other modules then we need to use their
IORef TypeEnv vars when typechecking but crucially not our own.
Run thing_inside in an interleaved thread. It shares everything with the parent thread, so this is DANGEROUS.
It throws an error if the computation fails
It's used for lazily type-checking interface signatures, which is pretty benign.
See Note [Masking exceptions in forkM]
A convenient wrapper for taking a MaybeErr SDoc a and throwing
an exception if it is an error.
Stuff for cost centres.
Get the next cost centre index associated with a given name.
See getCCIndexM.
Zonking
Complete matches
Types etc.
module GHC.Tc.Types
module GHC.Data.IOEnv
Orphan instances
1 instanceMonadUnique (IOEnv (Env gbl lcl))