TcPluginM

ghc-7.10.2: The GHC API

Safe Haskell | None
Language | Haskell2010

TcPluginM

Contents

- Basic TcPluginM functionality
- Finding Modules and Names
- Looking up Names in the typechecking environment
- Getting the TcM state
- Type variables
- Zonking

Description

This module provides an interface for typechecker plugins to access select functions of the `TcM`, principally those to do with reading parts of the state.

Synopsis

- data TcPluginM a
- tcPluginIO :: IO a -> TcPluginM a
- tcPluginTrace :: String -> SDoc -> TcPluginM ()
- unsafeTcPluginTcM :: TcM a -> TcPluginM a
- data FindResult
  - = Found ModLocation Module
  - | NoPackage PackageKey
  - | FoundMultiple [(Module, ModuleOrigin)]
  - | NotFound {
    - fr_paths :: [FilePath]
    - fr_pkg :: Maybe PackageKey
    - fr_mods_hidden :: [PackageKey]
    - fr_pkgs_hidden :: [PackageKey]
    - fr_suggestions :: [ModuleSuggestion]
    }
- findImportedModule :: ModuleName -> Maybe FastString -> TcPluginM FindResult
- lookupOrig :: Module -> OccName -> TcPluginM Name
- tcLookupGlobal :: Name -> TcPluginM TyThing
- tcLookupTyCon :: Name -> TcPluginM TyCon
- tcLookupDataCon :: Name -> TcPluginM DataCon
- tcLookupClass :: Name -> TcPluginM Class
- tcLookup :: Name -> TcPluginM TcTyThing
- tcLookupId :: Name -> TcPluginM Id
- getTopEnv :: TcPluginM HscEnv
- getEnvs :: TcPluginM (TcGblEnv, TcLclEnv)
- getInstEnvs :: TcPluginM InstEnvs
- getFamInstEnvs :: TcPluginM (FamInstEnv, FamInstEnv)
- matchFam :: TyCon -> [Type] -> TcPluginM (Maybe (TcCoercion, TcType))
- newFlexiTyVar :: Kind -> TcPluginM TcTyVar
- isTouchableTcPluginM :: TcTyVar -> TcPluginM Bool
- zonkTcType :: TcType -> TcPluginM TcType
- zonkCt :: Ct -> TcPluginM Ct

# Basic TcPluginM functionality

data TcPluginM a Source

Instances

Monad TcPluginM |
Functor TcPluginM |
Applicative TcPluginM |

tcPluginIO :: IO a -> TcPluginM a Source

Perform some IO, typically to interact with an external tool.

tcPluginTrace :: String -> SDoc -> TcPluginM () Source

Output useful for debugging the compiler.

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.

# Finding Modules and Names

data FindResult Source

The result of searching for an imported module.

Constructors

Found ModLocation Module | The module was found
NoPackage PackageKey | The requested package was not found
FoundMultiple [(Module, ModuleOrigin)] | _Error_: both in multiple packages
NotFound | Not found
Fields fr_paths :: [FilePath] fr_pkg :: Maybe PackageKey fr_mods_hidden :: [PackageKey] fr_pkgs_hidden :: [PackageKey] fr_suggestions :: [ModuleSuggestion]

findImportedModule :: ModuleName -> Maybe FastString -> TcPluginM FindResult Source

lookupOrig :: Module -> OccName -> TcPluginM Name Source

# Looking up Names in the typechecking environment

tcLookupGlobal :: Name -> TcPluginM TyThing Source

tcLookupTyCon :: Name -> TcPluginM TyCon Source

tcLookupDataCon :: Name -> TcPluginM DataCon Source

tcLookupClass :: Name -> TcPluginM Class Source

tcLookup :: Name -> TcPluginM TcTyThing Source

tcLookupId :: Name -> TcPluginM Id Source

# Getting the TcM state

getTopEnv :: TcPluginM HscEnv Source

getEnvs :: TcPluginM (TcGblEnv, TcLclEnv) Source

getInstEnvs :: TcPluginM InstEnvs Source

getFamInstEnvs :: TcPluginM (FamInstEnv, FamInstEnv) Source

matchFam :: TyCon -> [Type] -> TcPluginM (Maybe (TcCoercion, TcType)) Source

# Type variables

newFlexiTyVar :: Kind -> TcPluginM TcTyVar Source

isTouchableTcPluginM :: TcTyVar -> TcPluginM Bool Source

# Zonking

zonkTcType :: TcType -> TcPluginM TcType Source

zonkCt :: Ct -> TcPluginM Ct Source