TcRnMonad

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

TcRnMonad

Contents

- Initalisation
- Simple accessors
- Arrow scopes
- Unique supply
- Accessing input/output
- Debugging
- Typechecker global environment
- Error management
- Shared error message stuff: renamer and typechecker
- Context management for the type checker
- Error 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.
- Types etc.
- Orphan instances

Synopsis

- initTc :: HscEnv -> HscSource -> Bool -> Module -> RealSrcSpan -> TcM r -> IO (Messages, Maybe r)
- initTcWithGbl :: HscEnv -> TcGblEnv -> RealSrcSpan -> TcM r -> IO (Messages, Maybe r)
- initTcInteractive :: HscEnv -> TcM a -> IO (Messages, Maybe a)
- initTcRnIf :: Char -> HscEnv -> gbl -> lcl -> TcRnIf gbl lcl a -> IO a
- discardResult :: TcM a -> TcM ()
- getTopEnv :: TcRnIf gbl lcl HscEnv
- updTopEnv :: (HscEnv -> HscEnv) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- getGblEnv :: TcRnIf gbl lcl gbl
- updGblEnv :: (gbl -> gbl) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- setGblEnv :: gbl -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- getLclEnv :: TcRnIf gbl lcl lcl
- updLclEnv :: (lcl -> lcl) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- setLclEnv :: lcl' -> TcRnIf gbl lcl' a -> TcRnIf gbl lcl a
- getEnvs :: TcRnIf gbl lcl (gbl, lcl)
- setEnvs :: (gbl', lcl') -> TcRnIf gbl' lcl' a -> TcRnIf gbl lcl a
- xoptM :: Extension -> TcRnIf gbl lcl Bool
- doptM :: DumpFlag -> TcRnIf gbl lcl Bool
- goptM :: GeneralFlag -> TcRnIf gbl lcl Bool
- woptM :: WarningFlag -> TcRnIf gbl lcl Bool
- setXOptM :: Extension -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- unsetXOptM :: Extension -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- unsetGOptM :: GeneralFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- unsetWOptM :: WarningFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- whenDOptM :: DumpFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
- whenGOptM :: GeneralFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
- whenWOptM :: WarningFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
- whenXOptM :: Extension -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
- unlessXOptM :: Extension -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
- getGhcMode :: TcRnIf gbl lcl GhcMode
- withDoDynamicToo :: TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- getEpsVar :: TcRnIf gbl lcl (TcRef ExternalPackageState)
- getEps :: TcRnIf gbl lcl ExternalPackageState
- updateEps :: (ExternalPackageState -> (ExternalPackageState, a)) -> TcRnIf gbl lcl a
- updateEps_ :: (ExternalPackageState -> ExternalPackageState) -> TcRnIf gbl lcl ()
- getHpt :: TcRnIf gbl lcl HomePackageTable
- getEpsAndHpt :: TcRnIf gbl lcl (ExternalPackageState, HomePackageTable)
- newArrowScope :: TcM a -> TcM a
- escapeArrowScope :: TcM a -> TcM a
- newUnique :: TcRnIf gbl lcl Unique
- newUniqueSupply :: TcRnIf gbl lcl UniqSupply
- newName :: OccName -> TcM Name
- newNameAt :: OccName -> SrcSpan -> TcM Name
- cloneLocalName :: Name -> TcM Name
- newSysName :: OccName -> TcRnIf gbl lcl Name
- newSysLocalId :: FastString -> TcType -> TcRnIf gbl lcl TcId
- newSysLocalIds :: FastString -> [TcType] -> TcRnIf gbl lcl [TcId]
- newTcRef :: a -> TcRnIf gbl lcl (TcRef a)
- readTcRef :: TcRef a -> TcRnIf gbl lcl a
- writeTcRef :: TcRef a -> a -> TcRnIf gbl lcl ()
- updTcRef :: TcRef a -> (a -> a) -> TcRnIf gbl lcl ()
- traceTc :: String -> SDoc -> TcRn ()
- traceRn :: String -> SDoc -> TcRn ()
- traceOptTcRn :: DumpFlag -> SDoc -> TcRn ()
- traceTcRn :: DumpFlag -> SDoc -> TcRn ()
- getPrintUnqualified :: DynFlags -> TcRn PrintUnqualified
- printForUserTcRn :: SDoc -> TcRn ()
- traceIf :: SDoc -> TcRnIf m n ()
- traceHiDiffs :: SDoc -> TcRnIf m n ()
- traceOptIf :: DumpFlag -> SDoc -> TcRnIf m n ()
- debugTc :: TcM () -> TcM ()
- getIsGHCi :: TcRn Bool
- getGHCiMonad :: TcRn Name
- getInteractivePrintName :: TcRn Name
- tcIsHsBootOrSig :: TcRn Bool
- tcSelfBootInfo :: TcRn SelfBootInfo
- getGlobalRdrEnv :: TcRn GlobalRdrEnv
- getRdrEnvs :: TcRn (GlobalRdrEnv, LocalRdrEnv)
- getImports :: TcRn ImportAvails
- getFixityEnv :: TcRn FixityEnv
- extendFixityEnv :: [(Name, FixItem)] -> RnM a -> RnM a
- getRecFieldEnv :: TcRn RecFieldEnv
- getDeclaredDefaultTys :: TcRn (Maybe [Type])
- addDependentFiles :: [FilePath] -> TcRn ()
- getSrcSpanM :: TcRn SrcSpan
- setSrcSpan :: SrcSpan -> TcRn a -> TcRn a
- addLocM :: (a -> TcM b) -> Located a -> TcM b
- wrapLocM :: (a -> TcM b) -> Located a -> TcM (Located b)
- wrapLocFstM :: (a -> TcM (b, c)) -> Located a -> TcM (Located b, c)
- wrapLocSndM :: (a -> TcM (b, c)) -> Located a -> TcM (b, Located c)
- getErrsVar :: TcRn (TcRef Messages)
- setErrsVar :: TcRef Messages -> TcRn a -> TcRn a
- addErr :: MsgDoc -> TcRn ()
- failWith :: MsgDoc -> TcRn a
- failAt :: SrcSpan -> MsgDoc -> TcRn a
- addErrAt :: SrcSpan -> MsgDoc -> TcRn ()
- addErrs :: [(SrcSpan, MsgDoc)] -> TcRn ()
- checkErr :: Bool -> MsgDoc -> TcRn ()
- addMessages :: Messages -> TcRn ()
- discardWarnings :: TcRn a -> TcRn a
- mkLongErrAt :: SrcSpan -> MsgDoc -> MsgDoc -> TcRn ErrMsg
- mkErrDocAt :: SrcSpan -> ErrDoc -> TcRn ErrMsg
- addLongErrAt :: SrcSpan -> MsgDoc -> MsgDoc -> TcRn ()
- reportErrors :: [ErrMsg] -> TcM ()
- reportError :: ErrMsg -> TcRn ()
- reportWarning :: WarnReason -> ErrMsg -> TcRn ()
- recoverM :: TcRn r -> TcRn r -> TcRn r
- mapAndRecoverM :: (a -> TcRn b) -> [a] -> TcRn [b]
- mapAndReportM :: (a -> TcRn b) -> [a] -> TcRn [b]
- foldAndRecoverM :: (b -> a -> TcRn b) -> b -> [a] -> TcRn b
- tryTc :: TcRn a -> TcRn (Messages, Maybe a)
- askNoErrs :: TcRn a -> TcRn (a, Bool)
- discardErrs :: TcRn a -> TcRn a
- tryTcDiscardingErrs :: TcM r -> TcM r -> TcM r
- checkNoErrs :: TcM r -> TcM r
- whenNoErrs :: TcM () -> TcM ()
- ifErrsM :: TcRn r -> TcRn r -> TcRn r
- failIfErrsM :: TcRn ()
- checkTH :: a -> String -> TcRn ()
- failTH :: Outputable a => a -> String -> TcRn x
- getErrCtxt :: TcM [ErrCtxt]
- setErrCtxt :: [ErrCtxt] -> TcM a -> TcM a
- addErrCtxt :: MsgDoc -> TcM a -> TcM a
- addErrCtxtM :: (TidyEnv -> TcM (TidyEnv, MsgDoc)) -> TcM a -> TcM a
- addLandmarkErrCtxt :: MsgDoc -> TcM a -> TcM a
- addLandmarkErrCtxtM :: (TidyEnv -> TcM (TidyEnv, MsgDoc)) -> TcM a -> TcM a
- updCtxt :: ([ErrCtxt] -> [ErrCtxt]) -> TcM a -> TcM a
- popErrCtxt :: TcM a -> TcM a
- getCtLocM :: CtOrigin -> Maybe TypeOrKind -> TcM CtLoc
- setCtLocM :: CtLoc -> TcM a -> TcM a
- addErrTc :: MsgDoc -> TcM ()
- addErrsTc :: [MsgDoc] -> TcM ()
- addErrTcM :: (TidyEnv, MsgDoc) -> TcM ()
- mkErrTcM :: (TidyEnv, MsgDoc) -> TcM ErrMsg
- mkErrTc :: MsgDoc -> TcM ErrMsg
- failWithTc :: MsgDoc -> TcM a
- failWithTcM :: (TidyEnv, MsgDoc) -> TcM a
- checkTc :: Bool -> MsgDoc -> TcM ()
- checkTcM :: Bool -> (TidyEnv, MsgDoc) -> TcM ()
- failIfTc :: Bool -> MsgDoc -> TcM ()
- failIfTcM :: Bool -> (TidyEnv, MsgDoc) -> TcM ()
- warnIfFlag :: WarningFlag -> Bool -> MsgDoc -> TcRn ()
- warnIf :: Bool -> MsgDoc -> TcRn ()
- warnTc :: WarnReason -> Bool -> MsgDoc -> TcM ()
- warnTcM :: WarnReason -> Bool -> (TidyEnv, MsgDoc) -> TcM ()
- addWarnTc :: WarnReason -> MsgDoc -> TcM ()
- addWarnTcM :: WarnReason -> (TidyEnv, MsgDoc) -> TcM ()
- addWarn :: WarnReason -> MsgDoc -> TcRn ()
- addWarnAt :: WarnReason -> SrcSpan -> MsgDoc -> TcRn ()
- add_warn :: WarnReason -> MsgDoc -> MsgDoc -> TcRn ()
- mkErrInfo :: TidyEnv -> [ErrCtxt] -> TcM SDoc
- newTcEvBinds :: TcM EvBindsVar
- newNoTcEvBinds :: TcM EvBindsVar
- addTcEvBind :: EvBindsVar -> EvBind -> TcM ()
- addTopEvBinds :: Bag EvBind -> TcM a -> TcM a
- getTcEvTyCoVars :: EvBindsVar -> TcM TyCoVarSet
- getTcEvBindsMap :: EvBindsVar -> TcM EvBindMap
- setTcEvBindsMap :: EvBindsVar -> EvBindMap -> TcM ()
- chooseUniqueOccTc :: (OccSet -> OccName) -> TcM OccName
- getConstraintVar :: TcM (TcRef WantedConstraints)
- setConstraintVar :: TcRef WantedConstraints -> TcM a -> TcM a
- emitConstraints :: WantedConstraints -> TcM ()
- emitStaticConstraints :: WantedConstraints -> TcM ()
- emitSimple :: Ct -> TcM ()
- emitSimples :: Cts -> TcM ()
- emitImplication :: Implication -> TcM ()
- emitImplications :: Bag Implication -> TcM ()
- emitInsoluble :: Ct -> TcM ()
- discardConstraints :: TcM a -> TcM a
- captureConstraints :: TcM a -> TcM (a, WantedConstraints)
- tryCaptureConstraints :: TcM a -> TcM (Either IOEnvFailure a, WantedConstraints)
- pushLevelAndCaptureConstraints :: TcM a -> TcM (TcLevel, WantedConstraints, a)
- pushTcLevelM_ :: TcM a -> TcM a
- pushTcLevelM :: TcM a -> TcM (a, TcLevel)
- pushTcLevelsM :: Int -> TcM a -> TcM (a, TcLevel)
- getTcLevel :: TcM TcLevel
- setTcLevel :: TcLevel -> TcM a -> TcM a
- isTouchableTcM :: TcTyVar -> TcM Bool
- getLclTypeEnv :: TcM TcTypeEnv
- setLclTypeEnv :: TcLclEnv -> TcM a -> TcM a
- traceTcConstraints :: String -> TcM ()
- emitWildCardHoleConstraints :: [(Name, TcTyVar)] -> TcM ()
- recordThUse :: TcM ()
- recordThSpliceUse :: TcM ()
- recordTopLevelSpliceLoc :: SrcSpan -> TcM ()
- getTopLevelSpliceLocs :: TcM (Set RealSrcSpan)
- keepAlive :: Name -> TcRn ()
- getStage :: TcM ThStage
- getStageAndBindLevel :: Name -> TcRn (Maybe (TopLevelFlag, ThLevel, ThStage))
- setStage :: ThStage -> TcM a -> TcRn a
- addModFinalizersWithLclEnv :: ThModFinalizers -> TcM ()
- recordUnsafeInfer :: WarningMessages -> TcM ()
- finalSafeMode :: DynFlags -> TcGblEnv -> IO SafeHaskellMode
- fixSafeInstances :: SafeHaskellMode -> [ClsInst] -> [ClsInst]
- getLocalRdrEnv :: RnM LocalRdrEnv
- setLocalRdrEnv :: LocalRdrEnv -> RnM a -> RnM a
- mkIfLclEnv :: Module -> SDoc -> Bool -> IfLclEnv
- initIfaceTcRn :: IfG a -> TcRn a
- initIfaceCheck :: SDoc -> HscEnv -> IfG a -> IO a
- initIfaceLcl :: Module -> SDoc -> Bool -> IfL a -> IfM lcl a
- initIfaceLclWithSubst :: Module -> SDoc -> Bool -> NameShape -> IfL a -> IfM lcl a
- initIfaceLoad :: HscEnv -> IfG a -> IO a
- getIfModule :: IfL Module
- failIfM :: MsgDoc -> IfL a
- forkM_maybe :: SDoc -> IfL a -> IfL (Maybe a)
- forkM :: SDoc -> IfL a -> IfL a
- setImplicitEnvM :: TypeEnv -> IfL a -> IfL a
- withException :: TcRnIf gbl lcl (MaybeErr MsgDoc a) -> TcRnIf gbl lcl a
- class ContainsCostCentreState e where
  - extractCostCentreState :: e -> TcRef CostCentreState
