HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleghc-10.0.0.20260917GHC2024

GHC.Tc.Utils.Monad

Functions for working with the typechecker environment (setters, getters...).

Contents
  1. Initialisation
  2. Simple accessors
  3. Initialising TcM plugins
  4. Arrow scopes
  5. Unique supply
  6. Accessing input/output
  7. Debugging
  8. Typechecker global environment
  9. Error management
  10. Usage environment
  11. Shared error message stuff: renamer and typechecker
  12. Context management for the type checker
  13. Diagnostic message generation (type checker)
  14. Type constraints
  15. Template Haskell context
  16. Safe Haskell context
  17. Stuff for the renamer's local env
  18. Stuff for interface decls
  19. Stuff for cost centres.
  20. Zonking
  21. Complete matches
  22. Types etc.
Synopsis

Initialisation

Simple accessors

Initialising TcM plugins

How should TcM plugins be handled when initialising of the typechecker? See Note [Stop TcM plugins after desugaring].

Usage:

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

  2. If you only want to typecheck and not desugar, use StartAndStopTcMPlugins.

  3. If a prior operation has started TcM plugins, you can use UseRunningTcMPlugins to avoid re-initialising the plugins, for example in initTc.

  4. If you don't care about TcM plugins at all, you can use NoTcMPlugins.

Constructors

  • StartAndStopTcMPlugins

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

  • StartAndKeepRunningTcMPlugins

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

  • UseRunningTcMPlugins

    Use the TcM plugins that are already running.

    Use this when a prior operation has already initialised TcM plugins in order to avoid re-initialising them.

    NB: this will cause a crash if the plugins are not running (either not started or already stopped).

  • NoTcMPlugins

    Don't use any TcM plugins.

Arrow scopes

Unique supply

Accessing input/output

Debugging

valuedumpTcRn :: Bool -> DumpFlag -> String -> DumpFormat -> SDoc -> TcRn ()

Unconditionally dump some trace output

Certain tests (T3017, Roles3, T12763 etc.) expect part of the output generated by `-ddump-types` to be in PprUser style. However, generally we want all other debugging output to use PprDump style. We PprUser style if useUserStyle is True.

Typechecker global environment

Error management

Usage environment

valuetcCollectingUsage :: TcM a -> TcM (UsageEnv, a)

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.

Shared error message stuff: renamer and typechecker

valuemapAndRecoverM :: (a -> TcRn b) -> [a] -> TcRn [b]

Drop elements of the input that fail, so the result list can be shorter than the argument list

valuemapAndReportM :: (a -> TcRn b) -> [a] -> TcRn [b]

Apply the function to all elements on the input list If all succeed, return the list of results Otherwise fail, propagating all errors

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

valueinitIfaceLoadModule :: HscEnv -> Module -> IfG a -> IO a

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.

valueforkM :: SDoc -> IfL a -> IfL a

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]

Stuff for cost centres.

Zonking

Complete matches

Types etc.

Orphan instances

1 instance