Set up the typechecking environment.
Moduleghc-10.0.0.20260917GHC2024
GHC.Tc.Utils.Monad
Functions for working with the typechecker environment (setters, getters...).
- 2 types
- 231 values
- Packageghc-10.0.0.20260917
- Exports233
- LanguageGHC2024
- LicenceBSD-3-Clause
- SourceMonad.hs
Initialisation
3 declarationsInitialise the type checker monad for use in GHCi.
Simple accessors
39 declarationsDo 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.
Initialising TcM plugins
7 declarationsHow should TcM plugins be handled when initialising of the typechecker? See Note [Stop TcM plugins after desugaring].
Usage:
If you want to typecheck then desugar, use StartAndKeepRunningTcMPlugins. This will ensure TcM plugins are kept running for the benefit of the pattern-match checker, and shut down after desugaring.
If you only want to typecheck and not desugar, use StartAndStopTcMPlugins.
If a prior operation has started TcM plugins, you can use UseRunningTcMPlugins to avoid re-initialising the plugins, for example in initTc.
If you don't care about TcM plugins at all, you can use NoTcMPlugins.
Constructors
StartAndStopTcMPluginsStart TcM plugins, run the inner action, then shut down all TcM plugins.
Use this if you only need to run the typechecker, and do not intend to proceed to desugaring (in which case you should use StartAndKeepRunningTcMPlugins).
StartAndKeepRunningTcMPluginsStart TcM plugins, run the inner action, then run the "post-tc" actions of the plugins, but keep the TcM plugins running.
Use this when you intend to proceed to desugaring, as the desugarer wants TcM plugins to be running (for solver invocations via the pattern match checker). The desugarer will then shut down all TcM plugins.
If you only intend to typecheck, without desugaring, you should use StartAndStopTcMPlugins.
UseRunningTcMPluginsNoTcMPluginsDon't use any TcM plugins.
Initialise all TcM plugins, run the inner action, then run both their "post-tc" and "shutdown" actions.
Arrow scopes
2 declarationsUnique supply
8 declarationsAccessing input/output
5 declarationsDebugging
10 declarationsDump if the given DumpFlag is set.
Like logInfoTcRn, but for user consumption
Typechecker global environment
15 declarationsError management
26 declarationsUsage environment
3 declarationstcCollectingUsage 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
14 declarationsDrop 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
8 declarationsDiagnostic message generation (type checker)
23 declarationsA 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
39 declarationsCreates an EvBindsVar incapable of holding any bindings. It still tracks covar usages (see comments on ebv_needs in GHC.Tc.Types.Evidence), thus must be made monadically
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-10.0.0.20260917 · GHC.Tc.Utils.Monad
Put a value in a coercion hole
Template Haskell context
7 declarationsAdds the given modFinalizers to the global environment and set them to use the current local environment.
Safe Haskell context
3 declarationsMark 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
2 declarationsStuff for interface decls
13 declarationsinitIfaceLoad 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.
2 declarationsGet the next cost centre index associated with a given name.
See getCCIndexM.
Zonking
2 declarationsComplete matches
2 declarationsTypes etc.
0 declarationsmodule GHC.Tc.Types
module GHC.Data.IOEnv
Orphan instances
1 instanceMonadUnique (IOEnv (Env gbl lcl))