- getCCIndexM :: ContainsCostCentreState gbl => FastString -> TcRnIf gbl lcl CostCentreIndex
- module TcRnTypes
- module IOEnv

# Initalisation

initTc :: HscEnv -> HscSource -> Bool -> Module -> RealSrcSpan -> TcM r -> IO (Messages, Maybe r) #

Setup the initial typechecking environment

initTcWithGbl :: HscEnv -> TcGblEnv -> RealSrcSpan -> TcM r -> IO (Messages, Maybe r) #

Run a `TcM` action in the context of an existing `GblEnv`.

initTcInteractive :: HscEnv -> TcM a -> IO (Messages, Maybe a) #

initTcRnIf :: Char -> HscEnv -> gbl -> lcl -> TcRnIf gbl lcl a -> IO a #

# Simple accessors

discardResult :: TcM a -> TcM () #

getTopEnv :: TcRnIf gbl lcl HscEnv #

updTopEnv :: (HscEnv -> HscEnv) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a #

getGblEnv :: TcRnIf gbl lcl gbl #

updGblEnv :: (gbl -> gbl) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a #

setGblEnv :: gbl -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a #

getLclEnv :: TcRnIf gbl lcl lcl #

updLclEnv :: (lcl -> lcl) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a #

setLclEnv :: lcl' -> TcRnIf gbl lcl' a -> TcRnIf gbl lcl a #

getEnvs :: TcRnIf gbl lcl (gbl, lcl) #

setEnvs :: (gbl', lcl') -> TcRnIf gbl' lcl' a -> TcRnIf gbl lcl a #

xoptM :: Extension -> TcRnIf gbl lcl Bool #

doptM :: DumpFlag -> TcRnIf gbl lcl Bool #

goptM :: GeneralFlag -> TcRnIf gbl lcl Bool #

woptM :: WarningFlag -> TcRnIf gbl lcl Bool #

setXOptM :: Extension -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a #

unsetXOptM :: Extension -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a #

unsetGOptM :: GeneralFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a #

unsetWOptM :: WarningFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a #

whenDOptM :: DumpFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () #

Do it flag is true

whenGOptM :: GeneralFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () #

whenWOptM :: WarningFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () #

whenXOptM :: Extension -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () #

unlessXOptM :: Extension -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () #

getGhcMode :: TcRnIf gbl lcl GhcMode #

withDoDynamicToo :: TcRnIf gbl lcl a -> TcRnIf gbl lcl a #

getEpsVar :: TcRnIf gbl lcl (TcRef ExternalPackageState) #

getEps :: TcRnIf gbl lcl ExternalPackageState #

updateEps :: (ExternalPackageState -> (ExternalPackageState, a)) -> TcRnIf gbl lcl a #

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.

updateEps_ :: (ExternalPackageState -> ExternalPackageState) -> TcRnIf gbl lcl () #

Update the external package state.

This is an atomic operation and forces evaluation of the modified EPS in order to avoid space leaks.

getHpt :: TcRnIf gbl lcl HomePackageTable #

getEpsAndHpt :: TcRnIf gbl lcl (ExternalPackageState, HomePackageTable) #

# Arrow scopes

newArrowScope :: TcM a -> TcM a #

escapeArrowScope :: TcM a -> TcM a #

# Unique supply

newUnique :: TcRnIf gbl lcl Unique #

newUniqueSupply :: TcRnIf gbl lcl UniqSupply #

newName :: OccName -> TcM Name #

newNameAt :: OccName -> SrcSpan -> TcM Name #

cloneLocalName :: Name -> TcM Name #

newSysName :: OccName -> TcRnIf gbl lcl Name #

newSysLocalId :: FastString -> TcType -> TcRnIf gbl lcl TcId #

newSysLocalIds :: FastString -> [TcType] -> TcRnIf gbl lcl [TcId] #

# Accessing input/output

newTcRef :: a -> TcRnIf gbl lcl (TcRef a) #

readTcRef :: TcRef a -> TcRnIf gbl lcl a #

writeTcRef :: TcRef a -> a -> TcRnIf gbl lcl () #

updTcRef :: TcRef a -> (a -> a) -> TcRnIf gbl lcl () #

# Debugging

traceTc :: String -> SDoc -> TcRn () #

traceRn :: String -> SDoc -> TcRn () #

traceOptTcRn :: DumpFlag -> SDoc -> TcRn () #

Output a doc if the given `DumpFlag` is set.

By default this logs to stdout However, if the `-ddump-to-file` flag is set, then this will dump output to a file

Just a wrapper for `dumpSDoc`

traceTcRn :: DumpFlag -> SDoc -> TcRn () #

Unconditionally dump some trace output

The DumpFlag is used only to set the output filename for --dump-to-file, not to decide whether or not to output That part is done by the caller

getPrintUnqualified :: DynFlags -> TcRn PrintUnqualified #

printForUserTcRn :: SDoc -> TcRn () #

Like logInfoTcRn, but for user consumption

traceIf :: SDoc -> TcRnIf m n () #

traceHiDiffs :: SDoc -> TcRnIf m n () #

traceOptIf :: DumpFlag -> SDoc -> TcRnIf m n () #

debugTc :: TcM () -> TcM () #

# Typechecker global environment

getIsGHCi :: TcRn Bool #

getGHCiMonad :: TcRn Name #

getInteractivePrintName :: TcRn Name #

tcIsHsBootOrSig :: TcRn Bool #

tcSelfBootInfo :: TcRn SelfBootInfo #

getGlobalRdrEnv :: TcRn GlobalRdrEnv #

getRdrEnvs :: TcRn (GlobalRdrEnv, LocalRdrEnv) #

getImports :: TcRn ImportAvails #

getFixityEnv :: TcRn FixityEnv #

extendFixityEnv :: [(Name, FixItem)] -> RnM a -> RnM a #

getRecFieldEnv :: TcRn RecFieldEnv #

getDeclaredDefaultTys :: TcRn (Maybe [Type]) #

addDependentFiles :: [FilePath] -> TcRn () #

# Error management

getSrcSpanM :: TcRn SrcSpan #

setSrcSpan :: SrcSpan -> TcRn a -> TcRn a #

addLocM :: (a -> TcM b) -> Located a -> TcM b #

wrapLocM :: (a -> TcM b) -> Located a -> TcM (Located b) #

wrapLocFstM :: (a -> TcM (b, c)) -> Located a -> TcM (Located b, c) #

wrapLocSndM :: (a -> TcM (b, c)) -> Located a -> TcM (b, Located c) #

getErrsVar :: TcRn (TcRef Messages) #

setErrsVar :: TcRef Messages -> TcRn a -> TcRn a #

addErr :: MsgDoc -> TcRn () #

failWith :: MsgDoc -> TcRn a #

failAt :: SrcSpan -> MsgDoc -> TcRn a #

addErrAt :: SrcSpan -> MsgDoc -> TcRn () #

addErrs :: [(SrcSpan, MsgDoc)] -> TcRn () #

checkErr :: Bool -> MsgDoc -> TcRn () #

addMessages :: Messages -> TcRn () #

discardWarnings :: TcRn a -> TcRn a #

# Shared error message stuff: renamer and typechecker

mkLongErrAt :: SrcSpan -> MsgDoc -> MsgDoc -> TcRn ErrMsg #

mkErrDocAt :: SrcSpan -> ErrDoc -> TcRn ErrMsg #

addLongErrAt :: SrcSpan -> MsgDoc -> MsgDoc -> TcRn () #

reportErrors :: [ErrMsg] -> TcM () #

reportError :: ErrMsg -> TcRn () #

reportWarning :: WarnReason -> ErrMsg -> TcRn () #

recoverM :: TcRn r -> TcRn r -> TcRn r #

mapAndRecoverM :: (a -> TcRn b) -> [a] -> TcRn [b] #

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

mapAndReportM :: (a -> TcRn b) -> [a] -> TcRn [b] #

Succeeds if applying the argument to all members of the lists succeeds, but nevertheless runs it on all arguments, to collect all errors.

foldAndRecoverM :: (b -> a -> TcRn b) -> b -> [a] -> TcRn b #

The accumulator is not updated if the action fails

tryTc :: TcRn a -> TcRn (Messages, Maybe a) #

askNoErrs :: TcRn a -> TcRn (a, Bool) #

discardErrs :: TcRn a -> TcRn a #

tryTcDiscardingErrs :: TcM r -> TcM r -> TcM r #

checkNoErrs :: TcM r -> TcM r #

whenNoErrs :: TcM () -> TcM () #

ifErrsM :: TcRn r -> TcRn r -> TcRn r #

failIfErrsM :: TcRn () #

checkTH :: a -> String -> TcRn () #

failTH :: Outputable a => a -> String -> TcRn x #

# Context management for the type checker

getErrCtxt :: TcM [ErrCtxt] #

setErrCtxt :: [ErrCtxt] -> TcM a -> TcM a #

addErrCtxt :: MsgDoc -> TcM a -> TcM a #

Add a fixed message to the error context. This message should not do any tidying.

addErrCtxtM :: (TidyEnv -> TcM (TidyEnv, MsgDoc)) -> TcM a -> TcM a #

Add a message to the error context. This message may do tidying.

addLandmarkErrCtxt :: MsgDoc -> TcM a -> TcM a #

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.

addLandmarkErrCtxtM :: (TidyEnv -> TcM (TidyEnv, MsgDoc)) -> TcM a -> TcM a #

Variant of `addLandmarkErrCtxt` that allows for monadic operations and tidying.

updCtxt :: ([ErrCtxt] -> [ErrCtxt]) -> TcM a -> TcM a #

popErrCtxt :: TcM a -> TcM a #

getCtLocM :: CtOrigin -> Maybe TypeOrKind -> TcM CtLoc #

setCtLocM :: CtLoc -> TcM a -> TcM a #

# Error message generation (type checker)

addErrTc :: MsgDoc -> TcM () #

addErrsTc :: [MsgDoc] -> TcM () #

addErrTcM :: (TidyEnv, MsgDoc) -> TcM () #

mkErrTcM :: (TidyEnv, MsgDoc) -> TcM ErrMsg #

mkErrTc :: MsgDoc -> TcM ErrMsg #

failWithTc :: MsgDoc -> TcM a #

failWithTcM :: (TidyEnv, MsgDoc) -> TcM a #

checkTc :: Bool -> MsgDoc -> TcM () #

checkTcM :: Bool -> (TidyEnv, MsgDoc) -> TcM () #

failIfTc :: Bool -> MsgDoc -> TcM () #

failIfTcM :: Bool -> (TidyEnv, MsgDoc) -> TcM () #

warnIfFlag :: WarningFlag -> Bool -> MsgDoc -> TcRn () #

Display a warning if a condition is met, and the warning is enabled

warnIf :: Bool -> MsgDoc -> TcRn () #

Display a warning if a condition is met.

warnTc :: WarnReason -> Bool -> MsgDoc -> TcM () #

Display a warning if a condition is met.

warnTcM :: WarnReason -> Bool -> (TidyEnv, MsgDoc) -> TcM () #

Display a warning if a condition is met.

addWarnTc :: WarnReason -> MsgDoc -> TcM () #

Display a warning in the current context.

addWarnTcM :: WarnReason -> (TidyEnv, MsgDoc) -> TcM () #

Display a warning in a given context.

addWarn :: WarnReason -> MsgDoc -> TcRn () #

Display a warning for the current source location.

addWarnAt :: WarnReason -> SrcSpan -> MsgDoc -> TcRn () #

Display a warning for a given source location.

add_warn :: WarnReason -> MsgDoc -> MsgDoc -> TcRn () #

Display a warning, with an optional flag, for the current source location.

mkErrInfo :: TidyEnv -> [ErrCtxt] -> TcM SDoc #

# Type constraints

newTcEvBinds :: TcM EvBindsVar #

newNoTcEvBinds :: TcM EvBindsVar #

Creates an EvBindsVar incapable of holding any bindings. It still tracks covar usages (see comments on ebv_tcvs in TcEvidence), thus must be made monadically

addTcEvBind :: EvBindsVar -> EvBind -> TcM () #

addTopEvBinds :: Bag EvBind -> TcM a -> TcM a #

getTcEvTyCoVars :: EvBindsVar -> TcM TyCoVarSet #

getTcEvBindsMap :: EvBindsVar -> TcM EvBindMap #

setTcEvBindsMap :: EvBindsVar -> EvBindMap -> TcM () #

chooseUniqueOccTc :: (OccSet -> OccName) -> TcM OccName #

getConstraintVar :: TcM (TcRef WantedConstraints) #

setConstraintVar :: TcRef WantedConstraints -> TcM a -> TcM a #

emitConstraints :: WantedConstraints -> TcM () #

emitStaticConstraints :: WantedConstraints -> TcM () #

emitSimple :: Ct -> TcM () #

emitSimples :: Cts -> TcM () #

emitImplication :: Implication -> TcM () #

emitImplications :: Bag Implication -> TcM () #

emitInsoluble :: Ct -> TcM () #

discardConstraints :: TcM a -> TcM a #

Throw out any constraints emitted by the thing_inside

captureConstraints :: TcM a -> TcM (a, WantedConstraints) #

tryCaptureConstraints :: TcM a -> TcM (Either IOEnvFailure a, WantedConstraints) #

pushLevelAndCaptureConstraints :: TcM a -> TcM (TcLevel, WantedConstraints, a) #

The name says it all. The returned TcLevel is the *inner* TcLevel.

pushTcLevelM_ :: TcM a -> TcM a #

pushTcLevelM :: TcM a -> TcM (a, TcLevel) #

pushTcLevelsM :: Int -> TcM a -> TcM (a, TcLevel) #

getTcLevel :: TcM TcLevel #

setTcLevel :: TcLevel -> TcM a -> TcM a #

isTouchableTcM :: TcTyVar -> TcM Bool #

getLclTypeEnv :: TcM TcTypeEnv #

setLclTypeEnv :: TcLclEnv -> TcM a -> TcM a #

traceTcConstraints :: String -> TcM () #

emitWildCardHoleConstraints :: [(Name, TcTyVar)] -> TcM () #

# Template Haskell context

recordThUse :: TcM () #

recordThSpliceUse :: TcM () #

recordTopLevelSpliceLoc :: SrcSpan -> TcM () #

When generating an out-of-scope error message for a variable matching a binding in a later inter-splice group, the typechecker uses the splice locations to provide details in the message about the scope of that binding.

getTopLevelSpliceLocs :: TcM (Set RealSrcSpan) #

keepAlive :: Name -> TcRn () #

getStage :: TcM ThStage #

getStageAndBindLevel :: Name -> TcRn (Maybe (TopLevelFlag, ThLevel, ThStage)) #

setStage :: ThStage -> TcM a -> TcRn a #

addModFinalizersWithLclEnv :: ThModFinalizers -> TcM () #

Adds the given modFinalizers to the global environment and set them to use the current local environment.

# Safe Haskell context

recordUnsafeInfer :: WarningMessages -> TcM () #

Mark that safe inference has failed See Note [Safe Haskell Overlapping Instances Implementation] although this is used for more than just that failure case.

finalSafeMode :: DynFlags -> TcGblEnv -> IO SafeHaskellMode #

Figure out the final correct safe haskell mode

fixSafeInstances :: SafeHaskellMode -> [ClsInst] -> [ClsInst] #

Switch instances to safe instances if we're in Safe mode.

# Stuff for the renamer's local env

getLocalRdrEnv :: RnM LocalRdrEnv #

setLocalRdrEnv :: LocalRdrEnv -> RnM a -> RnM a #

# Stuff for interface decls

mkIfLclEnv :: Module -> SDoc -> Bool -> IfLclEnv #

initIfaceTcRn :: IfG a -> TcRn a #

Run an `IfG` (top-level interface monad) computation inside an existing `TcRn` (typecheck-renaming monad) computation by initializing an `IfGblEnv` based on `TcGblEnv`.

initIfaceCheck :: SDoc -> HscEnv -> IfG a -> IO a #

initIfaceLcl :: Module -> SDoc -> Bool -> IfL a -> IfM lcl a #

initIfaceLclWithSubst :: Module -> SDoc -> Bool -> NameShape -> IfL a -> IfM lcl a #

Initialize interface typechecking, but with a `NameShape` to apply when typechecking top-level `OccName`s (see `lookupIfaceTop`)

initIfaceLoad :: HscEnv -> IfG a -> IO a #

getIfModule :: IfL Module #

failIfM :: MsgDoc -> IfL a #

forkM_maybe :: SDoc -> IfL a -> IfL (Maybe a) #

forkM :: SDoc -> IfL a -> IfL a #

setImplicitEnvM :: TypeEnv -> IfL a -> IfL a #

withException :: TcRnIf gbl lcl (MaybeErr MsgDoc a) -> TcRnIf gbl lcl a #

A convenient wrapper for taking a `MaybeErr MsgDoc a` and throwing an exception if it is an error.

# Stuff for cost centres.

class ContainsCostCentreState e where #

Environments which track `CostCentreState`

Methods

extractCostCentreState :: e -> TcRef CostCentreState #

Instances

ContainsCostCentreState TcGblEnv # |
Instance details Defined in TcRnMonad Methods extractCostCentreState :: TcGblEnv -> TcRef CostCentreState #
ContainsCostCentreState DsGblEnv # |
Instance details Defined in TcRnMonad Methods extractCostCentreState :: DsGblEnv -> TcRef CostCentreState #

getCCIndexM :: ContainsCostCentreState gbl => FastString -> TcRnIf gbl lcl CostCentreIndex #

Get the next cost centre index associated with a given name.

# Types etc.

module TcRnTypes

module IOEnv

# Orphan instances

MonadUnique (IOEnv (Env gbl lcl)) # |
Instance details Methods getUniqueSupplyM :: IOEnv (Env gbl lcl) UniqSupply # getUniqueM :: IOEnv (Env gbl lcl) Unique # getUniquesM :: IOEnv (Env gbl lcl) [Unique] #