GHC

ghc-8.10.5: The GHC API

Safe Haskell | None
Language | Haskell2010

GHC

Contents

- Initialisation
- GHC Monad
- Flags and settings
- Targets
- Loading/compiling the program
  - Compiling to Core
- Inspecting the module structure of the program
- Inspecting modules
- Querying the environment
- Printing
- Interactive evaluation
  - Executing statements
  - Adding new declarations
  - Get/set the current context
  - Inspecting the current context
  - Inspecting types and kinds
  - Looking up a Name
  - Compiling expressions
  - Docs
  - Other
  - The debugger
- Abstract syntax elements
  - Packages
  - Modules
  - Names
  - Identifiers
  - Type constructors
  - Type variables
  - Data constructors
  - Classes
  - Instances
  - Types and Kinds
  - Entities
  - Syntax
  - Fixities
  - Source locations
  - Located
    - Constructing Located
    - Deconstructing Located
  - HasSrcSpan
    - Combining and comparing Located values
- Exceptions
- Token stream manipulations
- Pure interface to the parser
- API Annotations
- Miscellaneous

Synopsis

- defaultErrorHandler :: ExceptionMonad m => FatalMessager -> FlushOut -> m a -> m a
- defaultCleanupHandler :: ExceptionMonad m => DynFlags -> m a -> m a
- prettyPrintGhcErrors :: ExceptionMonad m => DynFlags -> m a -> m a
- withSignalHandlers :: (ExceptionMonad m, MonadIO m) => m a -> m a
- withCleanupSession :: GhcMonad m => m a -> m a
- data Ghc a
- data GhcT m a
- class (Functor m, MonadIO m, ExceptionMonad m, HasDynFlags m) => GhcMonad m where
  - getSession :: m HscEnv
  - setSession :: HscEnv -> m ()
- data HscEnv
- runGhc :: Maybe FilePath -> Ghc a -> IO a
- runGhcT :: ExceptionMonad m => Maybe FilePath -> GhcT m a -> m a
- initGhcMonad :: GhcMonad m => Maybe FilePath -> m ()
- gcatch :: (ExceptionMonad m, Exception e) => m a -> (e -> m a) -> m a
- gbracket :: ExceptionMonad m => m a -> (a -> m b) -> (a -> m c) -> m c
- gfinally :: ExceptionMonad m => m a -> m b -> m a
- printException :: GhcMonad m => SourceError -> m ()
- handleSourceError :: ExceptionMonad m => (SourceError -> m a) -> m a -> m a
- needsTemplateHaskellOrQQ :: ModuleGraph -> Bool
- data DynFlags = DynFlags {
  - ghcMode :: GhcMode
  - ghcLink :: GhcLink
  - hscTarget :: HscTarget
  - ghcNameVersion :: !GhcNameVersion
  - fileSettings :: !FileSettings
  - targetPlatform :: Platform
  - toolSettings :: !ToolSettings
  - platformMisc :: !PlatformMisc
  - platformConstants :: PlatformConstants
  - rawSettings :: [(String, String)]
  - integerLibrary :: IntegerLibrary
  - llvmConfig :: LlvmConfig
  - verbosity :: Int
  - optLevel :: Int
  - debugLevel :: Int
  - simplPhases :: Int
  - maxSimplIterations :: Int
  - ruleCheck :: Maybe String
  - inlineCheck :: Maybe String
  - strictnessBefore :: [Int]
  - parMakeCount :: Maybe Int
  - enableTimeStats :: Bool
  - ghcHeapSize :: Maybe Int
  - maxRelevantBinds :: Maybe Int
  - maxValidHoleFits :: Maybe Int
  - maxRefHoleFits :: Maybe Int
  - refLevelHoleFits :: Maybe Int
  - maxUncoveredPatterns :: Int
  - maxPmCheckModels :: Int
  - simplTickFactor :: Int
  - specConstrThreshold :: Maybe Int
  - specConstrCount :: Maybe Int
  - specConstrRecursive :: Int
  - binBlobThreshold :: Word
  - liberateCaseThreshold :: Maybe Int
  - floatLamArgs :: Maybe Int
  - liftLamsRecArgs :: Maybe Int
  - liftLamsNonRecArgs :: Maybe Int
  - liftLamsKnown :: Bool
  - cmmProcAlignment :: Maybe Int
  - historySize :: Int
  - importPaths :: [FilePath]
  - mainModIs :: Module
  - mainFunIs :: Maybe String
  - reductionDepth :: IntWithInf
  - solverIterations :: IntWithInf
  - thisInstalledUnitId :: InstalledUnitId
  - thisComponentId_ :: Maybe ComponentId
  - thisUnitIdInsts_ :: Maybe [(ModuleName, Module)]
  - ways :: [Way]
  - buildTag :: String
  - splitInfo :: Maybe (String, Int)
  - objectDir :: Maybe String
  - dylibInstallName :: Maybe String
  - hiDir :: Maybe String
  - hieDir :: Maybe String
  - stubDir :: Maybe String
  - dumpDir :: Maybe String
  - objectSuf :: String
  - hcSuf :: String
  - hiSuf :: String
  - hieSuf :: String
  - canGenerateDynamicToo :: IORef Bool
  - dynObjectSuf :: String
  - dynHiSuf :: String
  - outputFile :: Maybe String
  - dynOutputFile :: Maybe String
  - outputHi :: Maybe String
  - dynLibLoader :: DynLibLoader
  - dumpPrefix :: Maybe FilePath
  - dumpPrefixForce :: Maybe FilePath
  - ldInputs :: [Option]
  - includePaths :: IncludeSpecs
  - libraryPaths :: [String]
  - frameworkPaths :: [String]
  - cmdlineFrameworks :: [String]
  - rtsOpts :: Maybe String
  - rtsOptsEnabled :: RtsOptsEnabled
  - rtsOptsSuggestions :: Bool
  - hpcDir :: String
  - pluginModNames :: [ModuleName]
  - pluginModNameOpts :: [(ModuleName, String)]
  - frontendPluginOpts :: [String]
  - cachedPlugins :: [LoadedPlugin]
  - staticPlugins :: [StaticPlugin]
  - hooks :: Hooks
  - depMakefile :: FilePath
  - depIncludePkgDeps :: Bool
  - depIncludeCppDeps :: Bool
  - depExcludeMods :: [ModuleName]
  - depSuffixes :: [String]
  - packageDBFlags :: [PackageDBFlag]
  - ignorePackageFlags :: [IgnorePackageFlag]
  - packageFlags :: [PackageFlag]
  - pluginPackageFlags :: [PackageFlag]
  - trustFlags :: [TrustFlag]
  - packageEnv :: Maybe FilePath
  - pkgDatabase :: Maybe [(FilePath, [PackageConfig])]
  - pkgState :: PackageState
  - filesToClean :: IORef FilesToClean
  - dirsToClean :: IORef (Map FilePath FilePath)
  - nextTempSuffix :: IORef Int
  - generatedDumps :: IORef (Set FilePath)
  - dumpFlags :: EnumSet DumpFlag
  - generalFlags :: EnumSet GeneralFlag
  - warningFlags :: EnumSet WarningFlag
  - fatalWarningFlags :: EnumSet WarningFlag
  - language :: Maybe Language
  - safeHaskell :: SafeHaskellMode
  - safeInfer :: Bool
  - safeInferred :: Bool
  - thOnLoc :: SrcSpan
  - newDerivOnLoc :: SrcSpan
  - overlapInstLoc :: SrcSpan
  - incoherentOnLoc :: SrcSpan
  - pkgTrustOnLoc :: SrcSpan
  - warnSafeOnLoc :: SrcSpan
  - warnUnsafeOnLoc :: SrcSpan
  - trustworthyOnLoc :: SrcSpan
  - extensions :: [OnOff Extension]
  - extensionFlags :: EnumSet Extension
  - ufCreationThreshold :: Int
  - ufUseThreshold :: Int
  - ufFunAppDiscount :: Int
  - ufDictDiscount :: Int
  - ufKeenessFactor :: Float
  - ufDearOp :: Int
  - ufVeryAggressive :: Bool
  - maxWorkerArgs :: Int
  - ghciHistSize :: Int
  - log_action :: LogAction
  - flushOut :: FlushOut
  - flushErr :: FlushErr
  - ghcVersionFile :: Maybe FilePath
  - haddockOptions :: Maybe String
  - ghciScripts :: [String]
  - pprUserLength :: Int
  - pprCols :: Int
  - useUnicode :: Bool
  - useColor :: OverridingBool
  - canUseColor :: Bool
  - colScheme :: Scheme
  - profAuto :: ProfAuto
  - interactivePrint :: Maybe String
  - nextWrapperNum :: IORef (ModuleEnv Int)
  - sseVersion :: Maybe SseVersion
  - bmiVersion :: Maybe BmiVersion
  - avx :: Bool
  - avx2 :: Bool
  - avx512cd :: Bool
  - avx512er :: Bool
  - avx512f :: Bool
  - avx512pf :: Bool
  - rtldInfo :: IORef (Maybe LinkerInfo)
  - rtccInfo :: IORef (Maybe CompilerInfo)
  - maxInlineAllocSize :: Int
  - maxInlineMemcpyInsns :: Int
  - maxInlineMemsetInsns :: Int
  - reverseErrors :: Bool
  - maxErrors :: Maybe Int
  - initialUnique :: Int
  - uniqueIncrement :: Int
  - cfgWeightInfo :: CfgWeights
  }
- data GeneralFlag
  - = Opt_DumpToFile
  - | Opt_D_faststring_stats
  - | Opt_D_dump_minimal_imports
  - | Opt_DoCoreLinting
  - | Opt_DoStgLinting
  - | Opt_DoCmmLinting
  - | Opt_DoAsmLinting
  - | Opt_DoAnnotationLinting
  - | Opt_NoLlvmMangler
  - | Opt_FastLlvm
  - | Opt_NoTypeableBinds
  - | Opt_WarnIsError
  - | Opt_ShowWarnGroups
  - | Opt_HideSourcePaths
  - | Opt_PrintExplicitForalls
  - | Opt_PrintExplicitKinds
  - | Opt_PrintExplicitCoercions
  - | Opt_PrintExplicitRuntimeReps
  - | Opt_PrintEqualityRelations
  - | Opt_PrintAxiomIncomps
  - | Opt_PrintUnicodeSyntax
  - | Opt_PrintExpandedSynonyms
  - | Opt_PrintPotentialInstances
  - | Opt_PrintTypecheckerElaboration
  - | Opt_CallArity
  - | Opt_Exitification
  - | Opt_Strictness
  - | Opt_LateDmdAnal
  - | Opt_KillAbsence
  - | Opt_KillOneShot
  - | Opt_FullLaziness
  - | Opt_FloatIn
  - | Opt_LateSpecialise
  - | Opt_Specialise
  - | Opt_SpecialiseAggressively
  - | Opt_CrossModuleSpecialise
  - | Opt_StaticArgumentTransformation
  - | Opt_CSE
  - | Opt_StgCSE
  - | Opt_StgLiftLams
  - | Opt_LiberateCase
  - | Opt_SpecConstr
  - | Opt_SpecConstrKeen
  - | Opt_DoLambdaEtaExpansion
  - | Opt_IgnoreAsserts
  - | Opt_DoEtaReduction
  - | Opt_CaseMerge
  - | Opt_CaseFolding
  - | Opt_UnboxStrictFields
  - | Opt_UnboxSmallStrictFields
  - | Opt_DictsCheap
  - | Opt_EnableRewriteRules
  - | Opt_EnableThSpliceWarnings
  - | Opt_RegsGraph
  - | Opt_RegsIterative
  - | Opt_PedanticBottoms
  - | Opt_LlvmTBAA
  - | Opt_LlvmFillUndefWithGarbage
  - | Opt_IrrefutableTuples
  - | Opt_CmmSink
  - | Opt_CmmElimCommonBlocks
  - | Opt_AsmShortcutting
  - | Opt_OmitYields
  - | Opt_FunToThunk
  - | Opt_DictsStrict
  - | Opt_DmdTxDictSel
  - | Opt_Loopification
  - | Opt_CfgBlocklayout
  - | Opt_WeightlessBlocklayout
  - | Opt_CprAnal
  - | Opt_WorkerWrapper
  - | Opt_SolveConstantDicts
  - | Opt_AlignmentSanitisation
  - | Opt_CatchBottoms
  - | Opt_NumConstantFolding
  - | Opt_SimplPreInlining
  - | Opt_IgnoreInterfacePragmas
  - | Opt_OmitInterfacePragmas
  - | Opt_ExposeAllUnfoldings
  - | Opt_WriteInterface
  - | Opt_WriteHie
  - | Opt_AutoSccsOnIndividualCafs
  - | Opt_ProfCountEntries
  - | Opt_Pp
  - | Opt_ForceRecomp
  - | Opt_IgnoreOptimChanges
  - | Opt_IgnoreHpcChanges
  - | Opt_ExcessPrecision
  - | Opt_EagerBlackHoling
  - | Opt_NoHsMain
  - | Opt_SplitSections
  - | Opt_StgStats
  - | Opt_HideAllPackages
  - | Opt_HideAllPluginPackages
  - | Opt_PrintBindResult
  - | Opt_Haddock
  - | Opt_HaddockOptions
  - | Opt_BreakOnException
  - | Opt_BreakOnError
  - | Opt_PrintEvldWithShow
  - | Opt_PrintBindContents
  - | Opt_GenManifest
  - | Opt_EmbedManifest
  - | Opt_SharedImplib
  - | Opt_BuildingCabalPackage
  - | Opt_IgnoreDotGhci
  - | Opt_GhciSandbox
  - | Opt_GhciHistory
  - | Opt_GhciLeakCheck
  - | Opt_ValidateHie
  - | Opt_LocalGhciHistory
  - | Opt_NoIt
  - | Opt_HelpfulErrors
  - | Opt_DeferTypeErrors
  - | Opt_DeferTypedHoles
  - | Opt_DeferOutOfScopeVariables
  - | Opt_PIC
  - | Opt_PIE
  - | Opt_PICExecutable
  - | Opt_ExternalDynamicRefs
  - | Opt_SccProfilingOn
  - | Opt_Ticky
  - | Opt_Ticky_Allocd
  - | Opt_Ticky_LNE
  - | Opt_Ticky_Dyn_Thunk
  - | Opt_RPath
  - | Opt_RelativeDynlibPaths
  - | Opt_Hpc
  - | Opt_FlatCache
  - | Opt_ExternalInterpreter
  - | Opt_OptimalApplicativeDo
  - | Opt_VersionMacros
  - | Opt_WholeArchiveHsLibs
  - | Opt_SingleLibFolder
  - | Opt_KeepCAFs
  - | Opt_KeepGoing
  - | Opt_ByteCodeIfUnboxed
  - | Opt_ErrorSpans
  - | Opt_DeferDiagnostics
  - | Opt_DiagnosticsShowCaret
  - | Opt_PprCaseAsLet
  - | Opt_PprShowTicks
  - | Opt_ShowHoleConstraints
  - | Opt_ShowValidHoleFits
  - | Opt_SortValidHoleFits
  - | Opt_SortBySizeHoleFits
  - | Opt_SortBySubsumHoleFits
  - | Opt_AbstractRefHoleFits
  - | Opt_UnclutterValidHoleFits
  - | Opt_ShowTypeAppOfHoleFits
  - | Opt_ShowTypeAppVarsOfHoleFits
  - | Opt_ShowDocsOfHoleFits
  - | Opt_ShowTypeOfHoleFits
  - | Opt_ShowProvOfHoleFits
  - | Opt_ShowMatchesOfHoleFits
  - | Opt_ShowLoadedModules
  - | Opt_HexWordLiterals
  - | Opt_SuppressCoercions
  - | Opt_SuppressVarKinds
  - | Opt_SuppressModulePrefixes
  - | Opt_SuppressTypeApplications
  - | Opt_SuppressIdInfo
  - | Opt_SuppressUnfoldings
  - | Opt_SuppressTypeSignatures
  - | Opt_SuppressUniques
  - | Opt_SuppressStgExts
  - | Opt_SuppressTicks
  - | Opt_SuppressTimestamps
  - | Opt_AutoLinkPackages
  - | Opt_ImplicitImportQualified
  - | Opt_KeepHscppFiles
  - | Opt_KeepHiDiffs
  - | Opt_KeepHcFiles
  - | Opt_KeepSFiles
  - | Opt_KeepTmpFiles
  - | Opt_KeepRawTokenStream
  - | Opt_KeepLlvmFiles
  - | Opt_KeepHiFiles
  - | Opt_KeepOFiles
  - | Opt_BuildDynamicToo
  - | Opt_DistrustAllPackages
  - | Opt_PackageTrust
  - | Opt_PluginTrustworthy
  - | Opt_G_NoStateHack
  - | Opt_G_NoOptCoercion
- data Severity
  - = SevOutput
  - | SevFatal
  - | SevInteractive
  - | SevDump
  - | SevInfo
  - | SevWarning
  - | SevError
- data HscTarget
  - = HscC
  - | HscAsm
  - | HscLlvm
  - | HscInterpreted
  - | HscNothing
- gopt :: GeneralFlag -> DynFlags -> Bool
- data GhcMode
  - = CompManager
  - | OneShot
  - | MkDepend
- data GhcLink
  - = NoLink
  - | LinkBinary
  - | LinkInMemory
  - | LinkDynLib
  - | LinkStaticLib
- defaultObjectTarget :: DynFlags -> HscTarget
- parseDynamicFlags :: MonadIO m => DynFlags -> [Located String] -> m (DynFlags, [Located String], [Warn])
- getSessionDynFlags :: GhcMonad m => m DynFlags
- setSessionDynFlags :: GhcMonad m => DynFlags -> m [InstalledUnitId]
- getProgramDynFlags :: GhcMonad m => m DynFlags
- setProgramDynFlags :: GhcMonad m => DynFlags -> m [InstalledUnitId]
- setLogAction :: GhcMonad m => LogAction -> m ()
- getInteractiveDynFlags :: GhcMonad m => m DynFlags
- setInteractiveDynFlags :: GhcMonad m => DynFlags -> m ()
- data Target = Target {
  - targetId :: TargetId
  - targetAllowObjCode :: Bool
  - targetContents :: Maybe (InputFileBuffer, UTCTime)
  }
- data TargetId
  - = TargetModule ModuleName
  - | TargetFile FilePath (Maybe Phase)
- data Phase
- setTargets :: GhcMonad m => [Target] -> m ()
- getTargets :: GhcMonad m => m [Target]
- addTarget :: GhcMonad m => Target -> m ()
- removeTarget :: GhcMonad m => TargetId -> m ()
- guessTarget :: GhcMonad m => String -> Maybe Phase -> m Target
- depanal :: GhcMonad m => [ModuleName] -> Bool -> m ModuleGraph
- load :: GhcMonad m => LoadHowMuch -> m SuccessFlag
- data LoadHowMuch
  - = LoadAllTargets
  - | LoadUpTo ModuleName
  - | LoadDependenciesOf ModuleName
- data InteractiveImport
  - = IIDecl (ImportDecl GhcPs)
  - | IIModule ModuleName
- data SuccessFlag
  - = Succeeded
  - | Failed
- succeeded :: SuccessFlag -> Bool
- failed :: SuccessFlag -> Bool
- defaultWarnErrLogger :: WarnErrLogger
- type WarnErrLogger = forall m. GhcMonad m => Maybe SourceError -> m ()
- workingDirectoryChanged :: GhcMonad m => m ()
- parseModule :: GhcMonad m => ModSummary -> m ParsedModule
- typecheckModule :: GhcMonad m => ParsedModule -> m TypecheckedModule
- desugarModule :: GhcMonad m => TypecheckedModule -> m DesugaredModule
- loadModule :: (TypecheckedMod mod, GhcMonad m) => mod -> m mod
- data ParsedModule = ParsedModule {
  - pm_mod_summary :: ModSummary
  - pm_parsed_source :: ParsedSource
  - pm_extra_src_files :: [FilePath]
  - pm_annotations :: ApiAnns
  }
- data TypecheckedModule = TypecheckedModule {
  - tm_parsed_module :: ParsedModule
  - tm_renamed_source :: Maybe RenamedSource
  - tm_typechecked_source :: TypecheckedSource
  - tm_checked_module_info :: ModuleInfo
  - tm_internals_ :: (TcGblEnv, ModDetails)
  }
- data DesugaredModule = DesugaredModule {
  - dm_typechecked_module :: TypecheckedModule
  - dm_core_module :: ModGuts
  }
- type TypecheckedSource = LHsBinds GhcTc
- type ParsedSource = Located (HsModule GhcPs)
- type RenamedSource = (HsGroup GhcRn, [LImportDecl GhcRn], Maybe [(LIE GhcRn, Avails)], Maybe LHsDocString)
- class ParsedMod m => TypecheckedMod m
- class ParsedMod m
- moduleInfo :: TypecheckedMod m => m -> ModuleInfo
- renamedSource :: TypecheckedMod m => m -> Maybe RenamedSource
- typecheckedSource :: TypecheckedMod m => m -> TypecheckedSource
- parsedSource :: ParsedMod m => m -> ParsedSource
- coreModule :: DesugaredMod m => m -> ModGuts
- data CoreModule = CoreModule {
  - cm_module :: !Module
  - cm_types :: !TypeEnv
  - cm_binds :: CoreProgram
  - cm_safe :: SafeHaskellMode
  }
- compileToCoreModule :: GhcMonad m => FilePath -> m CoreModule
- compileToCoreSimplified :: GhcMonad m => FilePath -> m CoreModule
- data ModuleGraph
- emptyMG :: ModuleGraph
- mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph
- mkModuleGraph :: [ModSummary] -> ModuleGraph
- mgModSummaries :: ModuleGraph -> [ModSummary]
- mgLookupModule :: ModuleGraph -> Module -> Maybe ModSummary
- data ModSummary = ModSummary {
  - ms_mod :: Module
  - ms_hsc_src :: HscSource
  - ms_location :: ModLocation
  - ms_hs_date :: UTCTime
  - ms_obj_date :: Maybe UTCTime
  - ms_iface_date :: Maybe UTCTime
  - ms_hie_date :: Maybe UTCTime
  - ms_srcimps :: [(Maybe FastString, Located ModuleName)]
  - ms_textual_imps :: [(Maybe FastString, Located ModuleName)]
  - ms_parsed_mod :: Maybe HsParsedModule
  - ms_hspp_file :: FilePath
  - ms_hspp_opts :: DynFlags
  - ms_hspp_buf :: Maybe StringBuffer
  }
- ms_mod_name :: ModSummary -> ModuleName
- data ModLocation = ModLocation {
  - ml_hs_file :: Maybe FilePath
  - ml_hi_file :: FilePath
  - ml_obj_file :: FilePath
  - ml_hie_file :: FilePath
  }
- getModSummary :: GhcMonad m => ModuleName -> m ModSummary
- getModuleGraph :: GhcMonad m => m ModuleGraph
- isLoaded :: GhcMonad m => ModuleName -> m Bool
- topSortModuleGraph :: Bool -> ModuleGraph -> Maybe ModuleName -> [SCC ModSummary]
- data ModuleInfo
- getModuleInfo :: GhcMonad m => Module -> m (Maybe ModuleInfo)
- modInfoTyThings :: ModuleInfo -> [TyThing]
- modInfoTopLevelScope :: ModuleInfo -> Maybe [Name]
- modInfoExports :: ModuleInfo -> [Name]
- modInfoExportsWithSelectors :: ModuleInfo -> [Name]
- modInfoInstances :: ModuleInfo -> [ClsInst]
- modInfoIsExportedName :: ModuleInfo -> Name -> Bool
- modInfoLookupName :: GhcMonad m => ModuleInfo -> Name -> m (Maybe TyThing)
- modInfoIface :: ModuleInfo -> Maybe ModIface
- modInfoRdrEnv :: ModuleInfo -> Maybe GlobalRdrEnv
- modInfoSafe :: ModuleInfo -> SafeHaskellMode
- lookupGlobalName :: GhcMonad m => Name -> m (Maybe TyThing)
- findGlobalAnns :: (GhcMonad m, Typeable a) => ([Word8] -> a) -> AnnTarget Name -> m [a]
- mkPrintUnqualifiedForModule :: GhcMonad m => ModuleInfo -> m (Maybe PrintUnqualified)
- type ModIface = ModIface_ 'ModIfaceFinal
- data ModIface_ (phase :: ModIfacePhase) = ModIface {
  - mi_module :: !Module
  - mi_sig_of :: !(Maybe Module)
  - mi_hsc_src :: !HscSource
  - mi_deps :: Dependencies
  - mi_usages :: [Usage]
  - mi_exports :: ![IfaceExport]
  - mi_used_th :: !Bool
  - mi_fixities :: [(OccName, Fixity)]
  - mi_warns :: Warnings
  - mi_anns :: [IfaceAnnotation]
  - mi_decls :: [IfaceDeclExts phase]
  - mi_globals :: !(Maybe GlobalRdrEnv)
  - mi_insts :: [IfaceClsInst]
  - mi_fam_insts :: [IfaceFamInst]
  - mi_rules :: [IfaceRule]
  - mi_hpc :: !AnyHpcUsage
  - mi_trust :: !IfaceTrustInfo
  - mi_trust_pkg :: !Bool
  - mi_complete_sigs :: [IfaceCompleteMatch]
  - mi_doc_hdr :: Maybe HsDocString
  - mi_decl_docs :: DeclDocMap
  - mi_arg_docs :: ArgDocMap
  - mi_final_exts :: !(IfaceBackendExts phase)
  }
- data SafeHaskellMode
  - = Sf_None
  - | Sf_Unsafe
  - | Sf_Trustworthy
  - | Sf_Safe
  - | Sf_SafeInferred
  - | Sf_Ignore
- data PrintUnqualified
- alwaysQualify :: PrintUnqualified
- execStmt :: GhcMonad m => String -> ExecOptions -> m ExecResult
- execStmt' :: GhcMonad m => GhciLStmt GhcPs -> String -> ExecOptions -> m ExecResult
- data ExecOptions = ExecOptions {
  - execSingleStep :: SingleStep
  - execSourceFile :: String
  - execLineNumber :: Int
  - execWrap :: ForeignHValue -> EvalExpr ForeignHValue
  }
- execOptions :: ExecOptions
- data ExecResult
  - = ExecComplete {
    - execResult :: Either SomeException [Name]
    - execAllocation :: Word64
    }
  - | ExecBreak {
    - breakNames :: [Name]
    - breakInfo :: Maybe BreakInfo
    }
- resumeExec :: GhcMonad m => (SrcSpan -> Bool) -> SingleStep -> m ExecResult
- runDecls :: GhcMonad m => String -> m [Name]
- runDeclsWithLocation :: GhcMonad m => String -> Int -> String -> m [Name]
- runParsedDecls :: GhcMonad m => [LHsDecl GhcPs] -> m [Name]
- parseImportDecl :: GhcMonad m => String -> m (ImportDecl GhcPs)
- setContext :: GhcMonad m => [InteractiveImport] -> m ()
- getContext :: GhcMonad m => m [InteractiveImport]
- setGHCiMonad :: GhcMonad m => String -> m ()
- getGHCiMonad :: GhcMonad m => m Name
- getBindings :: GhcMonad m => m [TyThing]
- getInsts :: GhcMonad m => m ([ClsInst], [FamInst])
- getPrintUnqual :: GhcMonad m => m PrintUnqualified
- findModule :: GhcMonad m => ModuleName -> Maybe FastString -> m Module
- lookupModule :: GhcMonad m => ModuleName -> Maybe FastString -> m Module
- isModuleTrusted :: GhcMonad m => Module -> m Bool
- moduleTrustReqs :: GhcMonad m => Module -> m (Bool, Set InstalledUnitId)
- getNamesInScope :: GhcMonad m => m [Name]
- getRdrNamesInScope :: GhcMonad m => m [RdrName]
- getGRE :: GhcMonad m => m GlobalRdrEnv
- moduleIsInterpreted :: GhcMonad m => Module -> m Bool
- getInfo :: GhcMonad m => Bool -> Name -> m (Maybe (TyThing, Fixity, [ClsInst], [FamInst], SDoc))
- showModule :: GhcMonad m => ModSummary -> m String
- moduleIsBootOrNotObjectLinkable :: GhcMonad m => ModSummary -> m Bool
- getNameToInstancesIndex :: GhcMonad m => [Module] -> Maybe [Module] -> m (Messages, Maybe (NameEnv ([ClsInst], [FamInst])))
- exprType :: GhcMonad m => TcRnExprMode -> String -> m Type
- data TcRnExprMode
  - = TM_Inst
  - | TM_NoInst
  - | TM_Default
- typeKind :: GhcMonad m => Bool -> String -> m (Type, Kind)
- parseName :: GhcMonad m => String -> m [Name]
- lookupName :: GhcMonad m => Name -> m (Maybe TyThing)
- data HValue
- parseExpr :: GhcMonad m => String -> m (LHsExpr GhcPs)
- compileParsedExpr :: GhcMonad m => LHsExpr GhcPs -> m HValue
- compileExpr :: GhcMonad m => String -> m HValue
- dynCompileExpr :: GhcMonad m => String -> m Dynamic
- type ForeignHValue = ForeignRef HValue
- compileExprRemote :: GhcMonad m => String -> m ForeignHValue
- compileParsedExprRemote :: GhcMonad m => LHsExpr GhcPs -> m ForeignHValue
- getDocs :: GhcMonad m => Name -> m (Either GetDocsFailure (Maybe HsDocString, Map Int HsDocString))
- data GetDocsFailure
  - = NameHasNoModule Name
  - | NoDocsInIface Module Bool
  - | InteractiveName
- runTcInteractive :: HscEnv -> TcRn a -> IO (Messages, Maybe a)
- isStmt :: DynFlags -> String -> Bool
- hasImport :: DynFlags -> String -> Bool
- isImport :: DynFlags -> String -> Bool
- isDecl :: DynFlags -> String -> Bool
- data SingleStep
  - = RunToCompletion
  - | SingleStep
  - | RunAndLogSteps
- data Resume = Resume {
  - resumeStmt :: String
  - resumeContext :: ForeignRef (ResumeContext [HValueRef])
  - resumeBindings :: ([TyThing], GlobalRdrEnv)
  - resumeFinalIds :: [Id]
  - resumeApStack :: ForeignHValue
  - resumeBreakInfo :: Maybe BreakInfo
  - resumeSpan :: SrcSpan
  - resumeDecl :: String
  - resumeCCS :: RemotePtr CostCentreStack
  - resumeHistory :: [History]
  - resumeHistoryIx :: Int
  }
- data History
- getHistorySpan :: GhcMonad m => History -> m SrcSpan
- getHistoryModule :: History -> Module
- abandon :: GhcMonad m => m Bool
- abandonAll :: GhcMonad m => m Bool
- getResumeContext :: GhcMonad m => m [Resume]
- obtainTermFromId :: GhcMonad m => Int -> Bool -> Id -> m Term
- obtainTermFromVal :: GhcMonad m => Int -> Bool -> Type -> a -> m Term
- reconstructType :: HscEnv -> Int -> Id -> IO (Maybe Type)
- modInfoModBreaks :: ModuleInfo -> ModBreaks
- data ModBreaks = ModBreaks {
  - modBreaks_flags :: ForeignRef BreakArray
  - modBreaks_locs :: !(Array BreakIndex SrcSpan)
  - modBreaks_vars :: !(Array BreakIndex [OccName])
  - modBreaks_decls :: !(Array BreakIndex [String])
  - modBreaks_ccs :: !(Array BreakIndex (RemotePtr CostCentre))
  - modBreaks_breakInfo :: IntMap CgBreakInfo
  }
- type BreakIndex = Int
- data BreakInfo
- back :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String)
- forward :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String)
- data UnitId
- data Module
- mkModule :: UnitId -> ModuleName -> Module
- pprModule :: Module -> SDoc
- moduleName :: Module -> ModuleName
- moduleUnitId :: Module -> UnitId
- data ModuleName
- mkModuleName :: String -> ModuleName
- moduleNameString :: ModuleName -> String
- data Name
- isExternalName :: Name -> Bool
- nameModule :: HasDebugCallStack => Name -> Module
- pprParenSymName :: NamedThing a => a -> SDoc
- nameSrcSpan :: Name -> SrcSpan
- class NamedThing a where
  - getOccName :: a -> OccName
  - getName :: a -> Name
- data RdrName
  - = Unqual OccName
  - | Qual ModuleName OccName
- type Id = Var
- idType :: Id -> Kind
- isImplicitId :: Id -> Bool
- isDeadBinder :: Id -> Bool
- isExportedId :: Var -> Bool
- isLocalId :: Var -> Bool
- isGlobalId :: Var -> Bool
- isRecordSelector :: Id -> Bool
- isPrimOpId :: Id -> Bool
- isFCallId :: Id -> Bool
- isClassOpId_maybe :: Id -> Maybe Class
- isDataConWorkId :: Id -> Bool
- idDataCon :: Id -> DataCon
- isBottomingId :: Var -> Bool
- isDictonaryId :: Id -> Bool
- recordSelectorTyCon :: Id -> RecSelParent
- data TyCon
- tyConTyVars :: TyCon -> [TyVar]
- tyConDataCons :: TyCon -> [DataCon]
- tyConArity :: TyCon -> Arity
- isClassTyCon :: TyCon -> Bool
- isTypeSynonymTyCon :: TyCon -> Bool
- isTypeFamilyTyCon :: TyCon -> Bool
- isNewTyCon :: TyCon -> Bool
- isPrimTyCon :: TyCon -> Bool
- isFunTyCon :: TyCon -> Bool
- isFamilyTyCon :: TyCon -> Bool
- isOpenFamilyTyCon :: TyCon -> Bool
- isOpenTypeFamilyTyCon :: TyCon -> Bool
- tyConClass_maybe :: TyCon -> Maybe Class
- synTyConRhs_maybe :: TyCon -> Maybe Type
- synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type)
- tyConKind :: TyCon -> Kind
- type TyVar = Var
- alphaTyVars :: [TyVar]
- data DataCon
- dataConSig :: DataCon -> ([TyCoVar], ThetaType, [Type], Type)
- dataConType :: DataCon -> Type
- dataConTyCon :: DataCon -> TyCon
- dataConFieldLabels :: DataCon -> [FieldLabel]
- dataConIsInfix :: DataCon -> Bool
- isVanillaDataCon :: DataCon -> Bool
- dataConUserType :: DataCon -> Type
- dataConSrcBangs :: DataCon -> [HsSrcBang]
- data StrictnessMark
  - = MarkedStrict
  - | NotMarkedStrict
- isMarkedStrict :: StrictnessMark -> Bool
- data Class
- classMethods :: Class -> [Id]
- classSCTheta :: Class -> [PredType]
- classTvsFds :: Class -> ([TyVar], [FunDep TyVar])
- classATs :: Class -> [TyCon]
- pprFundeps :: Outputable a => [FunDep a] -> SDoc
- data ClsInst
- instanceDFunId :: ClsInst -> DFunId
- pprInstance :: ClsInst -> SDoc
- pprInstanceHdr :: ClsInst -> SDoc
- pprFamInst :: FamInst -> SDoc
- data FamInst
- data Type
- splitForAllTys :: Type -> ([TyCoVar], Type)
- funResultTy :: Type -> Type
- pprParendType :: Type -> SDoc
- pprTypeApp :: TyCon -> [Type] -> SDoc
- type Kind = Type
- type PredType = Type
- type ThetaType = [PredType]
- pprForAll :: [TyCoVarBinder] -> SDoc
- pprThetaArrowTy :: ThetaType -> SDoc
- parseInstanceHead :: GhcMonad m => String -> m Type
- getInstancesForType :: GhcMonad m => Type -> m [ClsInst]
- data TyThing
  - = AnId Id
  - | AConLike ConLike
  - | ATyCon TyCon
  - | ACoAxiom (CoAxiom Branched)
- module GHC.Hs
- data FixityDirection
  - = InfixL
  - | InfixR
  - | InfixN
- defaultFixity :: Fixity
- maxPrecedence :: Int
- negateFixity :: Fixity
- compareFixity :: Fixity -> Fixity -> (Bool, Bool)
- data LexicalFixity
  - = Prefix
  - | Infix
- data SrcLoc
  - = RealSrcLoc !RealSrcLoc
  - | UnhelpfulLoc FastString
- data RealSrcLoc
- mkSrcLoc :: FastString -> Int -> Int -> SrcLoc
- noSrcLoc :: SrcLoc
- srcLocFile :: RealSrcLoc -> FastString
- srcLocLine :: RealSrcLoc -> Int
- srcLocCol :: RealSrcLoc -> Int
- data SrcSpan
  - = RealSrcSpan !RealSrcSpan
  - | UnhelpfulSpan !FastString
- data RealSrcSpan
- mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan
- srcLocSpan :: SrcLoc -> SrcSpan
- isGoodSrcSpan :: SrcSpan -> Bool
- noSrcSpan :: SrcSpan
- srcSpanStart :: SrcSpan -> SrcLoc
- srcSpanEnd :: SrcSpan -> SrcLoc
- srcSpanFile :: RealSrcSpan -> FastString
- srcSpanStartLine :: RealSrcSpan -> Int
- srcSpanEndLine :: RealSrcSpan -> Int
- srcSpanStartCol :: RealSrcSpan -> Int
- srcSpanEndCol :: RealSrcSpan -> Int
- data GenLocated l e = L l e
- type Located = GenLocated SrcSpan
- noLoc :: HasSrcSpan a => SrcSpanLess a -> a
- mkGeneralLocated :: HasSrcSpan e => String -> SrcSpanLess e -> e
- getLoc :: HasSrcSpan a => a -> SrcSpan
- unLoc :: HasSrcSpan a => a -> SrcSpanLess a
- getRealSrcSpan :: RealLocated a -> RealSrcSpan
- unRealSrcSpan :: RealLocated a -> a
- class HasSrcSpan a where
  - composeSrcSpan :: Located (SrcSpanLess a) -> a
  - decomposeSrcSpan :: a -> Located (SrcSpanLess a)
- type family SrcSpanLess a
- dL :: HasSrcSpan a => a -> Located (SrcSpanLess a)
- cL :: HasSrcSpan a => SrcSpan -> SrcSpanLess a -> a
- eqLocated :: (HasSrcSpan a, Eq (SrcSpanLess a)) => a -> a -> Bool
- cmpLocated :: (HasSrcSpan a, Ord (SrcSpanLess a)) => a -> a -> Ordering
- combineLocs :: (HasSrcSpan a, HasSrcSpan b) => a -> b -> SrcSpan
- addCLoc :: (HasSrcSpan a, HasSrcSpan b, HasSrcSpan c) => a -> b -> SrcSpanLess c -> c
- leftmost_smallest :: SrcSpan -> SrcSpan -> Ordering
- leftmost_largest :: SrcSpan -> SrcSpan -> Ordering
- rightmost :: SrcSpan -> SrcSpan -> Ordering
- spans :: SrcSpan -> (Int, Int) -> Bool
- isSubspanOf :: SrcSpan -> SrcSpan -> Bool
- data GhcException
  - = Signal Int
  - | UsageError String
  - | CmdLineError String
  - | Panic String
  - | PprPanic String SDoc
  - | Sorry String
  - | PprSorry String SDoc
  - | InstallationError String
  - | ProgramError String
  - | PprProgramError String SDoc
- showGhcException :: GhcException -> ShowS
- data Token
- getTokenStream :: GhcMonad m => Module -> m [Located Token]
- getRichTokenStream :: GhcMonad m => Module -> m [(Located Token, String)]
- showRichTokenStream :: [(Located Token, String)] -> String
- addSourceToTokens :: RealSrcLoc -> StringBuffer -> [Located Token] -> [(Located Token, String)]
- parser :: String -> DynFlags -> FilePath -> (WarningMessages, Either ErrorMessages (Located (HsModule GhcPs)))
- type ApiAnns = (Map ApiAnnKey [SrcSpan], Map SrcSpan [Located AnnotationComment])
- data AnnKeywordId
  - = AnnAnyclass
  - | AnnAs
  - | AnnAt
  - | AnnBang
  - | AnnBackquote
  - | AnnBy
  - | AnnCase
  - | AnnClass
  - | AnnClose
  - | AnnCloseB
  - | AnnCloseBU
  - | AnnCloseC
  - | AnnCloseQ
  - | AnnCloseQU
  - | AnnCloseP
  - | AnnCloseS
  - | AnnColon
  - | AnnComma
  - | AnnCommaTuple
  - | AnnDarrow
  - | AnnDarrowU
  - | AnnData
  - | AnnDcolon
  - | AnnDcolonU
  - | AnnDefault
  - | AnnDeriving
  - | AnnDo
  - | AnnDot
  - | AnnDotdot
  - | AnnElse
  - | AnnEqual
  - | AnnExport
  - | AnnFamily
  - | AnnForall
  - | AnnForallU
  - | AnnForeign
  - | AnnFunId
  - | AnnGroup
  - | AnnHeader
  - | AnnHiding
  - | AnnIf
  - | AnnImport
  - | AnnIn
  - | AnnInfix
  - | AnnInstance
  - | AnnLam
  - | AnnLarrow
  - | AnnLarrowU
  - | AnnLet
  - | AnnMdo
  - | AnnMinus
  - | AnnModule
  - | AnnNewtype
  - | AnnName
  - | AnnOf
  - | AnnOpen
  - | AnnOpenB
  - | AnnOpenBU
  - | AnnOpenC
  - | AnnOpenE
  - | AnnOpenEQ
  - | AnnOpenEQU
  - | AnnOpenP
  - | AnnOpenPE
  - | AnnOpenPTE
  - | AnnOpenS
  - | AnnPackageName
  - | AnnPattern
  - | AnnProc
  - | AnnQualified
  - | AnnRarrow
  - | AnnRarrowU
  - | AnnRec
  - | AnnRole
  - | AnnSafe
  - | AnnSemi
  - | AnnSimpleQuote
  - | AnnSignature
  - | AnnStatic
  - | AnnStock
  - | AnnThen
  - | AnnThIdSplice
  - | AnnThIdTySplice
  - | AnnThTyQuote
  - | AnnTilde
  - | AnnType
  - | AnnUnit
  - | AnnUsing
  - | AnnVal
  - | AnnValStr
  - | AnnVbar
  - | AnnVia
  - | AnnWhere
  - | Annlarrowtail
  - | AnnlarrowtailU
  - | Annrarrowtail
  - | AnnrarrowtailU
  - | AnnLarrowtail
  - | AnnLarrowtailU
  - | AnnRarrowtail
  - | AnnRarrowtailU
  - | AnnEofPos
- data AnnotationComment
  - = AnnDocCommentNext String
  - | AnnDocCommentPrev String
  - | AnnDocCommentNamed String
  - | AnnDocSection Int String
  - | AnnDocOptions String
  - | AnnLineComment String
  - | AnnBlockComment String
- getAnnotation :: ApiAnns -> SrcSpan -> AnnKeywordId -> [SrcSpan]
- getAndRemoveAnnotation :: ApiAnns -> SrcSpan -> AnnKeywordId -> ([SrcSpan], ApiAnns)
- getAnnotationComments :: ApiAnns -> SrcSpan -> [Located AnnotationComment]
- getAndRemoveAnnotationComments :: ApiAnns -> SrcSpan -> ([Located AnnotationComment], ApiAnns)
- unicodeAnn :: AnnKeywordId -> AnnKeywordId
- cyclicModuleErr :: [ModSummary] -> SDoc

# Initialisation

defaultErrorHandler :: ExceptionMonad m => FatalMessager -> FlushOut -> m a -> m a #

Install some default exception handlers and run the inner computation. Unless you want to handle exceptions yourself, you should wrap this around the top level of your program. The default handlers output the error message(s) to stderr and exit cleanly.

defaultCleanupHandler :: ExceptionMonad m => DynFlags -> m a -> m a #

Deprecated: Cleanup is now done by runGhc/runGhcT

This function is no longer necessary, cleanup is now done by runGhc/runGhcT.

prettyPrintGhcErrors :: ExceptionMonad m => DynFlags -> m a -> m a #

withSignalHandlers :: (ExceptionMonad m, MonadIO m) => m a -> m a #

Temporarily install standard signal handlers for catching ^C, which just throw an exception in the current thread.

withCleanupSession :: GhcMonad m => m a -> m a #

# GHC Monad

data Ghc a #

A minimal implementation of a `GhcMonad`. If you need a custom monad, e.g., to maintain additional state consider wrapping this monad or using `GhcT`.

#### Instances

Instances details

Monad Ghc # |
Instance details Defined in GhcMonad Methods (>>=) :: Ghc a -> (a -> Ghc b) -> Ghc b Source # (>>) :: Ghc a -> Ghc b -> Ghc b Source # return :: a -> Ghc a Source #
Functor Ghc # |
Instance details Defined in GhcMonad Methods fmap :: (a -> b) -> Ghc a -> Ghc b Source # (<$) :: a -> Ghc b -> Ghc a Source #
MonadFix Ghc # |
Instance details Defined in GhcMonad Methods mfix :: (a -> Ghc a) -> Ghc a Source #
Applicative Ghc # |
Instance details Defined in GhcMonad Methods pure :: a -> Ghc a Source # (<*>) :: Ghc (a -> b) -> Ghc a -> Ghc b Source # liftA2 :: (a -> b -> c) -> Ghc a -> Ghc b -> Ghc c Source # (*>) :: Ghc a -> Ghc b -> Ghc b Source # (<*) :: Ghc a -> Ghc b -> Ghc a Source #
MonadIO Ghc # |
Instance details Defined in GhcMonad Methods liftIO :: IO a -> Ghc a Source #
ExceptionMonad Ghc # |
Instance details Defined in GhcMonad Methods gcatch :: Exception e => Ghc a -> (e -> Ghc a) -> Ghc a # gmask :: ((Ghc a -> Ghc a) -> Ghc b) -> Ghc b # gbracket :: Ghc a -> (a -> Ghc b) -> (a -> Ghc c) -> Ghc c # gfinally :: Ghc a -> Ghc b -> Ghc a #
HasDynFlags Ghc # |
Instance details Defined in GhcMonad Methods getDynFlags :: Ghc DynFlags #
GhcMonad Ghc # |
Instance details Defined in GhcMonad Methods getSession :: Ghc HscEnv # setSession :: HscEnv -> Ghc () #

data GhcT m a #

A monad transformer to add GHC specific features to another monad.

Note that the wrapped monad must support IO and handling of exceptions.

#### Instances

Instances details

Monad m => Monad (GhcT m) # |
Instance details Defined in GhcMonad Methods (>>=) :: GhcT m a -> (a -> GhcT m b) -> GhcT m b Source # (>>) :: GhcT m a -> GhcT m b -> GhcT m b Source # return :: a -> GhcT m a Source #
Functor m => Functor (GhcT m) # |
Instance details Defined in GhcMonad Methods fmap :: (a -> b) -> GhcT m a -> GhcT m b Source # (<$) :: a -> GhcT m b -> GhcT m a Source #
Applicative m => Applicative (GhcT m) # |
Instance details Defined in GhcMonad Methods pure :: a -> GhcT m a Source # (<*>) :: GhcT m (a -> b) -> GhcT m a -> GhcT m b Source # liftA2 :: (a -> b -> c) -> GhcT m a -> GhcT m b -> GhcT m c Source # (*>) :: GhcT m a -> GhcT m b -> GhcT m b Source # (<*) :: GhcT m a -> GhcT m b -> GhcT m a Source #
MonadIO m => MonadIO (GhcT m) # |
Instance details Defined in GhcMonad Methods liftIO :: IO a -> GhcT m a Source #
ExceptionMonad m => ExceptionMonad (GhcT m) # |
Instance details Defined in GhcMonad Methods gcatch :: Exception e => GhcT m a -> (e -> GhcT m a) -> GhcT m a # gmask :: ((GhcT m a -> GhcT m a) -> GhcT m b) -> GhcT m b # gbracket :: GhcT m a -> (a -> GhcT m b) -> (a -> GhcT m c) -> GhcT m c # gfinally :: GhcT m a -> GhcT m b -> GhcT m a #
MonadIO m => HasDynFlags (GhcT m) # |
Instance details Defined in GhcMonad Methods getDynFlags :: GhcT m DynFlags #
ExceptionMonad m => GhcMonad (GhcT m) # |
Instance details Defined in GhcMonad Methods getSession :: GhcT m HscEnv # setSession :: HscEnv -> GhcT m () #

class (Functor m, MonadIO m, ExceptionMonad m, HasDynFlags m) => GhcMonad m where #

A monad that has all the features needed by GHC API calls.

In short, a GHC monad

- allows embedding of IO actions,
- can log warnings,
- allows handling of (extensible) exceptions, and
- maintains a current session.

If you do not use `Ghc` or `GhcT`, make sure to call `initGhcMonad` before any call to the GHC API functions can occur.

Methods

getSession :: m HscEnv #

setSession :: HscEnv -> m () #

#### Instances

Instances details

GhcMonad Ghc # |
Instance details Defined in GhcMonad Methods getSession :: Ghc HscEnv # setSession :: HscEnv -> Ghc () #
ExceptionMonad m => GhcMonad (GhcT m) # |
Instance details Defined in GhcMonad Methods getSession :: GhcT m HscEnv # setSession :: HscEnv -> GhcT m () #

data HscEnv #

HscEnv is like `Session`, except that some of the fields are immutable. An HscEnv is used to compile a single module from plain Haskell source code (after preprocessing) to either C, assembly or C--. It's also used to store the dynamic linker state to allow for multiple linkers in the same address space. Things like the module graph don't change during a single compilation.

Historical note: "hsc" used to be the name of the compiler binary, when there was a separate driver and compiler. To compile a single module, the driver would invoke hsc on the source code... so nowadays we think of hsc as the layer of the compiler that deals with compiling a single module.

runGhc #

Arguments

:: Maybe FilePath | See argument to `initGhcMonad`.
-> Ghc a | The action to perform.
-> IO a |

Run function for the `Ghc` monad.

It initialises the GHC session and warnings via `initGhcMonad`. Each call to this function will create a new session which should not be shared among several threads.

Any errors not handled inside the `Ghc` action are propagated as IO exceptions.

runGhcT #

Arguments

:: ExceptionMonad m |
=> Maybe FilePath | See argument to `initGhcMonad`.
-> GhcT m a | The action to perform.
-> m a |

Run function for `GhcT` monad transformer.

It initialises the GHC session and warnings via `initGhcMonad`. Each call to this function will create a new session which should not be shared among several threads.

initGhcMonad :: GhcMonad m => Maybe FilePath -> m () #

Initialise a GHC session.

If you implement a custom `GhcMonad` you must call this function in the monad run function. It will initialise the session variable and clear all warnings.

The first argument should point to the directory where GHC's library files reside. More precisely, this should be the output of `ghc --print-libdir` of the version of GHC the module using this API is compiled with. For portability, you should use the `ghc-paths` package, available at http://hackage.haskell.org/package/ghc-paths.

gcatch :: (ExceptionMonad m, Exception e) => m a -> (e -> m a) -> m a #

Generalised version of `catch`, allowing an arbitrary exception handling monad instead of just `IO`.

gbracket :: ExceptionMonad m => m a -> (a -> m b) -> (a -> m c) -> m c #

Generalised version of `bracket`, allowing an arbitrary exception handling monad instead of just `IO`.

gfinally :: ExceptionMonad m => m a -> m b -> m a #

Generalised version of `finally`, allowing an arbitrary exception handling monad instead of just `IO`.

printException :: GhcMonad m => SourceError -> m () #

Print the error message and all warnings. Useful inside exception handlers. Clears warnings after printing.

handleSourceError #

Arguments

:: ExceptionMonad m |
=> (SourceError -> m a) | exception handler
-> m a | action to perform
-> m a |

Perform the given action and call the exception handler if the action throws a `SourceError`. See `SourceError` for more information.

needsTemplateHaskellOrQQ :: ModuleGraph -> Bool #

Determines whether a set of modules requires Template Haskell or Quasi Quotes

Note that if the session's `DynFlags` enabled Template Haskell when `depanal` was called, then each module in the returned module graph will have Template Haskell enabled whether it is actually needed or not.

# Flags and settings

data DynFlags #

Contains not only a collection of `GeneralFlag`s but also a plethora of information relating to the compilation of a single file or GHC session

Constructors

DynFlags |
Fields ghcMode :: GhcMode ghcLink :: GhcLink hscTarget :: HscTarget ghcNameVersion :: !GhcNameVersion fileSettings :: !FileSettings targetPlatform :: Platform toolSettings :: !ToolSettings platformMisc :: !PlatformMisc platformConstants :: PlatformConstants rawSettings :: [(String, String)] integerLibrary :: IntegerLibrary IntegerGMP or IntegerSimple. Set at configure time, but may be overriden by GHC-API users. See Note [The integer library] in PrelNames llvmConfig :: LlvmConfig N.B. It's important that this field is lazy since we load the LLVM configuration lazily. See Note [LLVM Configuration] in SysTools. verbosity :: Int Verbosity level: see Note [Verbosity levels] optLevel :: Int Optimisation level debugLevel :: Int How much debug information to produce simplPhases :: Int Number of simplifier phases maxSimplIterations :: Int Max simplifier iterations ruleCheck :: Maybe String inlineCheck :: Maybe String A prefix to report inlining decisions about strictnessBefore :: [Int] Additional demand analysis parMakeCount :: Maybe Int The number of modules to compile in parallel in --make mode, where Nothing ==> compile as many in parallel as there are CPUs. enableTimeStats :: Bool Enable RTS timing statistics? ghcHeapSize :: Maybe Int The heap size to set. maxRelevantBinds :: Maybe Int Maximum number of bindings from the type envt to show in type error messages maxValidHoleFits :: Maybe Int Maximum number of hole fits to show in typed hole error messages maxRefHoleFits :: Maybe Int Maximum number of refinement hole fits to show in typed hole error messages refLevelHoleFits :: Maybe Int Maximum level of refinement for refinement hole fits in typed hole error messages maxUncoveredPatterns :: Int Maximum number of unmatched patterns to show in non-exhaustiveness warnings maxPmCheckModels :: Int Soft limit on the number of models the pattern match checker checks a pattern against. A safe guard against exponential blow-up. simplTickFactor :: Int Multiplier for simplifier ticks specConstrThreshold :: Maybe Int Threshold for SpecConstr specConstrCount :: Maybe Int Max number of specialisations for any one function specConstrRecursive :: Int Max number of specialisations for recursive types Not optional; otherwise ForceSpecConstr can diverge. binBlobThreshold :: Word Binary literals (e.g. strings) whose size is above this threshold will be dumped in a binary file by the assembler code generator (0 to disable) liberateCaseThreshold :: Maybe Int Threshold for LiberateCase floatLamArgs :: Maybe Int Arg count for lambda floating See CoreMonad.FloatOutSwitches liftLamsRecArgs :: Maybe Int Maximum number of arguments after lambda lifting a recursive function. liftLamsNonRecArgs :: Maybe Int Maximum number of arguments after lambda lifting a non-recursive function. liftLamsKnown :: Bool Lambda lift even when this turns a known call into an unknown call. cmmProcAlignment :: Maybe Int Align Cmm functions at this boundary or use default. historySize :: Int Simplification history size importPaths :: [FilePath] mainModIs :: Module mainFunIs :: Maybe String reductionDepth :: IntWithInf Typechecker maximum stack depth solverIterations :: IntWithInf Number of iterations in the constraints solver Typically only 1 is needed thisInstalledUnitId :: InstalledUnitId thisComponentId_ :: Maybe ComponentId thisUnitIdInsts_ :: Maybe [(ModuleName, Module)] ways :: [Way] Way flags from the command line buildTag :: String The global "way" (e.g. "p" for prof) splitInfo :: Maybe (String, Int) objectDir :: Maybe String dylibInstallName :: Maybe String hiDir :: Maybe String hieDir :: Maybe String stubDir :: Maybe String dumpDir :: Maybe String objectSuf :: String hcSuf :: String hiSuf :: String hieSuf :: String canGenerateDynamicToo :: IORef Bool dynObjectSuf :: String dynHiSuf :: String outputFile :: Maybe String dynOutputFile :: Maybe String outputHi :: Maybe String dynLibLoader :: DynLibLoader dumpPrefix :: Maybe FilePath This is set by `runPipeline` based on where its output is going. dumpPrefixForce :: Maybe FilePath Override the `dumpPrefix` set by `runPipeline`. Set by `-ddump-file-prefix` ldInputs :: [Option] includePaths :: IncludeSpecs libraryPaths :: [String] frameworkPaths :: [String] cmdlineFrameworks :: [String] rtsOpts :: Maybe String rtsOptsEnabled :: RtsOptsEnabled rtsOptsSuggestions :: Bool hpcDir :: String Path to store the .mix files pluginModNames :: [ModuleName] pluginModNameOpts :: [(ModuleName, String)] frontendPluginOpts :: [String] the `-ffrontend-opt` flags given on the command line, in *reverse* order that they're specified on the command line. cachedPlugins :: [LoadedPlugin] plugins dynamically loaded after processing arguments. What will be loaded here is directed by pluginModNames. Arguments are loaded from pluginModNameOpts. The purpose of this field is to cache the plugins so they don't have to be loaded each time they are needed. See `initializePlugins`. staticPlugins :: [StaticPlugin] staic plugins which do not need dynamic loading. These plugins are intended to be added by GHC API users directly to this list. To add dynamically loaded plugins through the GHC API see `addPluginModuleName` instead. hooks :: Hooks depMakefile :: FilePath depIncludePkgDeps :: Bool depIncludeCppDeps :: Bool depExcludeMods :: [ModuleName] depSuffixes :: [String] packageDBFlags :: [PackageDBFlag] The `-package-db` flags given on the command line, In *reverse* order that they're specified on the command line. This is intended to be applied with the list of "initial" package databases derived from `GHC_PACKAGE_PATH`; see `getPackageConfRefs`. ignorePackageFlags :: [IgnorePackageFlag] The `-ignore-package` flags from the command line. In *reverse* order that they're specified on the command line. packageFlags :: [PackageFlag] The `-package` and `-hide-package` flags from the command-line. In *reverse* order that they're specified on the command line. pluginPackageFlags :: [PackageFlag] The `-plugin-package-id` flags from command line. In *reverse* order that they're specified on the command line. trustFlags :: [TrustFlag] The `-trust` and `-distrust` flags. In *reverse* order that they're specified on the command line. packageEnv :: Maybe FilePath Filepath to the package environment file (if overriding default) pkgDatabase :: Maybe [(FilePath, [PackageConfig])] pkgState :: PackageState filesToClean :: IORef FilesToClean dirsToClean :: IORef (Map FilePath FilePath) nextTempSuffix :: IORef Int generatedDumps :: IORef (Set FilePath) dumpFlags :: EnumSet DumpFlag generalFlags :: EnumSet GeneralFlag warningFlags :: EnumSet WarningFlag fatalWarningFlags :: EnumSet WarningFlag language :: Maybe Language safeHaskell :: SafeHaskellMode Safe Haskell mode safeInfer :: Bool safeInferred :: Bool thOnLoc :: SrcSpan newDerivOnLoc :: SrcSpan overlapInstLoc :: SrcSpan incoherentOnLoc :: SrcSpan pkgTrustOnLoc :: SrcSpan warnSafeOnLoc :: SrcSpan warnUnsafeOnLoc :: SrcSpan trustworthyOnLoc :: SrcSpan extensions :: [OnOff Extension] extensionFlags :: EnumSet Extension ufCreationThreshold :: Int ufUseThreshold :: Int ufFunAppDiscount :: Int ufDictDiscount :: Int ufKeenessFactor :: Float ufDearOp :: Int ufVeryAggressive :: Bool maxWorkerArgs :: Int ghciHistSize :: Int log_action :: LogAction MsgDoc output action: use ErrUtils instead of this if you can flushOut :: FlushOut flushErr :: FlushErr ghcVersionFile :: Maybe FilePath haddockOptions :: Maybe String ghciScripts :: [String] GHCi scripts specified by -ghci-script, in reverse order pprUserLength :: Int pprCols :: Int useUnicode :: Bool useColor :: OverridingBool canUseColor :: Bool colScheme :: Scheme profAuto :: ProfAuto what kind of {-# SCC #-} to add automatically interactivePrint :: Maybe String nextWrapperNum :: IORef (ModuleEnv Int) sseVersion :: Maybe SseVersion Machine dependent flags (-mblah stuff) bmiVersion :: Maybe BmiVersion avx :: Bool avx2 :: Bool avx512cd :: Bool avx512er :: Bool avx512f :: Bool avx512pf :: Bool rtldInfo :: IORef (Maybe LinkerInfo) Run-time linker information (what options we need, etc.) rtccInfo :: IORef (Maybe CompilerInfo) Run-time compiler information maxInlineAllocSize :: Int Max size, in bytes, of inline array allocations. maxInlineMemcpyInsns :: Int Only inline memcpy if it generates no more than this many pseudo (roughly: Cmm) instructions. maxInlineMemsetInsns :: Int Only inline memset if it generates no more than this many pseudo (roughly: Cmm) instructions. reverseErrors :: Bool Reverse the order of error messages in GHC/GHCi maxErrors :: Maybe Int Limit the maximum number of errors to show initialUnique :: Int Unique supply configuration for testing build determinism uniqueIncrement :: Int cfgWeightInfo :: CfgWeights Temporary: CFG Edge weights for fast iterations

data GeneralFlag #

Enumerates the simple on-or-off dynamic flags

Constructors

Opt_DumpToFile | Append dump output to files instead of stdout.
Opt_D_faststring_stats |
Opt_D_dump_minimal_imports |
Opt_DoCoreLinting |
Opt_DoStgLinting |
Opt_DoCmmLinting |
Opt_DoAsmLinting |
Opt_DoAnnotationLinting |
Opt_NoLlvmMangler |
Opt_FastLlvm |
Opt_NoTypeableBinds |
Opt_WarnIsError |
Opt_ShowWarnGroups |
Opt_HideSourcePaths |
Opt_PrintExplicitForalls |
Opt_PrintExplicitKinds |
Opt_PrintExplicitCoercions |
Opt_PrintExplicitRuntimeReps |
Opt_PrintEqualityRelations |
Opt_PrintAxiomIncomps |
Opt_PrintUnicodeSyntax |
Opt_PrintExpandedSynonyms |
Opt_PrintPotentialInstances |
Opt_PrintTypecheckerElaboration |
Opt_CallArity |
Opt_Exitification |
Opt_Strictness |
Opt_LateDmdAnal |
Opt_KillAbsence |
Opt_KillOneShot |
Opt_FullLaziness |
Opt_FloatIn |
Opt_LateSpecialise |
Opt_Specialise |
Opt_SpecialiseAggressively |
Opt_CrossModuleSpecialise |
Opt_StaticArgumentTransformation |
Opt_CSE |
Opt_StgCSE |
Opt_StgLiftLams |
Opt_LiberateCase |
Opt_SpecConstr |
Opt_SpecConstrKeen |
Opt_DoLambdaEtaExpansion |
Opt_IgnoreAsserts |
Opt_DoEtaReduction |
Opt_CaseMerge |
Opt_CaseFolding |
Opt_UnboxStrictFields |
Opt_UnboxSmallStrictFields |
Opt_DictsCheap |
Opt_EnableRewriteRules |
Opt_EnableThSpliceWarnings |
Opt_RegsGraph |
Opt_RegsIterative |
Opt_PedanticBottoms |
Opt_LlvmTBAA |
Opt_LlvmFillUndefWithGarbage |
Opt_IrrefutableTuples |
Opt_CmmSink |
Opt_CmmElimCommonBlocks |
Opt_AsmShortcutting |
Opt_OmitYields |
Opt_FunToThunk |
Opt_DictsStrict |
Opt_DmdTxDictSel |
Opt_Loopification |
Opt_CfgBlocklayout | Use the cfg based block layout algorithm.
Opt_WeightlessBlocklayout | Layout based on last instruction per block.
Opt_CprAnal |
Opt_WorkerWrapper |
Opt_SolveConstantDicts |
Opt_AlignmentSanitisation |
Opt_CatchBottoms |
Opt_NumConstantFolding |
Opt_SimplPreInlining |
Opt_IgnoreInterfacePragmas |
Opt_OmitInterfacePragmas |
Opt_ExposeAllUnfoldings |
Opt_WriteInterface |
Opt_WriteHie |
Opt_AutoSccsOnIndividualCafs |
Opt_ProfCountEntries |
Opt_Pp |
Opt_ForceRecomp |
Opt_IgnoreOptimChanges |
Opt_IgnoreHpcChanges |
Opt_ExcessPrecision |
Opt_EagerBlackHoling |
Opt_NoHsMain |
Opt_SplitSections |
Opt_StgStats |
Opt_HideAllPackages |
Opt_HideAllPluginPackages |
Opt_PrintBindResult |
Opt_Haddock |
Opt_HaddockOptions |
Opt_BreakOnException |
Opt_BreakOnError |
Opt_PrintEvldWithShow |
Opt_PrintBindContents |
Opt_GenManifest |
Opt_EmbedManifest |
Opt_SharedImplib |
Opt_BuildingCabalPackage |
Opt_IgnoreDotGhci |
Opt_GhciSandbox |
Opt_GhciHistory |
Opt_GhciLeakCheck |
Opt_ValidateHie |
Opt_LocalGhciHistory |
Opt_NoIt |
Opt_HelpfulErrors |
Opt_DeferTypeErrors |
Opt_DeferTypedHoles |
Opt_DeferOutOfScopeVariables |
Opt_PIC |
    -fPIC
Opt_PIE |
    -fPIE
Opt_PICExecutable |
    -pie
Opt_ExternalDynamicRefs |
Opt_SccProfilingOn |
Opt_Ticky |
Opt_Ticky_Allocd |
Opt_Ticky_LNE |
Opt_Ticky_Dyn_Thunk |
Opt_RPath |
Opt_RelativeDynlibPaths |
Opt_Hpc |
Opt_FlatCache |
Opt_ExternalInterpreter |
Opt_OptimalApplicativeDo |
Opt_VersionMacros |
Opt_WholeArchiveHsLibs |
Opt_SingleLibFolder |
Opt_KeepCAFs |
Opt_KeepGoing |
Opt_ByteCodeIfUnboxed |
Opt_ErrorSpans |
Opt_DeferDiagnostics |
Opt_DiagnosticsShowCaret |
Opt_PprCaseAsLet |
Opt_PprShowTicks |
Opt_ShowHoleConstraints |
Opt_ShowValidHoleFits |
Opt_SortValidHoleFits |
Opt_SortBySizeHoleFits |
Opt_SortBySubsumHoleFits |
Opt_AbstractRefHoleFits |
Opt_UnclutterValidHoleFits |
Opt_ShowTypeAppOfHoleFits |
Opt_ShowTypeAppVarsOfHoleFits |
Opt_ShowDocsOfHoleFits |
Opt_ShowTypeOfHoleFits |
Opt_ShowProvOfHoleFits |
Opt_ShowMatchesOfHoleFits |
Opt_ShowLoadedModules |
Opt_HexWordLiterals |
Opt_SuppressCoercions |
Opt_SuppressVarKinds |
Opt_SuppressModulePrefixes |
Opt_SuppressTypeApplications |
Opt_SuppressIdInfo |
Opt_SuppressUnfoldings |
Opt_SuppressTypeSignatures |
Opt_SuppressUniques |
Opt_SuppressStgExts |
Opt_SuppressTicks |
Opt_SuppressTimestamps | Suppress timestamps in dumps
Opt_AutoLinkPackages |
Opt_ImplicitImportQualified |
Opt_KeepHscppFiles |
Opt_KeepHiDiffs |
Opt_KeepHcFiles |
Opt_KeepSFiles |
Opt_KeepTmpFiles |
Opt_KeepRawTokenStream |
Opt_KeepLlvmFiles |
Opt_KeepHiFiles |
Opt_KeepOFiles |
Opt_BuildDynamicToo |
Opt_DistrustAllPackages |
Opt_PackageTrust |
Opt_PluginTrustworthy |
Opt_G_NoStateHack |
Opt_G_NoOptCoercion |

#### Instances

Instances details

Enum GeneralFlag # |
Instance details Defined in DynFlags Methods succ :: GeneralFlag -> GeneralFlag Source # pred :: GeneralFlag -> GeneralFlag Source # toEnum :: Int -> GeneralFlag Source # fromEnum :: GeneralFlag -> Int Source # enumFrom :: GeneralFlag -> [GeneralFlag] Source # enumFromThen :: GeneralFlag -> GeneralFlag -> [GeneralFlag] Source # enumFromTo :: GeneralFlag -> GeneralFlag -> [GeneralFlag] Source # enumFromThenTo :: GeneralFlag -> GeneralFlag -> GeneralFlag -> [GeneralFlag] Source #
Eq GeneralFlag # |
Instance details Defined in DynFlags Methods (==) :: GeneralFlag -> GeneralFlag -> Bool # (/=) :: GeneralFlag -> GeneralFlag -> Bool #
Show GeneralFlag # |
Instance details Defined in DynFlags Methods showsPrec :: Int -> GeneralFlag -> ShowS Source # show :: GeneralFlag -> String Source # showList :: [GeneralFlag] -> ShowS Source #

data Severity #

Constructors

SevOutput |
SevFatal |
SevInteractive |
SevDump | Log message intended for compiler developers No filelinecolumn stuff
SevInfo | Log messages intended for end users. No filelinecolumn stuff.
SevWarning |
SevError | SevWarning and SevError are used for warnings and errors o The message has a filelinecolumn heading, plus "warning:" or "error:", added by mkLocMessags o Output is intended for end users

#### Instances

Instances details

Show Severity # |
Instance details Defined in ErrUtils Methods showsPrec :: Int -> Severity -> ShowS Source # show :: Severity -> String Source # showList :: [Severity] -> ShowS Source #
ToJson Severity # |
Instance details Defined in ErrUtils Methods json :: Severity -> JsonDoc #

data HscTarget #

The target code type of the compilation (if any).

Whenever you change the target, also make sure to set `ghcLink` to something sensible.

`HscNothing` can be used to avoid generating any output, however, note that:

- If a program uses Template Haskell the typechecker may need to run code from an imported module. To facilitate this, code generation is enabled for modules imported by modules that use template haskell. See Note [-fno-code mode].

Constructors

HscC | Generate C code.
HscAsm | Generate assembly using the native code generator.
HscLlvm | Generate assembly using the llvm code generator.
HscInterpreted | Generate bytecode. (Requires `LinkInMemory`)
HscNothing | Don't generate any code. See notes above.

#### Instances

Instances details

Eq HscTarget # |
Instance details Defined in DynFlags Methods (==) :: HscTarget -> HscTarget -> Bool # (/=) :: HscTarget -> HscTarget -> Bool #
Show HscTarget # |
Instance details Defined in DynFlags Methods showsPrec :: Int -> HscTarget -> ShowS Source # show :: HscTarget -> String Source # showList :: [HscTarget] -> ShowS Source #

gopt :: GeneralFlag -> DynFlags -> Bool #

Test whether a `GeneralFlag` is set

data GhcMode #

The `GhcMode` tells us whether we're doing multi-module compilation (controlled via the GHC API) or one-shot (single-module) compilation. This makes a difference primarily to the Finder: in one-shot mode we look for interface files for imported modules, but in multi-module mode we look for source files in order to check whether they need to be recompiled.

Constructors

CompManager | `--make`, GHCi, etc.
OneShot |
    ghc -c Foo.hs
MkDepend | `ghc -M`, see Finder for why we need this

#### Instances

Instances details

Eq GhcMode # |
Instance details Defined in DynFlags Methods (==) :: GhcMode -> GhcMode -> Bool # (/=) :: GhcMode -> GhcMode -> Bool #
Outputable GhcMode # |
Instance details Defined in DynFlags Methods ppr :: GhcMode -> SDoc # pprPrec :: Rational -> GhcMode -> SDoc #

data GhcLink #

What to do in the link step, if there is one.

Constructors

NoLink | Don't link at all
LinkBinary | Link object code into a binary
LinkInMemory | Use the in-memory dynamic linker (works for both bytecode and object code).
LinkDynLib | Link objects into a dynamic lib (DLL on Windows, DSO on ELF platforms)
LinkStaticLib | Link objects into a static lib

#### Instances

Instances details

Eq GhcLink # |
Instance details Defined in DynFlags Methods (==) :: GhcLink -> GhcLink -> Bool # (/=) :: GhcLink -> GhcLink -> Bool #
Show GhcLink # |
Instance details Defined in DynFlags Methods showsPrec :: Int -> GhcLink -> ShowS Source # show :: GhcLink -> String Source # showList :: [GhcLink] -> ShowS Source #

defaultObjectTarget :: DynFlags -> HscTarget #

parseDynamicFlags :: MonadIO m => DynFlags -> [Located String] -> m (DynFlags, [Located String], [Warn]) #

getSessionDynFlags :: GhcMonad m => m DynFlags #

Grabs the DynFlags from the Session

setSessionDynFlags :: GhcMonad m => DynFlags -> m [InstalledUnitId] #

Updates both the interactive and program DynFlags in a Session. This also reads the package database (unless it has already been read), and prepares the compilers knowledge about packages. It can be called again to load new packages: just add new package flags to (packageFlags dflags).

Returns a list of new packages that may need to be linked in using the dynamic linker (see `linkPackages`) as a result of new package flags. If you are not doing linking or doing static linking, you can ignore the list of packages returned.

getProgramDynFlags :: GhcMonad m => m DynFlags #

Returns the program `DynFlags`.

setProgramDynFlags :: GhcMonad m => DynFlags -> m [InstalledUnitId] #

Sets the program `DynFlags`. Note: this invalidates the internal cached module graph, causing more work to be done the next time `load` is called.

setLogAction :: GhcMonad m => LogAction -> m () #

Set the action taken when the compiler produces a message. This can also be accomplished using `setProgramDynFlags`, but using `setLogAction` avoids invalidating the cached module graph.

getInteractiveDynFlags :: GhcMonad m => m DynFlags #

Get the `DynFlags` used to evaluate interactive expressions.

setInteractiveDynFlags :: GhcMonad m => DynFlags -> m () #

Set the `DynFlags` used to evaluate interactive expressions. Note: this cannot be used for changes to packages. Use `setSessionDynFlags`, or `setProgramDynFlags` and then copy the `pkgState` into the interactive `DynFlags`.

# Targets

data Target #

A compilation target.

A target may be supplied with the actual text of the module. If so, use this instead of the file contents (this is for use in an IDE where the file hasn't been saved by the user yet).

Constructors

Target |
Fields targetId :: TargetId module or filename targetAllowObjCode :: Bool object code allowed? targetContents :: Maybe (InputFileBuffer, UTCTime) Optional in-memory buffer containing the source code GHC should use for this target instead of reading it from disk. Since GHC version 8.10 modules which require preprocessors such as Literate Haskell or CPP to run are also supported. If a corresponding source file does not exist on disk this will result in a `SourceError` exception if `targetId = TargetModule _` is used. However together with `targetId = TargetFile _` GHC will not complain about the file missing.

#### Instances

Instances details

Outputable Target # |
Instance details Defined in HscTypes Methods ppr :: Target -> SDoc # pprPrec :: Rational -> Target -> SDoc #

data TargetId #

Constructors

TargetModule ModuleName | A module name: search for the file
TargetFile FilePath (Maybe Phase) | A filename: preprocess & parse it to find the module name. If specified, the Phase indicates how to compile this file (which phase to start from). Nothing indicates the starting phase should be determined from the suffix of the filename.

#### Instances

Instances details

Eq TargetId # |
Instance details Defined in HscTypes Methods (==) :: TargetId -> TargetId -> Bool # (/=) :: TargetId -> TargetId -> Bool #
Outputable TargetId # |
Instance details Defined in HscTypes Methods ppr :: TargetId -> SDoc # pprPrec :: Rational -> TargetId -> SDoc #

data Phase #

#### Instances

Instances details

Eq Phase # |
Instance details Defined in DriverPhases Methods (==) :: Phase -> Phase -> Bool # (/=) :: Phase -> Phase -> Bool #
Show Phase # |
Instance details Defined in DriverPhases Methods showsPrec :: Int -> Phase -> ShowS Source # show :: Phase -> String Source # showList :: [Phase] -> ShowS Source #
Outputable Phase # |
Instance details Defined in DriverPhases Methods ppr :: Phase -> SDoc # pprPrec :: Rational -> Phase -> SDoc #

setTargets :: GhcMonad m => [Target] -> m () #

Sets the targets for this session. Each target may be a module name or a filename. The targets correspond to the set of root modules for the program/library. Unloading the current program is achieved by setting the current set of targets to be empty, followed by `load`.

getTargets :: GhcMonad m => m [Target] #

Returns the current set of targets

addTarget :: GhcMonad m => Target -> m () #

Add another target.

removeTarget :: GhcMonad m => TargetId -> m () #

Remove a target

guessTarget :: GhcMonad m => String -> Maybe Phase -> m Target #

Attempts to guess what Target a string refers to. This function implements the `--make`/GHCi command-line syntax for filenames:

- if the string looks like a Haskell source filename, then interpret it as such
- if adding a .hs or .lhs suffix yields the name of an existing file, then use that
- otherwise interpret the string as a module name

# Loading/compiling the program

depanal #

Arguments

:: GhcMonad m |
=> [ModuleName] | excluded modules
-> Bool | allow duplicate roots
-> m ModuleGraph |

Perform a dependency analysis starting from the current targets and update the session with the new module graph.

Dependency analysis entails parsing the `import` directives and may therefore require running certain preprocessors.

Note that each `ModSummary` in the module graph caches its `DynFlags`. These `DynFlags` are determined by the current session `DynFlags` and the `OPTIONS` and `LANGUAGE` pragmas of the parsed module. Thus if you want changes to the `DynFlags` to take effect you need to call this function again.

load :: GhcMonad m => LoadHowMuch -> m SuccessFlag #

Try to load the program. See `LoadHowMuch` for the different modes.

This function implements the core of GHC's `--make` mode. It preprocesses, compiles and loads the specified modules, avoiding re-compilation wherever possible. Depending on the target (see `hscTarget`) compiling and loading may result in files being created on disk.

Calls the `defaultWarnErrLogger` after each compiling each module, whether successful or not.

Throw a `SourceError` if errors are encountered before the actual compilation starts (e.g., during dependency analysis). All other errors are reported using the `defaultWarnErrLogger`.

data LoadHowMuch #

Describes which modules of the module graph need to be loaded.

Constructors

LoadAllTargets | Load all targets and its dependencies.
LoadUpTo ModuleName | Load only the given module and its dependencies.
LoadDependenciesOf ModuleName | Load only the dependencies of the given module, but not the module itself.

data InteractiveImport #

Constructors

IIDecl (ImportDecl GhcPs) | Bring the exports of a particular module (filtered by an import decl) into scope
IIModule ModuleName | Bring into scope the entire top-level envt of of this module, including the things imported into it.

#### Instances

Instances details

Outputable InteractiveImport # |
Instance details Defined in HscTypes Methods ppr :: InteractiveImport -> SDoc # pprPrec :: Rational -> InteractiveImport -> SDoc #

data SuccessFlag #

Constructors

Succeeded |
Failed |

#### Instances

Instances details

Outputable SuccessFlag # |
Instance details Defined in BasicTypes Methods ppr :: SuccessFlag -> SDoc # pprPrec :: Rational -> SuccessFlag -> SDoc #

succeeded :: SuccessFlag -> Bool #

failed :: SuccessFlag -> Bool #

defaultWarnErrLogger :: WarnErrLogger #

type WarnErrLogger = forall m. GhcMonad m => Maybe SourceError -> m () #

A function called to log warnings and errors.

workingDirectoryChanged :: GhcMonad m => m () #

Inform GHC that the working directory has changed. GHC will flush its cache of module locations, since it may no longer be valid.

Note: Before changing the working directory make sure all threads running in the same session have stopped. If you change the working directory, you should also unload the current program (set targets to empty, followed by load).

parseModule :: GhcMonad m => ModSummary -> m ParsedModule #

Parse a module.

Throws a `SourceError` on parse error.

typecheckModule :: GhcMonad m => ParsedModule -> m TypecheckedModule #

Typecheck and rename a parsed module.

Throws a `SourceError` if either fails.

desugarModule :: GhcMonad m => TypecheckedModule -> m DesugaredModule #

Desugar a typechecked module.

loadModule :: (TypecheckedMod mod, GhcMonad m) => mod -> m mod #

Load a module. Input doesn't need to be desugared.

A module must be loaded before dependent modules can be typechecked. This always includes generating a `ModIface` and, depending on the `hscTarget`, may also include code generation.

This function will always cause recompilation and will always overwrite previous compilation results (potentially files on disk).

data ParsedModule #

The result of successful parsing.

Constructors

ParsedModule |
Fields pm_mod_summary :: ModSummary pm_parsed_source :: ParsedSource pm_extra_src_files :: [FilePath] pm_annotations :: ApiAnns

#### Instances

Instances details

ParsedMod ParsedModule # |
Instance details Defined in GHC Methods modSummary :: ParsedModule -> ModSummary parsedSource :: ParsedModule -> ParsedSource #

data TypecheckedModule #

The result of successful typechecking. It also contains the parser result.

Constructors

TypecheckedModule |
Fields tm_parsed_module :: ParsedModule tm_renamed_source :: Maybe RenamedSource tm_typechecked_source :: TypecheckedSource tm_checked_module_info :: ModuleInfo tm_internals_ :: (TcGblEnv, ModDetails)

#### Instances

Instances details

TypecheckedMod TypecheckedModule # |
Instance details Defined in GHC Methods renamedSource :: TypecheckedModule -> Maybe RenamedSource # typecheckedSource :: TypecheckedModule -> TypecheckedSource # moduleInfo :: TypecheckedModule -> ModuleInfo # tm_internals :: TypecheckedModule -> (TcGblEnv, ModDetails)
ParsedMod TypecheckedModule # |
Instance details Defined in GHC Methods modSummary :: TypecheckedModule -> ModSummary parsedSource :: TypecheckedModule -> ParsedSource #

data DesugaredModule #

The result of successful desugaring (i.e., translation to core). Also contains all the information of a typechecked module.

Constructors

DesugaredModule |
Fields dm_typechecked_module :: TypecheckedModule dm_core_module :: ModGuts

#### Instances

Instances details

TypecheckedMod DesugaredModule # |
Instance details Defined in GHC Methods renamedSource :: DesugaredModule -> Maybe RenamedSource # typecheckedSource :: DesugaredModule -> TypecheckedSource # moduleInfo :: DesugaredModule -> ModuleInfo # tm_internals :: DesugaredModule -> (TcGblEnv, ModDetails)
ParsedMod DesugaredModule # |
Instance details Defined in GHC Methods modSummary :: DesugaredModule -> ModSummary parsedSource :: DesugaredModule -> ParsedSource #

type TypecheckedSource = LHsBinds GhcTc #

type ParsedSource = Located (HsModule GhcPs) #

type RenamedSource = (HsGroup GhcRn, [LImportDecl GhcRn], Maybe [(LIE GhcRn, Avails)], Maybe LHsDocString) #

class ParsedMod m => TypecheckedMod m #

Minimal complete definition

renamedSource, typecheckedSource, moduleInfo, tm_internals

#### Instances

Instances details

TypecheckedMod DesugaredModule # |
Instance details Defined in GHC Methods renamedSource :: DesugaredModule -> Maybe RenamedSource # typecheckedSource :: DesugaredModule -> TypecheckedSource # moduleInfo :: DesugaredModule -> ModuleInfo # tm_internals :: DesugaredModule -> (TcGblEnv, ModDetails)
TypecheckedMod TypecheckedModule # |
Instance details Defined in GHC Methods renamedSource :: TypecheckedModule -> Maybe RenamedSource # typecheckedSource :: TypecheckedModule -> TypecheckedSource # moduleInfo :: TypecheckedModule -> ModuleInfo # tm_internals :: TypecheckedModule -> (TcGblEnv, ModDetails)

class ParsedMod m #

Minimal complete definition

modSummary, parsedSource

#### Instances

Instances details

ParsedMod DesugaredModule # |
Instance details Defined in GHC Methods modSummary :: DesugaredModule -> ModSummary parsedSource :: DesugaredModule -> ParsedSource #
ParsedMod TypecheckedModule # |
Instance details Defined in GHC Methods modSummary :: TypecheckedModule -> ModSummary parsedSource :: TypecheckedModule -> ParsedSource #
ParsedMod ParsedModule # |
Instance details Defined in GHC Methods modSummary :: ParsedModule -> ModSummary parsedSource :: ParsedModule -> ParsedSource #

moduleInfo :: TypecheckedMod m => m -> ModuleInfo #

renamedSource :: TypecheckedMod m => m -> Maybe RenamedSource #

typecheckedSource :: TypecheckedMod m => m -> TypecheckedSource #

parsedSource :: ParsedMod m => m -> ParsedSource #

coreModule :: DesugaredMod m => m -> ModGuts #

## Compiling to Core

data CoreModule #

A CoreModule consists of just the fields of a `ModGuts` that are needed for the `compileToCoreModule` interface.

Constructors

CoreModule |
Fields cm_module :: !Module Module name cm_types :: !TypeEnv Type environment for types declared in this module cm_binds :: CoreProgram Declarations cm_safe :: SafeHaskellMode Safe Haskell mode

#### Instances

Instances details

Outputable CoreModule # |
Instance details Defined in GHC Methods ppr :: CoreModule -> SDoc # pprPrec :: Rational -> CoreModule -> SDoc #

compileToCoreModule :: GhcMonad m => FilePath -> m CoreModule #

This is the way to get access to the Core bindings corresponding to a module. `compileToCore` parses, typechecks, and desugars the module, then returns the resulting Core module (consisting of the module name, type declarations, and function declarations) if successful.

compileToCoreSimplified :: GhcMonad m => FilePath -> m CoreModule #

Like compileToCoreModule, but invokes the simplifier, so as to return simplified and tidied Core.

# Inspecting the module structure of the program

data ModuleGraph #

A ModuleGraph contains all the nodes from the home package (only). There will be a node for each source module, plus a node for each hi-boot module.

The graph is not necessarily stored in topologically-sorted order. Use `topSortModuleGraph` and `flattenSCC` to achieve this.

emptyMG :: ModuleGraph #

mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph #

Map a function `f` over all the `ModSummaries`. To preserve invariants `f` can't change the isBoot status.

mkModuleGraph :: [ModSummary] -> ModuleGraph #

mgModSummaries :: ModuleGraph -> [ModSummary] #

mgLookupModule :: ModuleGraph -> Module -> Maybe ModSummary #

Look up a ModSummary in the ModuleGraph

data ModSummary #

A single node in a `ModuleGraph`. The nodes of the module graph are one of:

- A regular Haskell source module
- A hi-boot source module

Constructors

ModSummary |
Fields ms_mod :: Module Identity of the module ms_hsc_src :: HscSource The module source either plain Haskell or hs-boot ms_location :: ModLocation Location of the various files belonging to the module ms_hs_date :: UTCTime Timestamp of source file ms_obj_date :: Maybe UTCTime Timestamp of object, if we have one ms_iface_date :: Maybe UTCTime Timestamp of hi file, if we *only* are typechecking (it is `Nothing` otherwise. See Note [Recompilation checking in -fno-code mode] and #9243 ms_hie_date :: Maybe UTCTime Timestamp of hie file, if we have one ms_srcimps :: [(Maybe FastString, Located ModuleName)] Source imports of the module ms_textual_imps :: [(Maybe FastString, Located ModuleName)] Non-source imports of the module from the module *text* ms_parsed_mod :: Maybe HsParsedModule The parsed, nonrenamed source, if we have it. This is also used to support "inline module syntax" in Backpack files. ms_hspp_file :: FilePath Filename of preprocessed source file ms_hspp_opts :: DynFlags Cached flags from `OPTIONS`, `INCLUDE` and `LANGUAGE` pragmas in the modules source code ms_hspp_buf :: Maybe StringBuffer The actual preprocessed source, if we have it

#### Instances

Instances details

Outputable ModSummary # |
Instance details Defined in HscTypes Methods ppr :: ModSummary -> SDoc # pprPrec :: Rational -> ModSummary -> SDoc #

ms_mod_name :: ModSummary -> ModuleName #

data ModLocation #

Module Location

Where a module lives on the file system: the actual locations of the .hs, .hi and .o files, if we have them

Constructors

ModLocation |
Fields ml_hs_file :: Maybe FilePath ml_hi_file :: FilePath ml_obj_file :: FilePath ml_hie_file :: FilePath

#### Instances

Instances details

Show ModLocation # |
Instance details Defined in Module Methods showsPrec :: Int -> ModLocation -> ShowS Source # show :: ModLocation -> String Source # showList :: [ModLocation] -> ShowS Source #
Outputable ModLocation # |
Instance details Defined in Module Methods ppr :: ModLocation -> SDoc # pprPrec :: Rational -> ModLocation -> SDoc #

getModSummary :: GhcMonad m => ModuleName -> m ModSummary #

Return the `ModSummary` of a module with the given name.

The module must be part of the module graph (see `hsc_mod_graph` and `ModuleGraph`). If this is not the case, this function will throw a `GhcApiError`.

This function ignores boot modules and requires that there is only one non-boot module with the given name.

getModuleGraph :: GhcMonad m => m ModuleGraph #

Get the module dependency graph.

isLoaded :: GhcMonad m => ModuleName -> m Bool #

Return `True` == module is loaded.

topSortModuleGraph #

Arguments

:: Bool | Drop hi-boot nodes? (see below)
-> ModuleGraph |
-> Maybe ModuleName | Root module name. If `Nothing`, use the full graph.
-> [SCC ModSummary] |

Topological sort of the module graph

Calculate SCCs of the module graph, possibly dropping the hi-boot nodes The resulting list of strongly-connected-components is in topologically sorted order, starting with the module(s) at the bottom of the dependency graph (ie compile them first) and ending with the ones at the top.

Drop hi-boot nodes (first boolean arg)?

- `False`: treat the hi-boot summaries as nodes of the graph, so the graph must be acyclic
- `True`: eliminate the hi-boot nodes, and instead pretend the a source-import of Foo is an import of Foo The resulting graph has no hi-boot nodes, but can be cyclic

# Inspecting modules

data ModuleInfo #

Container for information about a `Module`.

getModuleInfo :: GhcMonad m => Module -> m (Maybe ModuleInfo) #

Request information about a loaded `Module`

modInfoTyThings :: ModuleInfo -> [TyThing] #

The list of top-level entities defined in a module

modInfoTopLevelScope :: ModuleInfo -> Maybe [Name] #

modInfoExports :: ModuleInfo -> [Name] #

modInfoExportsWithSelectors :: ModuleInfo -> [Name] #

modInfoInstances :: ModuleInfo -> [ClsInst] #

Returns the instances defined by the specified module. Warning: currently unimplemented for package modules.

modInfoIsExportedName :: ModuleInfo -> Name -> Bool #

modInfoLookupName :: GhcMonad m => ModuleInfo -> Name -> m (Maybe TyThing) #

modInfoIface :: ModuleInfo -> Maybe ModIface #

modInfoRdrEnv :: ModuleInfo -> Maybe GlobalRdrEnv #

modInfoSafe :: ModuleInfo -> SafeHaskellMode #

Retrieve module safe haskell mode

lookupGlobalName :: GhcMonad m => Name -> m (Maybe TyThing) #

Looks up a global name: that is, any top-level name in any visible module. Unlike `lookupName`, lookupGlobalName does not use the interactive context, and therefore does not require a preceding `setContext`.

findGlobalAnns :: (GhcMonad m, Typeable a) => ([Word8] -> a) -> AnnTarget Name -> m [a] #

mkPrintUnqualifiedForModule :: GhcMonad m => ModuleInfo -> m (Maybe PrintUnqualified) #

type ModIface = ModIface_ 'ModIfaceFinal #

data ModIface_ (phase :: ModIfacePhase) #

A `ModIface` plus a `ModDetails` summarises everything we know about a compiled module. The `ModIface` is the stuff *before* linking, and can be written out to an interface file. The 'ModDetails is after linking and can be completely recovered from just the `ModIface`.

When we read an interface file, we also construct a `ModIface` from it, except that we explicitly make the `mi_decls` and a few other fields empty; as when reading we consolidate the declarations etc. into a number of indexed maps and environments in the `ExternalPackageState`.

Constructors

ModIface |
Fields mi_module :: !Module Name of the module we are for mi_sig_of :: !(Maybe Module) Are we a sig of another mod? mi_hsc_src :: !HscSource Boot? Signature? mi_deps :: Dependencies The dependencies of the module. This is consulted for directly-imported modules, but not for anything else (hence lazy) mi_usages :: [Usage] Usages; kept sorted so that it's easy to decide whether to write a new iface file (changing usages doesn't affect the hash of this module) NOT STRICT! we read this field lazily from the interface file It is *only* consulted by the recompilation checker mi_exports :: ![IfaceExport] Exports Kept sorted by (mod,occ), to make version comparisons easier Records the modules that are the declaration points for things exported by this module, and the `OccName`s of those things mi_used_th :: !Bool Module required TH splices when it was compiled. This disables recompilation avoidance (see #481). mi_fixities :: [(OccName, Fixity)] Fixities NOT STRICT! we read this field lazily from the interface file mi_warns :: Warnings Warnings NOT STRICT! we read this field lazily from the interface file mi_anns :: [IfaceAnnotation] Annotations NOT STRICT! we read this field lazily from the interface file mi_decls :: [IfaceDeclExts phase] Type, class and variable declarations The hash of an Id changes if its fixity or deprecations change (as well as its type of course) Ditto data constructors, class operations, except that the hash of the parent class/tycon changes mi_globals :: !(Maybe GlobalRdrEnv) Binds all the things defined at the top level in the original source code for this module. which is NOT the same as mi_exports, nor mi_decls (which may contains declarations for things not actually defined by the user). Used for GHCi and for inspecting the contents of modules via the GHC API only. (We need the source file to figure out the top-level environment, if we didn't compile this module from source then this field contains `Nothing`). Strictly speaking this field should live in the `HomeModInfo`, but that leads to more plumbing. mi_insts :: [IfaceClsInst] Sorted class instance mi_fam_insts :: [IfaceFamInst] Sorted family instances mi_rules :: [IfaceRule] Sorted rules mi_hpc :: !AnyHpcUsage True if this program uses Hpc at any point in the program. mi_trust :: !IfaceTrustInfo Safe Haskell Trust information for this module. mi_trust_pkg :: !Bool Do we require the package this module resides in be trusted to trust this module? This is used for the situation where a module is Safe (so doesn't require the package be trusted itself) but imports some trustworthy modules from its own package (which does require its own package be trusted). See Note [RnNames . Trust Own Package] mi_complete_sigs :: [IfaceCompleteMatch] mi_doc_hdr :: Maybe HsDocString Module header. mi_decl_docs :: DeclDocMap Docs on declarations. mi_arg_docs :: ArgDocMap Docs on arguments. mi_final_exts :: !(IfaceBackendExts phase) Either `()` or `ModIfaceBackend` for a fully instantiated interface.

#### Instances

Instances details

Binary ModIface # |
Instance details Defined in HscTypes Methods put_ :: BinHandle -> ModIface -> IO () # put :: BinHandle -> ModIface -> IO (Bin ModIface) # get :: BinHandle -> IO ModIface #
(NFData (IfaceBackendExts phase), NFData (IfaceDeclExts phase)) => NFData (ModIface_ phase) # |
Instance details Defined in HscTypes Methods rnf :: ModIface_ phase -> () Source #

data SafeHaskellMode #

The various Safe Haskell modes

Constructors

Sf_None | inferred unsafe
Sf_Unsafe | declared and checked
Sf_Trustworthy | declared and checked
Sf_Safe | declared and checked
Sf_SafeInferred | inferred as safe
Sf_Ignore | `-fno-safe-haskell` state

#### Instances

Instances details

Eq SafeHaskellMode # |
Instance details Defined in DynFlags Methods (==) :: SafeHaskellMode -> SafeHaskellMode -> Bool # (/=) :: SafeHaskellMode -> SafeHaskellMode -> Bool #
Show SafeHaskellMode # |
Instance details Defined in DynFlags Methods showsPrec :: Int -> SafeHaskellMode -> ShowS Source # show :: SafeHaskellMode -> String Source # showList :: [SafeHaskellMode] -> ShowS Source #
Outputable SafeHaskellMode # |
Instance details Defined in DynFlags Methods ppr :: SafeHaskellMode -> SDoc # pprPrec :: Rational -> SafeHaskellMode -> SDoc #

# Querying the environment

# Printing

data PrintUnqualified #

When printing code that contains original names, we need to map the original names back to something the user understands. This is the purpose of the triple of functions that gets passed around when rendering `SDoc`.

alwaysQualify :: PrintUnqualified #

# Interactive evaluation

## Executing statements

execStmt #

Arguments

:: GhcMonad m |
=> String | a statement (bind or expression)
-> ExecOptions |
-> m ExecResult |

Run a statement in the current interactive context.

execStmt' :: GhcMonad m => GhciLStmt GhcPs -> String -> ExecOptions -> m ExecResult #

Like `execStmt`, but takes a parsed statement as argument. Useful when doing preprocessing on the AST before execution, e.g. in GHCi (see GHCi.UI.runStmt).

data ExecOptions #

Constructors

ExecOptions |
Fields execSingleStep :: SingleStep stepping mode execSourceFile :: String filename (for errors) execLineNumber :: Int line number (for errors) execWrap :: ForeignHValue -> EvalExpr ForeignHValue

execOptions :: ExecOptions #

default ExecOptions

data ExecResult #

Constructors

ExecComplete |
Fields execResult :: Either SomeException [Name] execAllocation :: Word64
ExecBreak |
Fields breakNames :: [Name] breakInfo :: Maybe BreakInfo

resumeExec :: GhcMonad m => (SrcSpan -> Bool) -> SingleStep -> m ExecResult #

## Adding new declarations

runDecls :: GhcMonad m => String -> m [Name] #

runDeclsWithLocation :: GhcMonad m => String -> Int -> String -> m [Name] #

Run some declarations and return any user-visible names that were brought into scope.

runParsedDecls :: GhcMonad m => [LHsDecl GhcPs] -> m [Name] #

Like `runDeclsWithLocation`, but takes parsed declarations as argument. Useful when doing preprocessing on the AST before execution, e.g. in GHCi (see GHCi.UI.runStmt).

## Get/set the current context

parseImportDecl :: GhcMonad m => String -> m (ImportDecl GhcPs) #

setContext :: GhcMonad m => [InteractiveImport] -> m () #

Set the interactive evaluation context.

(setContext imports) sets the ic_imports field (which in turn determines what is in scope at the prompt) to `imports`, and constructs the ic_rn_glb_env environment to reflect it.

We retain in scope all the things defined at the prompt, and kept in ic_tythings. (Indeed, they shadow stuff from ic_imports.)

getContext :: GhcMonad m => m [InteractiveImport] #

Get the interactive evaluation context, consisting of a pair of the set of modules from which we take the full top-level scope, and the set of modules from which we take just the exports respectively.

setGHCiMonad :: GhcMonad m => String -> m () #

Set the monad GHCi lifts user statements into.

Checks that a type (in string form) is an instance of the `GHC.GHCi.GHCiSandboxIO` type class. Sets it to be the GHCi monad if it is, throws an error otherwise.

getGHCiMonad :: GhcMonad m => m Name #

Get the monad GHCi lifts user statements into.

## Inspecting the current context

getBindings :: GhcMonad m => m [TyThing] #

Return the bindings for the current interactive session.

getInsts :: GhcMonad m => m ([ClsInst], [FamInst]) #

Return the instances for the current interactive session.

getPrintUnqual :: GhcMonad m => m PrintUnqualified #

findModule :: GhcMonad m => ModuleName -> Maybe FastString -> m Module #

Takes a `ModuleName` and possibly a `UnitId`, and consults the filesystem and package database to find the corresponding `Module`, using the algorithm that is used for an `import` declaration.

lookupModule :: GhcMonad m => ModuleName -> Maybe FastString -> m Module #

Like `findModule`, but differs slightly when the module refers to a source file, and the file has not been loaded via `load`. In this case, `findModule` will throw an error (module not loaded), but `lookupModule` will check to see whether the module can also be found in a package, and if so, that package `Module` will be returned. If not, the usual module-not-found error will be thrown.

isModuleTrusted :: GhcMonad m => Module -> m Bool #

Check that a module is safe to import (according to Safe Haskell).

We return True to indicate the import is safe and False otherwise although in the False case an error may be thrown first.

moduleTrustReqs :: GhcMonad m => Module -> m (Bool, Set InstalledUnitId) #

Return if a module is trusted and the pkgs it depends on to be trusted.

getNamesInScope :: GhcMonad m => m [Name] #

Returns all names in scope in the current interactive context

getRdrNamesInScope :: GhcMonad m => m [RdrName] #

Returns all `RdrName`s in scope in the current interactive context, excluding any that are internally-generated.

getGRE :: GhcMonad m => m GlobalRdrEnv #

get the GlobalRdrEnv for a session

moduleIsInterpreted :: GhcMonad m => Module -> m Bool #

Returns `True` if the specified module is interpreted, and hence has its full top-level scope available.

getInfo :: GhcMonad m => Bool -> Name -> m (Maybe (TyThing, Fixity, [ClsInst], [FamInst], SDoc)) #

Looks up an identifier in the current interactive context (for :info) Filter the instances by the ones whose tycons (or clases resp) are in scope (qualified or otherwise). Otherwise we list a whole lot too many! The exact choice of which ones to show, and which to hide, is a judgement call. (see #1581)

showModule :: GhcMonad m => ModSummary -> m String #

moduleIsBootOrNotObjectLinkable :: GhcMonad m => ModSummary -> m Bool #

getNameToInstancesIndex #

Arguments

:: GhcMonad m |
=> [Module] | visible modules. An orphan instance will be returned if it is visible from at least one module in the list.
-> Maybe [Module] | modules to load. If this is not specified, we load modules for everything that is in scope unqualified.
-> m (Messages, Maybe (NameEnv ([ClsInst], [FamInst]))) |

Retrieve all type and family instances in the environment, indexed by `Name`. Each name's lists will contain every instance in which that name is mentioned in the instance head.

## Inspecting types and kinds

exprType :: GhcMonad m => TcRnExprMode -> String -> m Type #

Get the type of an expression Returns the type as described by `TcRnExprMode`

data TcRnExprMode #

How should we infer a type? See Note [TcRnExprMode]

Constructors

TM_Inst | Instantiate the type fully (:type)
TM_NoInst | Do not instantiate the type (:type +v)
TM_Default | Default the type eagerly (:type +d)

typeKind :: GhcMonad m => Bool -> String -> m (Type, Kind) #

Get the kind of a type

## Looking up a Name

parseName :: GhcMonad m => String -> m [Name] #

Parses a string as an identifier, and returns the list of `Name`s that the identifier can refer to in the current interactive context.

lookupName :: GhcMonad m => Name -> m (Maybe TyThing) #

Returns the `TyThing` for a `Name`. The `Name` may refer to any entity known to GHC, including `Name`s defined using `runStmt`.

## Compiling expressions

data HValue Source #

#### Instances

Instances details

Show HValue |
Instance details Defined in GHCi.RemoteTypes Methods showsPrec :: Int -> HValue -> ShowS Source # show :: HValue -> String Source # showList :: [HValue] -> ShowS Source #

parseExpr :: GhcMonad m => String -> m (LHsExpr GhcPs) #

Parse an expression, the parsed expression can be further processed and passed to compileParsedExpr.

compileParsedExpr :: GhcMonad m => LHsExpr GhcPs -> m HValue #

compileExpr :: GhcMonad m => String -> m HValue #

Compile an expression, run it, and deliver the resulting HValue.

dynCompileExpr :: GhcMonad m => String -> m Dynamic #

Compile an expression, run it and return the result as a Dynamic.

type ForeignHValue = ForeignRef HValue Source #

compileExprRemote :: GhcMonad m => String -> m ForeignHValue #

Compile an expression, run it, and deliver the resulting HValue.

compileParsedExprRemote :: GhcMonad m => LHsExpr GhcPs -> m ForeignHValue #

Compile a parsed expression (before renaming), run it, and deliver the resulting HValue.

## Docs

getDocs :: GhcMonad m => Name -> m (Either GetDocsFailure (Maybe HsDocString, Map Int HsDocString)) #

data GetDocsFailure #

Failure modes for `getDocs`.

Constructors

NameHasNoModule Name | `nameModule_maybe` returned `Nothing`.
NoDocsInIface Module Bool | `True`: The module was compiled. `False`: The module was :loaded.
InteractiveName | The `Name` was defined interactively.

#### Instances

Instances details

Outputable GetDocsFailure # |
Instance details Defined in InteractiveEval Methods ppr :: GetDocsFailure -> SDoc # pprPrec :: Rational -> GetDocsFailure -> SDoc #

## Other

runTcInteractive :: HscEnv -> TcRn a -> IO (Messages, Maybe a) #

isStmt :: DynFlags -> String -> Bool #

Returns `True` if passed string is a statement.

hasImport :: DynFlags -> String -> Bool #

Returns `True` if passed string has an import declaration.

isImport :: DynFlags -> String -> Bool #

Returns `True` if passed string is an import declaration.

isDecl :: DynFlags -> String -> Bool #

Returns `True` if passed string is a declaration but not a splice.

## The debugger

data SingleStep #

Constructors

RunToCompletion |
SingleStep |
RunAndLogSteps |

data Resume #

Constructors

Resume |
Fields resumeStmt :: String resumeContext :: ForeignRef (ResumeContext [HValueRef]) resumeBindings :: ([TyThing], GlobalRdrEnv) resumeFinalIds :: [Id] resumeApStack :: ForeignHValue resumeBreakInfo :: Maybe BreakInfo resumeSpan :: SrcSpan resumeDecl :: String resumeCCS :: RemotePtr CostCentreStack resumeHistory :: [History] resumeHistoryIx :: Int

data History #

getHistorySpan :: GhcMonad m => History -> m SrcSpan #

getHistoryModule :: History -> Module #

abandon :: GhcMonad m => m Bool #

abandonAll :: GhcMonad m => m Bool #

getResumeContext :: GhcMonad m => m [Resume] #

obtainTermFromId :: GhcMonad m => Int -> Bool -> Id -> m Term #

obtainTermFromVal :: GhcMonad m => Int -> Bool -> Type -> a -> m Term #

reconstructType :: HscEnv -> Int -> Id -> IO (Maybe Type) #

modInfoModBreaks :: ModuleInfo -> ModBreaks #

data ModBreaks #

All the information about the breakpoints for a module

Constructors

ModBreaks |
Fields modBreaks_flags :: ForeignRef BreakArray The array of flags, one per breakpoint, indicating which breakpoints are enabled. modBreaks_locs :: !(Array BreakIndex SrcSpan) An array giving the source span of each breakpoint. modBreaks_vars :: !(Array BreakIndex [OccName]) An array giving the names of the free variables at each breakpoint. modBreaks_decls :: !(Array BreakIndex [String]) An array giving the names of the declarations enclosing each breakpoint. modBreaks_ccs :: !(Array BreakIndex (RemotePtr CostCentre)) Array pointing to cost centre for each breakpoint modBreaks_breakInfo :: IntMap CgBreakInfo info about each breakpoint from the bytecode generator

type BreakIndex = Int #

Breakpoint index

data BreakInfo #

back :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String) #

forward :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String) #

# Abstract syntax elements

## Packages

data UnitId #

A unit identifier identifies a (possibly partially) instantiated library. It is primarily used as part of `Module`, which in turn is used in `Name`, which is used to give names to entities when typechecking.

There are two possible forms for a `UnitId`. It can be a `DefiniteUnitId`, in which case we just have a string that uniquely identifies some fully compiled, installed library we have on disk. However, when we are typechecking a library with missing holes, we may need to instantiate a library on the fly (in which case we don't have any on-disk representation.) In that case, you have an `IndefiniteUnitId`, which explicitly records the instantiation, so that we can substitute over it.

#### Instances

Instances details

Eq UnitId # |
Instance details Defined in Module Methods (==) :: UnitId -> UnitId -> Bool # (/=) :: UnitId -> UnitId -> Bool #
Data UnitId # |
Instance details Defined in Module Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UnitId -> c UnitId Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UnitId Source # toConstr :: UnitId -> Constr Source # dataTypeOf :: UnitId -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UnitId) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnitId) Source # gmapT :: (forall b. Data b => b -> b) -> UnitId -> UnitId Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UnitId -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UnitId -> r Source # gmapQ :: (forall d. Data d => d -> u) -> UnitId -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> UnitId -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UnitId -> m UnitId Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UnitId -> m UnitId Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UnitId -> m UnitId Source #
Ord UnitId # |
Instance details Defined in Module Methods compare :: UnitId -> UnitId -> Ordering # (<) :: UnitId -> UnitId -> Bool # (<=) :: UnitId -> UnitId -> Bool # (>) :: UnitId -> UnitId -> Bool # (>=) :: UnitId -> UnitId -> Bool # max :: UnitId -> UnitId -> UnitId # min :: UnitId -> UnitId -> UnitId #
Show UnitId # |
Instance details Defined in Module Methods showsPrec :: Int -> UnitId -> ShowS Source # show :: UnitId -> String Source # showList :: [UnitId] -> ShowS Source #
NFData UnitId # |
Instance details Defined in Module Methods rnf :: UnitId -> () Source #
Outputable UnitId # |
Instance details Defined in Module Methods ppr :: UnitId -> SDoc # pprPrec :: Rational -> UnitId -> SDoc #
Uniquable UnitId # |
Instance details Defined in Module Methods getUnique :: UnitId -> Unique #
Binary UnitId # |
Instance details Defined in Module Methods put_ :: BinHandle -> UnitId -> IO () # put :: BinHandle -> UnitId -> IO (Bin UnitId) # get :: BinHandle -> IO UnitId #
DbUnitIdModuleRep InstalledUnitId ComponentId UnitId ModuleName Module # |
Instance details Defined in Module Methods fromDbModule :: DbModule InstalledUnitId ComponentId UnitId ModuleName Module -> Module Source # toDbModule :: Module -> DbModule InstalledUnitId ComponentId UnitId ModuleName Module Source # fromDbUnitId :: DbUnitId InstalledUnitId ComponentId UnitId ModuleName Module -> UnitId Source # toDbUnitId :: UnitId -> DbUnitId InstalledUnitId ComponentId UnitId ModuleName Module Source #

## Modules

data Module #

A Module is a pair of a `UnitId` and a `ModuleName`.

Module variables (i.e. `H`) which can be instantiated to a specific module at some later point in time are represented with `moduleUnitId` set to `holeUnitId` (this allows us to avoid having to make `moduleUnitId` a partial operation.)

#### Instances

Instances details

Eq Module # |
Instance details Defined in Module Methods (==) :: Module -> Module -> Bool # (/=) :: Module -> Module -> Bool #
Data Module # |
Instance details Defined in Module Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Module -> c Module Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Module Source # toConstr :: Module -> Constr Source # dataTypeOf :: Module -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Module) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module) Source # gmapT :: (forall b. Data b => b -> b) -> Module -> Module Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Module -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Module -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Module -> m Module Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Module -> m Module Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Module -> m Module Source #
Ord Module # |
Instance details Defined in Module Methods compare :: Module -> Module -> Ordering # (<) :: Module -> Module -> Bool # (<=) :: Module -> Module -> Bool # (>) :: Module -> Module -> Bool # (>=) :: Module -> Module -> Bool # max :: Module -> Module -> Module # min :: Module -> Module -> Module #
NFData Module # |
Instance details Defined in Module Methods rnf :: Module -> () Source #
Outputable Module # |
Instance details Defined in Module Methods ppr :: Module -> SDoc # pprPrec :: Rational -> Module -> SDoc #
Uniquable Module # |
Instance details Defined in Module Methods getUnique :: Module -> Unique #
Binary Module # |
Instance details Defined in Module Methods put_ :: BinHandle -> Module -> IO () # put :: BinHandle -> Module -> IO (Bin Module) # get :: BinHandle -> IO Module #
DbUnitIdModuleRep InstalledUnitId ComponentId UnitId ModuleName Module # |
Instance details Defined in Module Methods fromDbModule :: DbModule InstalledUnitId ComponentId UnitId ModuleName Module -> Module Source # toDbModule :: Module -> DbModule InstalledUnitId ComponentId UnitId ModuleName Module Source # fromDbUnitId :: DbUnitId InstalledUnitId ComponentId UnitId ModuleName Module -> UnitId Source # toDbUnitId :: UnitId -> DbUnitId InstalledUnitId ComponentId UnitId ModuleName Module Source #

mkModule :: UnitId -> ModuleName -> Module #

pprModule :: Module -> SDoc #

moduleName :: Module -> ModuleName #

moduleUnitId :: Module -> UnitId #

data ModuleName #

A ModuleName is essentially a simple string, e.g. `Data.List`.

#### Instances

Instances details

Eq ModuleName # |
Instance details Defined in Module Methods (==) :: ModuleName -> ModuleName -> Bool # (/=) :: ModuleName -> ModuleName -> Bool #
Data ModuleName # |
Instance details Defined in Module Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ModuleName -> c ModuleName Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ModuleName Source # toConstr :: ModuleName -> Constr Source # dataTypeOf :: ModuleName -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ModuleName) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModuleName) Source # gmapT :: (forall b. Data b => b -> b) -> ModuleName -> ModuleName Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ModuleName -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ModuleName -> r Source # gmapQ :: (forall d. Data d => d -> u) -> ModuleName -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> ModuleName -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ModuleName -> m ModuleName Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ModuleName -> m ModuleName Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ModuleName -> m ModuleName Source #
Ord ModuleName # |
Instance details Defined in Module Methods compare :: ModuleName -> ModuleName -> Ordering # (<) :: ModuleName -> ModuleName -> Bool # (<=) :: ModuleName -> ModuleName -> Bool # (>) :: ModuleName -> ModuleName -> Bool # (>=) :: ModuleName -> ModuleName -> Bool # max :: ModuleName -> ModuleName -> ModuleName # min :: ModuleName -> ModuleName -> ModuleName #
NFData ModuleName # |
Instance details Defined in Module Methods rnf :: ModuleName -> () Source #
BinaryStringRep ModuleName # |
Instance details Defined in Module Methods fromStringRep :: ByteString -> ModuleName Source # toStringRep :: ModuleName -> ByteString Source #
Outputable ModuleName # |
Instance details Defined in Module Methods ppr :: ModuleName -> SDoc # pprPrec :: Rational -> ModuleName -> SDoc #
Uniquable ModuleName # |
Instance details Defined in Module Methods getUnique :: ModuleName -> Unique #
Binary ModuleName # |
Instance details Defined in Module Methods put_ :: BinHandle -> ModuleName -> IO () # put :: BinHandle -> ModuleName -> IO (Bin ModuleName) # get :: BinHandle -> IO ModuleName #
DbUnitIdModuleRep InstalledUnitId ComponentId UnitId ModuleName Module # |
Instance details Defined in Module Methods fromDbModule :: DbModule InstalledUnitId ComponentId UnitId ModuleName Module -> Module Source # toDbModule :: Module -> DbModule InstalledUnitId ComponentId UnitId ModuleName Module Source # fromDbUnitId :: DbUnitId InstalledUnitId ComponentId UnitId ModuleName Module -> UnitId Source # toDbUnitId :: UnitId -> DbUnitId InstalledUnitId ComponentId UnitId ModuleName Module Source #

mkModuleName :: String -> ModuleName #

moduleNameString :: ModuleName -> String #

## Names

data Name #

A unique, unambiguous name for something, containing information about where that thing originated.

#### Instances

Instances details

Eq Name # | The same comments as for `Name`'s `Ord` instance apply.
Instance details Defined in Name Methods (==) :: Name -> Name -> Bool # (/=) :: Name -> Name -> Bool #
Data Name # |
Instance details Defined in Name Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Name -> c Name Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Name Source # toConstr :: Name -> Constr Source # dataTypeOf :: Name -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Name) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name) Source # gmapT :: (forall b. Data b => b -> b) -> Name -> Name Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Name -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Name -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Name -> m Name Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name Source #
Ord Name # | Caution: This instance is implemented via `nonDetCmpUnique`, which means that the ordering is not stable across deserialization or rebuilds. See `nonDetCmpUnique` for further information, and trac #15240 for a bug caused by improper use of this instance.
Instance details Defined in Name Methods compare :: Name -> Name -> Ordering # (<) :: Name -> Name -> Bool # (<=) :: Name -> Name -> Bool # (>) :: Name -> Name -> Bool # (>=) :: Name -> Name -> Bool # max :: Name -> Name -> Name # min :: Name -> Name -> Name #
NFData Name # |
Instance details Defined in Name Methods rnf :: Name -> () Source #
OutputableBndr Name # |
Instance details Defined in Name Methods pprBndr :: BindingSite -> Name -> SDoc # pprPrefixOcc :: Name -> SDoc # pprInfixOcc :: Name -> SDoc # bndrIsJoin_maybe :: Name -> Maybe Int #
Outputable Name # |
Instance details Defined in Name Methods ppr :: Name -> SDoc # pprPrec :: Rational -> Name -> SDoc #
HasSrcSpan Name # |
Instance details Defined in Name Methods composeSrcSpan :: Located (SrcSpanLess Name) -> Name # decomposeSrcSpan :: Name -> Located (SrcSpanLess Name) #
Uniquable Name # |
Instance details Defined in Name Methods getUnique :: Name -> Unique #
Binary Name # | Assumes that the `Name` is a non-binding one. See `putIfaceTopBndr` and `getIfaceTopBndr` for serializing binding `Name`s. See `UserData` for the rationale for this distinction.
Instance details Defined in Name Methods put_ :: BinHandle -> Name -> IO () # put :: BinHandle -> Name -> IO (Bin Name) # get :: BinHandle -> IO Name #
HasOccName Name # |
Instance details Defined in Name Methods occName :: Name -> OccName #
NamedThing Name # |
Instance details Defined in Name Methods getOccName :: Name -> OccName # getName :: Name -> Name #
type SrcSpanLess Name # |
Instance details Defined in Name type SrcSpanLess Name = Name

isExternalName :: Name -> Bool #

nameModule :: HasDebugCallStack => Name -> Module #

pprParenSymName :: NamedThing a => a -> SDoc #

print a `NamedThing`, adding parentheses if the name is an operator.

nameSrcSpan :: Name -> SrcSpan #

class NamedThing a where #

A class allowing convenient access to the `Name` of various datatypes

Minimal complete definition

getName

Methods

getOccName :: a -> OccName #

getName :: a -> Name #

#### Instances

Instances details

NamedThing Name # |
Instance details Defined in Name Methods getOccName :: Name -> OccName # getName :: Name -> Name #
NamedThing TyCon # |
Instance details Defined in TyCon Methods getOccName :: TyCon -> OccName # getName :: TyCon -> Name #
NamedThing Var # |
Instance details Defined in Var Methods getOccName :: Var -> OccName # getName :: Var -> Name #
NamedThing TyThing # |
Instance details Defined in TyCoRep Methods getOccName :: TyThing -> OccName # getName :: TyThing -> Name #
NamedThing PatSyn # |
Instance details Defined in PatSyn Methods getOccName :: PatSyn -> OccName # getName :: PatSyn -> Name #
NamedThing DataCon # |
Instance details Defined in DataCon Methods getOccName :: DataCon -> OccName # getName :: DataCon -> Name #
NamedThing ConLike # |
Instance details Defined in ConLike Methods getOccName :: ConLike -> OccName # getName :: ConLike -> Name #
NamedThing Class # |
Instance details Defined in Class Methods getOccName :: Class -> OccName # getName :: Class -> Name #
NamedThing IfaceConDecl # |
Instance details Defined in IfaceSyn Methods getOccName :: IfaceConDecl -> OccName # getName :: IfaceConDecl -> Name #
NamedThing IfaceClassOp # |
Instance details Defined in IfaceSyn Methods getOccName :: IfaceClassOp -> OccName # getName :: IfaceClassOp -> Name #
NamedThing IfaceDecl # |
Instance details Defined in IfaceSyn Methods getOccName :: IfaceDecl -> OccName # getName :: IfaceDecl -> Name #
NamedThing FamInst # |
Instance details Defined in FamInstEnv Methods getOccName :: FamInst -> OccName # getName :: FamInst -> Name #
NamedThing ClsInst # |
Instance details Defined in InstEnv Methods getOccName :: ClsInst -> OccName # getName :: ClsInst -> Name #
NamedThing HoleFitCandidate # |
Instance details Defined in TcHoleFitTypes Methods getOccName :: HoleFitCandidate -> OccName # getName :: HoleFitCandidate -> Name #
NamedThing e => NamedThing (Located e) # |
Instance details Defined in Name Methods getOccName :: Located e -> OccName # getName :: Located e -> Name #
NamedThing (CoAxiom br) # |
Instance details Defined in CoAxiom Methods getOccName :: CoAxiom br -> OccName # getName :: CoAxiom br -> Name #
NamedThing (HsTyVarBndr GhcRn) # |
Instance details Defined in GHC.Hs.Types Methods getOccName :: HsTyVarBndr GhcRn -> OccName # getName :: HsTyVarBndr GhcRn -> Name #
NamedThing tv => NamedThing (VarBndr tv flag) # |
Instance details Defined in Var Methods getOccName :: VarBndr tv flag -> OccName # getName :: VarBndr tv flag -> Name #

data RdrName #

Reader Name

Do not use the data constructors of RdrName directly: prefer the family of functions that creates them, such as `mkRdrUnqual`

- Note: A Located RdrName will only have API Annotations if it is a compound one, e.g.

    `bar`
    ( ~ )

- `AnnKeywordId` : `AnnType`, `AnnOpen` `'('` or `'['` or `'[:'`, `AnnClose` `')'` or `']'` or `':]'`,, `AnnBackquote` `'`'`, `AnnVal` `AnnTilde`,

Constructors

Unqual OccName | Unqualified name Used for ordinary, unqualified occurrences, e.g. `x`, `y` or `Foo`. Create such a `RdrName` with `mkRdrUnqual`
Qual ModuleName OccName | Qualified name A qualified name written by the user in source code. The module isn't necessarily the module where the thing is defined; just the one from which it is imported. Examples are `Bar.x`, `Bar.y` or `Bar.Foo`. Create such a `RdrName` with `mkRdrQual`

#### Instances

Instances details

Eq RdrName # |
Instance details Defined in RdrName Methods (==) :: RdrName -> RdrName -> Bool # (/=) :: RdrName -> RdrName -> Bool #
Data RdrName # |
Instance details Defined in RdrName Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RdrName -> c RdrName Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RdrName Source # toConstr :: RdrName -> Constr Source # dataTypeOf :: RdrName -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RdrName) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RdrName) Source # gmapT :: (forall b. Data b => b -> b) -> RdrName -> RdrName Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RdrName -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RdrName -> r Source # gmapQ :: (forall d. Data d => d -> u) -> RdrName -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> RdrName -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> RdrName -> m RdrName Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RdrName -> m RdrName Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RdrName -> m RdrName Source #
Ord RdrName # |
Instance details Defined in RdrName Methods compare :: RdrName -> RdrName -> Ordering # (<) :: RdrName -> RdrName -> Bool # (<=) :: RdrName -> RdrName -> Bool # (>) :: RdrName -> RdrName -> Bool # (>=) :: RdrName -> RdrName -> Bool # max :: RdrName -> RdrName -> RdrName # min :: RdrName -> RdrName -> RdrName #
OutputableBndr RdrName # |
Instance details Defined in RdrName Methods pprBndr :: BindingSite -> RdrName -> SDoc # pprPrefixOcc :: RdrName -> SDoc # pprInfixOcc :: RdrName -> SDoc # bndrIsJoin_maybe :: RdrName -> Maybe Int #
Outputable RdrName # |
Instance details Defined in RdrName Methods ppr :: RdrName -> SDoc # pprPrec :: Rational -> RdrName -> SDoc #
HasOccName RdrName # |
Instance details Defined in RdrName Methods occName :: RdrName -> OccName #
DisambInfixOp RdrName # |
Instance details Defined in RdrHsSyn Methods mkHsVarOpPV :: Located RdrName -> PV (Located RdrName) # mkHsConOpPV :: Located RdrName -> PV (Located RdrName) # mkHsInfixHolePV :: SrcSpan -> PV (Located RdrName) #

## Identifiers

type Id = Var #

Identifier

idType :: Id -> Kind #

isImplicitId :: Id -> Bool #

`isImplicitId` tells whether an `Id`s info is implied by other declarations, so we don't need to put its signature in an interface file, even if it's mentioned in some other interface unfolding.

isDeadBinder :: Id -> Bool #

isExportedId :: Var -> Bool #

`isExportedIdVar` means "don't throw this away"

isLocalId :: Var -> Bool #

isGlobalId :: Var -> Bool #

isRecordSelector :: Id -> Bool #

isPrimOpId :: Id -> Bool #

isFCallId :: Id -> Bool #

isClassOpId_maybe :: Id -> Maybe Class #

isDataConWorkId :: Id -> Bool #

idDataCon :: Id -> DataCon #

Get from either the worker or the wrapper `Id` to the `DataCon`. Currently used only in the desugarer.

INVARIANT: `idDataCon (dataConWrapId d) = d`: remember, `dataConWrapId` can return either the wrapper or the worker

isBottomingId :: Var -> Bool #

Returns true if an application to n args would diverge

isDictonaryId :: Id -> Bool #

recordSelectorTyCon :: Id -> RecSelParent #

If the `Id` is that for a record selector, extract the `sel_tycon`. Panic otherwise.

## Type constructors

data TyCon #

TyCons represent type constructors. Type constructors are introduced by things such as:

1) Data declarations: `data Foo = ...` creates the `Foo` type constructor of kind `*`

2) Type synonyms: `type Foo = ...` creates the `Foo` type constructor

3) Newtypes: `newtype Foo a = MkFoo ...` creates the `Foo` type constructor of kind `* -> *`

4) Class declarations: `class Foo where` creates the `Foo` type constructor of kind `*`

This data type also encodes a number of primitive, built in type constructors such as those for function and tuple types.

#### Instances

Instances details

Eq TyCon # |
Instance details Defined in TyCon Methods (==) :: TyCon -> TyCon -> Bool # (/=) :: TyCon -> TyCon -> Bool #
Data TyCon # |
Instance details Defined in TyCon Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TyCon -> c TyCon Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TyCon Source # toConstr :: TyCon -> Constr Source # dataTypeOf :: TyCon -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TyCon) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyCon) Source # gmapT :: (forall b. Data b => b -> b) -> TyCon -> TyCon Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyCon -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyCon -> r Source # gmapQ :: (forall d. Data d => d -> u) -> TyCon -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> TyCon -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TyCon -> m TyCon Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCon -> m TyCon Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCon -> m TyCon Source #
Outputable TyCon # |
Instance details Defined in TyCon Methods ppr :: TyCon -> SDoc # pprPrec :: Rational -> TyCon -> SDoc #
Uniquable TyCon # |
Instance details Defined in TyCon Methods getUnique :: TyCon -> Unique #
NamedThing TyCon # |
Instance details Defined in TyCon Methods getOccName :: TyCon -> OccName # getName :: TyCon -> Name #

tyConTyVars :: TyCon -> [TyVar] #

TyVar binders

tyConDataCons :: TyCon -> [DataCon] #

As `tyConDataCons_maybe`, but returns the empty list of constructors if no constructors could be found

tyConArity :: TyCon -> Arity #

Arity

isClassTyCon :: TyCon -> Bool #

Is this `TyCon` that for a class instance?

isTypeSynonymTyCon :: TyCon -> Bool #

Is this a `TyCon` representing a regular H98 type synonym (`type`)?

isTypeFamilyTyCon :: TyCon -> Bool #

Is this a synonym `TyCon` that can have may have further instances appear?

isNewTyCon :: TyCon -> Bool #

Is this `TyCon` that for a `newtype`

isPrimTyCon :: TyCon -> Bool #

Does this `TyCon` represent something that cannot be defined in Haskell?

isFunTyCon :: TyCon -> Bool #

isFamilyTyCon :: TyCon -> Bool #

Is this a `TyCon`, synonym or otherwise, that defines a family?

isOpenFamilyTyCon :: TyCon -> Bool #

Is this a `TyCon`, synonym or otherwise, that defines a family with instances?

isOpenTypeFamilyTyCon :: TyCon -> Bool #

Is this an open type family TyCon?

tyConClass_maybe :: TyCon -> Maybe Class #

If this `TyCon` is that for a class instance, return the class it is for. Otherwise returns `Nothing`

synTyConRhs_maybe :: TyCon -> Maybe Type #

Extract the information pertaining to the right hand side of a type synonym (`type`) declaration.

synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type) #

Extract the `TyVar`s bound by a vanilla type synonym and the corresponding (unsubstituted) right hand side.

tyConKind :: TyCon -> Kind #

Kind of this TyCon

## Type variables

type TyVar = Var #

Type or kind Variable

alphaTyVars :: [TyVar] #

## Data constructors

data DataCon #

A data constructor

- `AnnKeywordId` : `AnnOpen`, `AnnClose`,`AnnComma`

#### Instances

Instances details

Eq DataCon # |
Instance details Defined in DataCon Methods (==) :: DataCon -> DataCon -> Bool # (/=) :: DataCon -> DataCon -> Bool #
Data DataCon # |
Instance details Defined in DataCon Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DataCon -> c DataCon Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DataCon Source # toConstr :: DataCon -> Constr Source # dataTypeOf :: DataCon -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DataCon) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataCon) Source # gmapT :: (forall b. Data b => b -> b) -> DataCon -> DataCon Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DataCon -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DataCon -> r Source # gmapQ :: (forall d. Data d => d -> u) -> DataCon -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> DataCon -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> DataCon -> m DataCon Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DataCon -> m DataCon Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DataCon -> m DataCon Source #
OutputableBndr DataCon # |
Instance details Defined in DataCon Methods pprBndr :: BindingSite -> DataCon -> SDoc # pprPrefixOcc :: DataCon -> SDoc # pprInfixOcc :: DataCon -> SDoc # bndrIsJoin_maybe :: DataCon -> Maybe Int #
Outputable DataCon # |
Instance details Defined in DataCon Methods ppr :: DataCon -> SDoc # pprPrec :: Rational -> DataCon -> SDoc #
Uniquable DataCon # |
Instance details Defined in DataCon Methods getUnique :: DataCon -> Unique #
NamedThing DataCon # |
Instance details Defined in DataCon Methods getOccName :: DataCon -> OccName # getName :: DataCon -> Name #

dataConSig :: DataCon -> ([TyCoVar], ThetaType, [Type], Type) #

The "signature" of the `DataCon` returns, in order:

1) The result of `dataConUnivAndExTyCoVars`,

2) All the `ThetaType`s relating to the `DataCon` (coercion, dictionary, implicit parameter - whatever), including dependent GADT equalities. Dependent GADT equalities are *also* listed in return value (1), so be careful!

3) The type arguments to the constructor

4) The original result type of the `DataCon`

dataConType :: DataCon -> Type #

dataConTyCon :: DataCon -> TyCon #

The type constructor that we are building via this data constructor

dataConFieldLabels :: DataCon -> [FieldLabel] #

The labels for the fields of this particular `DataCon`

dataConIsInfix :: DataCon -> Bool #

Should the `DataCon` be presented infix?

isVanillaDataCon :: DataCon -> Bool #

Vanilla `DataCon`s are those that are nice boring Haskell 98 constructors

dataConUserType :: DataCon -> Type #

The user-declared type of the data constructor in the nice-to-read form:

    T :: forall a b. a -> b -> T [a]

rather than:

    T :: forall a c. forall b. (c~[a]) => a -> b -> T c

The type variables are quantified in the order that the user wrote them. See `Note [DataCon user type variable binders]`.

NB: If the constructor is part of a data instance, the result type mentions the family tycon, not the internal one.

dataConSrcBangs :: DataCon -> [HsSrcBang] #

Strictness/unpack annotations, from user; or, for imported DataCons, from the interface file The list is in one-to-one correspondence with the arity of the `DataCon`

data StrictnessMark #

Constructors

MarkedStrict |
NotMarkedStrict |

#### Instances

Instances details

Outputable StrictnessMark # |
Instance details Defined in DataCon Methods ppr :: StrictnessMark -> SDoc # pprPrec :: Rational -> StrictnessMark -> SDoc #

isMarkedStrict :: StrictnessMark -> Bool #

## Classes

data Class #

#### Instances

Instances details

Eq Class # |
Instance details Defined in Class Methods (==) :: Class -> Class -> Bool # (/=) :: Class -> Class -> Bool #
Data Class # |
Instance details Defined in Class Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Class -> c Class Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Class Source # toConstr :: Class -> Constr Source # dataTypeOf :: Class -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Class) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Class) Source # gmapT :: (forall b. Data b => b -> b) -> Class -> Class Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Class -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Class -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Class -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Class -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Class -> m Class Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Class -> m Class Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Class -> m Class Source #
Outputable Class # |
Instance details Defined in Class Methods ppr :: Class -> SDoc # pprPrec :: Rational -> Class -> SDoc #
Uniquable Class # |
Instance details Defined in Class Methods getUnique :: Class -> Unique #
NamedThing Class # |
Instance details Defined in Class Methods getOccName :: Class -> OccName # getName :: Class -> Name #

classMethods :: Class -> [Id] #

classSCTheta :: Class -> [PredType] #

classTvsFds :: Class -> ([TyVar], [FunDep TyVar]) #

classATs :: Class -> [TyCon] #

pprFundeps :: Outputable a => [FunDep a] -> SDoc #

## Instances

data ClsInst #

A type-class instance. Note that there is some tricky laziness at work here. See Note [ClsInst laziness and the rough-match fields] for more details.

#### Instances

Instances details

Data ClsInst # |
Instance details Defined in InstEnv Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ClsInst -> c ClsInst Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ClsInst Source # toConstr :: ClsInst -> Constr Source # dataTypeOf :: ClsInst -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ClsInst) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ClsInst) Source # gmapT :: (forall b. Data b => b -> b) -> ClsInst -> ClsInst Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ClsInst -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ClsInst -> r Source # gmapQ :: (forall d. Data d => d -> u) -> ClsInst -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> ClsInst -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ClsInst -> m ClsInst Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ClsInst -> m ClsInst Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ClsInst -> m ClsInst Source #
Outputable ClsInst # |
Instance details Defined in InstEnv Methods ppr :: ClsInst -> SDoc # pprPrec :: Rational -> ClsInst -> SDoc #
NamedThing ClsInst # |
Instance details Defined in InstEnv Methods getOccName :: ClsInst -> OccName # getName :: ClsInst -> Name #

instanceDFunId :: ClsInst -> DFunId #

pprInstance :: ClsInst -> SDoc #

pprInstanceHdr :: ClsInst -> SDoc #

pprFamInst :: FamInst -> SDoc #

Pretty-prints a `FamInst` (type/data family instance) with its defining location.

data FamInst #

#### Instances

Instances details

Outputable FamInst # |
Instance details Defined in FamInstEnv Methods ppr :: FamInst -> SDoc # pprPrec :: Rational -> FamInst -> SDoc #
NamedThing FamInst # |
Instance details Defined in FamInstEnv Methods getOccName :: FamInst -> OccName # getName :: FamInst -> Name #

## Types and Kinds

data Type #

#### Instances

Instances details

Data Type # |
Instance details Defined in TyCoRep Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Type -> c Type Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type Source # toConstr :: Type -> Constr Source # dataTypeOf :: Type -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type) Source # gmapT :: (forall b. Data b => b -> b) -> Type -> Type Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Type -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Type -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Type -> m Type Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type Source #
Outputable Type # |
Instance details Defined in TyCoRep Methods ppr :: Type -> SDoc # pprPrec :: Rational -> Type -> SDoc #

splitForAllTys :: Type -> ([TyCoVar], Type) #

Take a ForAllTy apart, returning the list of tycovars and the result type. This always succeeds, even if it returns only an empty list. Note that the result type returned may have free variables that were bound by a forall.

funResultTy :: Type -> Type #

Extract the function result type and panic if that is not possible

pprParendType :: Type -> SDoc #

pprTypeApp :: TyCon -> [Type] -> SDoc #

type Kind = Type #

The key type representing kinds in the compiler.

type PredType = Type #

A type of the form `p` of constraint kind represents a value whose type is the Haskell predicate `p`, where a predicate is what occurs before the `=>` in a Haskell type.

We use `PredType` as documentation to mark those types that we guarantee to have this kind.

It can be expanded into its representation, but:

- The type checker must treat it as opaque
- The rest of the compiler treats it as transparent

Consider these examples:

    f :: (Eq a) => a -> Int
    g :: (?x :: Int -> Int) => a -> Int
    h :: (r\l) => {r} => {l::Int | r}

Here the `Eq a` and `?x :: Int -> Int` and `rl` are all called "predicates"

type ThetaType = [PredType] #

A collection of `PredType`s

pprForAll :: [TyCoVarBinder] -> SDoc #

pprThetaArrowTy :: ThetaType -> SDoc #

parseInstanceHead :: GhcMonad m => String -> m Type #

getInstancesForType :: GhcMonad m => Type -> m [ClsInst] #

## Entities

data TyThing #

A global typecheckable-thing, essentially anything that has a name. Not to be confused with a `TcTyThing`, which is also a typecheckable thing but in the *local* context. See `TcEnv` for how to retrieve a `TyThing` given a `Name`.

Constructors

AnId Id |
AConLike ConLike |
ATyCon TyCon |
ACoAxiom (CoAxiom Branched) |

#### Instances

Instances details

Outputable TyThing # |
Instance details Defined in TyCoRep Methods ppr :: TyThing -> SDoc # pprPrec :: Rational -> TyThing -> SDoc #
NamedThing TyThing # |
Instance details Defined in TyCoRep Methods getOccName :: TyThing -> OccName # getName :: TyThing -> Name #

## Syntax

module GHC.Hs

## Fixities

data FixityDirection #

Constructors

InfixL |
InfixR |
InfixN |

#### Instances

Instances details

Eq FixityDirection # |
Instance details Defined in BasicTypes Methods (==) :: FixityDirection -> FixityDirection -> Bool # (/=) :: FixityDirection -> FixityDirection -> Bool #
Data FixityDirection # |
Instance details Defined in BasicTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FixityDirection -> c FixityDirection Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c FixityDirection Source # toConstr :: FixityDirection -> Constr Source # dataTypeOf :: FixityDirection -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c FixityDirection) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FixityDirection) Source # gmapT :: (forall b. Data b => b -> b) -> FixityDirection -> FixityDirection Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FixityDirection -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FixityDirection -> r Source # gmapQ :: (forall d. Data d => d -> u) -> FixityDirection -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> FixityDirection -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> FixityDirection -> m FixityDirection Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FixityDirection -> m FixityDirection Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FixityDirection -> m FixityDirection Source #
Outputable FixityDirection # |
Instance details Defined in BasicTypes Methods ppr :: FixityDirection -> SDoc # pprPrec :: Rational -> FixityDirection -> SDoc #
Binary FixityDirection # |
Instance details Defined in Binary Methods put_ :: BinHandle -> FixityDirection -> IO () # put :: BinHandle -> FixityDirection -> IO (Bin FixityDirection) # get :: BinHandle -> IO FixityDirection #

defaultFixity :: Fixity #

maxPrecedence :: Int #

negateFixity :: Fixity #

compareFixity :: Fixity -> Fixity -> (Bool, Bool) #

data LexicalFixity #

Captures the fixity of declarations as they are parsed. This is not necessarily the same as the fixity declaration, as the normal fixity may be overridden using parens or backticks.

Constructors

Prefix |
Infix |

#### Instances

Instances details

Eq LexicalFixity # |
Instance details Defined in BasicTypes Methods (==) :: LexicalFixity -> LexicalFixity -> Bool # (/=) :: LexicalFixity -> LexicalFixity -> Bool #
Data LexicalFixity # |
Instance details Defined in BasicTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LexicalFixity -> c LexicalFixity Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c LexicalFixity Source # toConstr :: LexicalFixity -> Constr Source # dataTypeOf :: LexicalFixity -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c LexicalFixity) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LexicalFixity) Source # gmapT :: (forall b. Data b => b -> b) -> LexicalFixity -> LexicalFixity Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LexicalFixity -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LexicalFixity -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LexicalFixity -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LexicalFixity -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LexicalFixity -> m LexicalFixity Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LexicalFixity -> m LexicalFixity Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LexicalFixity -> m LexicalFixity Source #
Outputable LexicalFixity # |
Instance details Defined in BasicTypes Methods ppr :: LexicalFixity -> SDoc # pprPrec :: Rational -> LexicalFixity -> SDoc #

## Source locations

data SrcLoc #

Source Location

Constructors

RealSrcLoc !RealSrcLoc |
UnhelpfulLoc FastString |

#### Instances

Instances details

Eq SrcLoc # |
Instance details Defined in SrcLoc Methods (==) :: SrcLoc -> SrcLoc -> Bool # (/=) :: SrcLoc -> SrcLoc -> Bool #
Ord SrcLoc # |
Instance details Defined in SrcLoc Methods compare :: SrcLoc -> SrcLoc -> Ordering # (<) :: SrcLoc -> SrcLoc -> Bool # (<=) :: SrcLoc -> SrcLoc -> Bool # (>) :: SrcLoc -> SrcLoc -> Bool # (>=) :: SrcLoc -> SrcLoc -> Bool # max :: SrcLoc -> SrcLoc -> SrcLoc # min :: SrcLoc -> SrcLoc -> SrcLoc #
Show SrcLoc # |
Instance details Defined in SrcLoc Methods showsPrec :: Int -> SrcLoc -> ShowS Source # show :: SrcLoc -> String Source # showList :: [SrcLoc] -> ShowS Source #
Outputable SrcLoc # |
Instance details Defined in SrcLoc Methods ppr :: SrcLoc -> SDoc # pprPrec :: Rational -> SrcLoc -> SDoc #

data RealSrcLoc #

Real Source Location

Represents a single point within a file

#### Instances

Instances details

Eq RealSrcLoc # |
Instance details Defined in SrcLoc Methods (==) :: RealSrcLoc -> RealSrcLoc -> Bool # (/=) :: RealSrcLoc -> RealSrcLoc -> Bool #
Ord RealSrcLoc # |
Instance details Defined in SrcLoc Methods compare :: RealSrcLoc -> RealSrcLoc -> Ordering # (<) :: RealSrcLoc -> RealSrcLoc -> Bool # (<=) :: RealSrcLoc -> RealSrcLoc -> Bool # (>) :: RealSrcLoc -> RealSrcLoc -> Bool # (>=) :: RealSrcLoc -> RealSrcLoc -> Bool # max :: RealSrcLoc -> RealSrcLoc -> RealSrcLoc # min :: RealSrcLoc -> RealSrcLoc -> RealSrcLoc #
Show RealSrcLoc # |
Instance details Defined in SrcLoc Methods showsPrec :: Int -> RealSrcLoc -> ShowS Source # show :: RealSrcLoc -> String Source # showList :: [RealSrcLoc] -> ShowS Source #
Outputable RealSrcLoc # |
Instance details Defined in SrcLoc Methods ppr :: RealSrcLoc -> SDoc # pprPrec :: Rational -> RealSrcLoc -> SDoc #

mkSrcLoc :: FastString -> Int -> Int -> SrcLoc #

noSrcLoc :: SrcLoc #

Built-in "bad" `SrcLoc` values for particular locations

srcLocFile :: RealSrcLoc -> FastString #

Gives the filename of the `RealSrcLoc`

srcLocLine :: RealSrcLoc -> Int #

Raises an error when used on a "bad" `SrcLoc`

srcLocCol :: RealSrcLoc -> Int #

Raises an error when used on a "bad" `SrcLoc`

data SrcSpan #

Source Span

A `SrcSpan` identifies either a specific portion of a text file or a human-readable description of a location.

Constructors

RealSrcSpan !RealSrcSpan |
UnhelpfulSpan !FastString |

#### Instances

Instances details

Eq SrcSpan # |
Instance details Defined in SrcLoc Methods (==) :: SrcSpan -> SrcSpan -> Bool # (/=) :: SrcSpan -> SrcSpan -> Bool #
Data SrcSpan # |
Instance details Defined in SrcLoc Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SrcSpan -> c SrcSpan Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SrcSpan Source # toConstr :: SrcSpan -> Constr Source # dataTypeOf :: SrcSpan -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SrcSpan) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcSpan) Source # gmapT :: (forall b. Data b => b -> b) -> SrcSpan -> SrcSpan Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SrcSpan -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SrcSpan -> r Source # gmapQ :: (forall d. Data d => d -> u) -> SrcSpan -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> SrcSpan -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan Source #
Ord SrcSpan # |
Instance details Defined in SrcLoc Methods compare :: SrcSpan -> SrcSpan -> Ordering # (<) :: SrcSpan -> SrcSpan -> Bool # (<=) :: SrcSpan -> SrcSpan -> Bool # (>) :: SrcSpan -> SrcSpan -> Bool # (>=) :: SrcSpan -> SrcSpan -> Bool # max :: SrcSpan -> SrcSpan -> SrcSpan # min :: SrcSpan -> SrcSpan -> SrcSpan #
Show SrcSpan # |
Instance details Defined in SrcLoc Methods showsPrec :: Int -> SrcSpan -> ShowS Source # show :: SrcSpan -> String Source # showList :: [SrcSpan] -> ShowS Source #
NFData SrcSpan # |
Instance details Defined in SrcLoc Methods rnf :: SrcSpan -> () Source #
Outputable SrcSpan # |
Instance details Defined in SrcLoc Methods ppr :: SrcSpan -> SDoc # pprPrec :: Rational -> SrcSpan -> SDoc #
ToJson SrcSpan # |
Instance details Defined in SrcLoc Methods json :: SrcSpan -> JsonDoc #
Binary SrcSpan # |
Instance details Defined in Binary Methods put_ :: BinHandle -> SrcSpan -> IO () # put :: BinHandle -> SrcSpan -> IO (Bin SrcSpan) # get :: BinHandle -> IO SrcSpan #
Data (LHsTypeArg GhcTc) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcTc -> c (LHsTypeArg GhcTc) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcTc) Source # toConstr :: LHsTypeArg GhcTc -> Constr Source # dataTypeOf :: LHsTypeArg GhcTc -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcTc)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcTc)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcTc -> LHsTypeArg GhcTc Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcTc -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcTc -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcTc -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcTc -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source #
Data (LHsTypeArg GhcRn) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcRn -> c (LHsTypeArg GhcRn) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcRn) Source # toConstr :: LHsTypeArg GhcRn -> Constr Source # dataTypeOf :: LHsTypeArg GhcRn -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcRn)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcRn)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcRn -> LHsTypeArg GhcRn Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcRn -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcRn -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcRn -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcRn -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source #
Data (LHsTypeArg GhcPs) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcPs -> c (LHsTypeArg GhcPs) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcPs) Source # toConstr :: LHsTypeArg GhcPs -> Constr Source # dataTypeOf :: LHsTypeArg GhcPs -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcPs)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcPs)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcPs -> LHsTypeArg GhcPs Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcPs -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcPs -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcPs -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcPs -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source #
HasSrcSpan (Located a) # |
Instance details Defined in SrcLoc Methods composeSrcSpan :: Located (SrcSpanLess (Located a)) -> Located a # decomposeSrcSpan :: Located a -> Located (SrcSpanLess (Located a)) #
Binary a => Binary (Located a) # |
Instance details Defined in Binary Methods put_ :: BinHandle -> Located a -> IO () # put :: BinHandle -> Located a -> IO (Bin (Located a)) # get :: BinHandle -> IO (Located a) #
NamedThing e => NamedThing (Located e) # |
Instance details Defined in Name Methods getOccName :: Located e -> OccName # getName :: Located e -> Name #

data RealSrcSpan #

A `RealSrcSpan` delimits a portion of a text file. It could be represented by a pair of (line,column) coordinates, but in fact we optimise slightly by using more compact representations for single-line and zero-length spans, both of which are quite common.

The end position is defined to be the column after the end of the span. That is, a span of (1,1)-(1,2) is one character long, and a span of (1,1)-(1,1) is zero characters long.

Real Source Span

#### Instances

Instances details

Eq RealSrcSpan # |
Instance details Defined in SrcLoc Methods (==) :: RealSrcSpan -> RealSrcSpan -> Bool # (/=) :: RealSrcSpan -> RealSrcSpan -> Bool #
Data RealSrcSpan # |
Instance details Defined in SrcLoc Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RealSrcSpan -> c RealSrcSpan Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RealSrcSpan Source # toConstr :: RealSrcSpan -> Constr Source # dataTypeOf :: RealSrcSpan -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RealSrcSpan) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RealSrcSpan) Source # gmapT :: (forall b. Data b => b -> b) -> RealSrcSpan -> RealSrcSpan Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RealSrcSpan -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RealSrcSpan -> r Source # gmapQ :: (forall d. Data d => d -> u) -> RealSrcSpan -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> RealSrcSpan -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> RealSrcSpan -> m RealSrcSpan Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RealSrcSpan -> m RealSrcSpan Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RealSrcSpan -> m RealSrcSpan Source #
Ord RealSrcSpan # |
Instance details Defined in SrcLoc Methods compare :: RealSrcSpan -> RealSrcSpan -> Ordering # (<) :: RealSrcSpan -> RealSrcSpan -> Bool # (<=) :: RealSrcSpan -> RealSrcSpan -> Bool # (>) :: RealSrcSpan -> RealSrcSpan -> Bool # (>=) :: RealSrcSpan -> RealSrcSpan -> Bool # max :: RealSrcSpan -> RealSrcSpan -> RealSrcSpan # min :: RealSrcSpan -> RealSrcSpan -> RealSrcSpan #
Show RealSrcSpan # |
Instance details Defined in SrcLoc Methods showsPrec :: Int -> RealSrcSpan -> ShowS Source # show :: RealSrcSpan -> String Source # showList :: [RealSrcSpan] -> ShowS Source #
Outputable RealSrcSpan # |
Instance details Defined in SrcLoc Methods ppr :: RealSrcSpan -> SDoc # pprPrec :: Rational -> RealSrcSpan -> SDoc #
ToJson RealSrcSpan # |
Instance details Defined in SrcLoc Methods json :: RealSrcSpan -> JsonDoc #
Binary RealSrcSpan # |
Instance details Defined in Binary Methods put_ :: BinHandle -> RealSrcSpan -> IO () # put :: BinHandle -> RealSrcSpan -> IO (Bin RealSrcSpan) # get :: BinHandle -> IO RealSrcSpan #

mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan #

Create a `SrcSpan` between two points in a file

srcLocSpan :: SrcLoc -> SrcSpan #

Create a `SrcSpan` corresponding to a single point

isGoodSrcSpan :: SrcSpan -> Bool #

Test if a `SrcSpan` is "good", i.e. has precise location information

noSrcSpan :: SrcSpan #

Built-in "bad" `SrcSpan`s for common sources of location uncertainty

srcSpanStart :: SrcSpan -> SrcLoc #

Returns the location at the start of the `SrcSpan` or a "bad" `SrcSpan` if that is unavailable

srcSpanEnd :: SrcSpan -> SrcLoc #

Returns the location at the end of the `SrcSpan` or a "bad" `SrcSpan` if that is unavailable

srcSpanFile :: RealSrcSpan -> FastString #

srcSpanStartLine :: RealSrcSpan -> Int #

srcSpanEndLine :: RealSrcSpan -> Int #

srcSpanStartCol :: RealSrcSpan -> Int #

srcSpanEndCol :: RealSrcSpan -> Int #

## Located

data GenLocated l e #

We attach SrcSpans to lots of things, so let's have a datatype for it.

Constructors

L l e |

#### Instances

Instances details

Data (LHsTypeArg GhcTc) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcTc -> c (LHsTypeArg GhcTc) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcTc) Source # toConstr :: LHsTypeArg GhcTc -> Constr Source # dataTypeOf :: LHsTypeArg GhcTc -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcTc)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcTc)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcTc -> LHsTypeArg GhcTc Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcTc -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcTc -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcTc -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcTc -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source #
Data (LHsTypeArg GhcRn) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcRn -> c (LHsTypeArg GhcRn) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcRn) Source # toConstr :: LHsTypeArg GhcRn -> Constr Source # dataTypeOf :: LHsTypeArg GhcRn -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcRn)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcRn)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcRn -> LHsTypeArg GhcRn Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcRn -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcRn -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcRn -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcRn -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source #
Data (LHsTypeArg GhcPs) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcPs -> c (LHsTypeArg GhcPs) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcPs) Source # toConstr :: LHsTypeArg GhcPs -> Constr Source # dataTypeOf :: LHsTypeArg GhcPs -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcPs)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcPs)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcPs -> LHsTypeArg GhcPs Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcPs -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcPs -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcPs -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcPs -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source #
Functor (GenLocated l) # |
Instance details Defined in SrcLoc Methods fmap :: (a -> b) -> GenLocated l a -> GenLocated l b Source # (<$) :: a -> GenLocated l b -> GenLocated l a Source #
Foldable (GenLocated l) # |
Instance details Defined in SrcLoc Methods fold :: Monoid m => GenLocated l m -> m Source # foldMap :: Monoid m => (a -> m) -> GenLocated l a -> m Source # foldMap' :: Monoid m => (a -> m) -> GenLocated l a -> m Source # foldr :: (a -> b -> b) -> b -> GenLocated l a -> b Source # foldr' :: (a -> b -> b) -> b -> GenLocated l a -> b Source # foldl :: (b -> a -> b) -> b -> GenLocated l a -> b Source # foldl' :: (b -> a -> b) -> b -> GenLocated l a -> b Source # foldr1 :: (a -> a -> a) -> GenLocated l a -> a Source # foldl1 :: (a -> a -> a) -> GenLocated l a -> a Source # toList :: GenLocated l a -> [a] Source # null :: GenLocated l a -> Bool Source # length :: GenLocated l a -> Int Source # elem :: Eq a => a -> GenLocated l a -> Bool Source # maximum :: Ord a => GenLocated l a -> a Source # minimum :: Ord a => GenLocated l a -> a Source # sum :: Num a => GenLocated l a -> a Source # product :: Num a => GenLocated l a -> a Source #
Traversable (GenLocated l) # |
Instance details Defined in SrcLoc Methods traverse :: Applicative f => (a -> f b) -> GenLocated l a -> f (GenLocated l b) Source # sequenceA :: Applicative f => GenLocated l (f a) -> f (GenLocated l a) Source # mapM :: Monad m => (a -> m b) -> GenLocated l a -> m (GenLocated l b) Source # sequence :: Monad m => GenLocated l (m a) -> m (GenLocated l a) Source #
HasSrcSpan (Located a) # |
Instance details Defined in SrcLoc Methods composeSrcSpan :: Located (SrcSpanLess (Located a)) -> Located a # decomposeSrcSpan :: Located a -> Located (SrcSpanLess (Located a)) #
Binary a => Binary (Located a) # |
Instance details Defined in Binary Methods put_ :: BinHandle -> Located a -> IO () # put :: BinHandle -> Located a -> IO (Bin (Located a)) # get :: BinHandle -> IO (Located a) #
NamedThing e => NamedThing (Located e) # |
Instance details Defined in Name Methods getOccName :: Located e -> OccName # getName :: Located e -> Name #
(Eq l, Eq e) => Eq (GenLocated l e) # |
Instance details Defined in SrcLoc Methods (==) :: GenLocated l e -> GenLocated l e -> Bool # (/=) :: GenLocated l e -> GenLocated l e -> Bool #
(Data l, Data e) => Data (GenLocated l e) # |
Instance details Defined in SrcLoc Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GenLocated l e -> c (GenLocated l e) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GenLocated l e) Source # toConstr :: GenLocated l e -> Constr Source # dataTypeOf :: GenLocated l e -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (GenLocated l e)) Source # dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (GenLocated l e)) Source # gmapT :: (forall b. Data b => b -> b) -> GenLocated l e -> GenLocated l e Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r Source # gmapQ :: (forall d. Data d => d -> u) -> GenLocated l e -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> GenLocated l e -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> GenLocated l e -> m (GenLocated l e) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GenLocated l e -> m (GenLocated l e) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GenLocated l e -> m (GenLocated l e) Source #
(Ord l, Ord e) => Ord (GenLocated l e) # |
Instance details Defined in SrcLoc Methods compare :: GenLocated l e -> GenLocated l e -> Ordering # (<) :: GenLocated l e -> GenLocated l e -> Bool # (<=) :: GenLocated l e -> GenLocated l e -> Bool # (>) :: GenLocated l e -> GenLocated l e -> Bool # (>=) :: GenLocated l e -> GenLocated l e -> Bool # max :: GenLocated l e -> GenLocated l e -> GenLocated l e # min :: GenLocated l e -> GenLocated l e -> GenLocated l e #
(Outputable l, Outputable e) => Outputable (GenLocated l e) # |
Instance details Defined in SrcLoc Methods ppr :: GenLocated l e -> SDoc # pprPrec :: Rational -> GenLocated l e -> SDoc #
type SrcSpanLess (GenLocated l e) # |
Instance details Defined in SrcLoc type SrcSpanLess (GenLocated l e) = e

type Located = GenLocated SrcSpan #

### Constructing Located

noLoc :: HasSrcSpan a => SrcSpanLess a -> a #

mkGeneralLocated :: HasSrcSpan e => String -> SrcSpanLess e -> e #

### Deconstructing Located

getLoc :: HasSrcSpan a => a -> SrcSpan #

unLoc :: HasSrcSpan a => a -> SrcSpanLess a #

getRealSrcSpan :: RealLocated a -> RealSrcSpan #

unRealSrcSpan :: RealLocated a -> a #

## HasSrcSpan

class HasSrcSpan a where #

A typeclass to set/get SrcSpans

Methods

composeSrcSpan :: Located (SrcSpanLess a) -> a #

Composes a `SrcSpan` decoration with an undecorated syntactic entity to form its decorated variant

decomposeSrcSpan :: a -> Located (SrcSpanLess a) #

Decomposes a decorated syntactic entity into its `SrcSpan` decoration and its undecorated variant

#### Instances

Instances details

HasSrcSpan Name # |
Instance details Defined in Name Methods composeSrcSpan :: Located (SrcSpanLess Name) -> Name # decomposeSrcSpan :: Name -> Located (SrcSpanLess Name) #
HasSrcSpan (Located a) # |
Instance details Defined in SrcLoc Methods composeSrcSpan :: Located (SrcSpanLess (Located a)) -> Located a # decomposeSrcSpan :: Located a -> Located (SrcSpanLess (Located a)) #

type family SrcSpanLess a #

Determines the type of undecorated syntactic entities For most syntactic entities `E`, where source location spans are introduced by a wrapper construtor of the same syntactic entity, we have `SrcSpanLess E = E`. However, some syntactic entities have a different type compared to a syntactic entity `e :: E` may have the type `Located E` when decorated by wrapping it with `L sp e` for a source span `sp`.

#### Instances

Instances details

type SrcSpanLess Name # |
Instance details Defined in Name type SrcSpanLess Name = Name
type SrcSpanLess (GenLocated l e) # |
Instance details Defined in SrcLoc type SrcSpanLess (GenLocated l e) = e

dL :: HasSrcSpan a => a -> Located (SrcSpanLess a) #

An abbreviated form of decomposeSrcSpan, mainly to be used in ViewPatterns

cL :: HasSrcSpan a => SrcSpan -> SrcSpanLess a -> a #

An abbreviated form of composeSrcSpan, mainly to replace the hardcoded `L`

### Combining and comparing Located values

eqLocated :: (HasSrcSpan a, Eq (SrcSpanLess a)) => a -> a -> Bool #

Tests whether the two located things are equal

cmpLocated :: (HasSrcSpan a, Ord (SrcSpanLess a)) => a -> a -> Ordering #

Tests the ordering of the two located things

combineLocs :: (HasSrcSpan a, HasSrcSpan b) => a -> b -> SrcSpan #

addCLoc :: (HasSrcSpan a, HasSrcSpan b, HasSrcSpan c) => a -> b -> SrcSpanLess c -> c #

Combine locations from two `Located` things and add them to a third thing

leftmost_smallest :: SrcSpan -> SrcSpan -> Ordering #

Alternative strategies for ordering `SrcSpan`s

leftmost_largest :: SrcSpan -> SrcSpan -> Ordering #

Alternative strategies for ordering `SrcSpan`s

rightmost :: SrcSpan -> SrcSpan -> Ordering #

Alternative strategies for ordering `SrcSpan`s

spans :: SrcSpan -> (Int, Int) -> Bool #

Determines whether a span encloses a given line and column index

isSubspanOf #

Arguments

:: SrcSpan | The span that may be enclosed by the other
-> SrcSpan | The span it may be enclosed by
-> Bool |

Determines whether a span is enclosed by another one

# Exceptions

data GhcException #

GHC's own exception type error messages all take the form:

         location: error

If the location is on the command line, or in GHC itself, then location="ghc". All of the error types below correspond to a location of "ghc", except for ProgramError (where the string is assumed to contain a location already, so we don't print one).

Constructors

Signal Int | Some other fatal signal (SIGHUP,SIGTERM)
UsageError String | Prints the short usage msg after the error
CmdLineError String | A problem with the command line arguments, but don't print usage.
Panic String | The `impossible` happened.
PprPanic String SDoc |
Sorry String | The user tickled something that's known not to work yet, but we're not counting it as a bug.
PprSorry String SDoc |
InstallationError String | An installation problem.
ProgramError String | An error in the user's code, probably.
PprProgramError String SDoc |

#### Instances

Instances details

Show GhcException # |
Instance details Defined in Panic Methods showsPrec :: Int -> GhcException -> ShowS Source # show :: GhcException -> String Source # showList :: [GhcException] -> ShowS Source #
Exception GhcException # |
Instance details Defined in Panic Methods toException :: GhcException -> SomeException Source # fromException :: SomeException -> Maybe GhcException Source # displayException :: GhcException -> String Source #

showGhcException :: GhcException -> ShowS #

Append a description of the given exception to this string.

Note that this uses `unsafeGlobalDynFlags`, which may have some uninitialized fields if invoked before `initGhcMonad` has been called. If the error message to be printed includes a pretty-printer document which forces one of these fields this call may bottom.

# Token stream manipulations

data Token #

#### Instances

Instances details

Show Token # |
Instance details Defined in Lexer Methods showsPrec :: Int -> Token -> ShowS Source # show :: Token -> String Source # showList :: [Token] -> ShowS Source #
Outputable Token # |
Instance details Defined in Lexer Methods ppr :: Token -> SDoc # pprPrec :: Rational -> Token -> SDoc #

getTokenStream :: GhcMonad m => Module -> m [Located Token] #

Return module source as token stream, including comments.

The module must be in the module graph and its source must be available. Throws a `SourceError` on parse error.

getRichTokenStream :: GhcMonad m => Module -> m [(Located Token, String)] #

Give even more information on the source than `getTokenStream` This function allows reconstructing the source completely with `showRichTokenStream`.

showRichTokenStream :: [(Located Token, String)] -> String #

Take a rich token stream such as produced from `getRichTokenStream` and return source code almost identical to the original code (except for insignificant whitespace.)

addSourceToTokens :: RealSrcLoc -> StringBuffer -> [Located Token] -> [(Located Token, String)] #

Given a source location and a StringBuffer corresponding to this location, return a rich token stream with the source associated to the tokens.

# Pure interface to the parser

parser #

Arguments

:: String | Haskell module source text (full Unicode is supported)
-> DynFlags | the flags
-> FilePath | the filename (for source locations)
-> (WarningMessages, Either ErrorMessages (Located (HsModule GhcPs))) |

A pure interface to the module parser.

# API Annotations

type ApiAnns = (Map ApiAnnKey [SrcSpan], Map SrcSpan [Located AnnotationComment]) #

data AnnKeywordId #

API Annotations exist so that tools can perform source to source conversions of Haskell code. They are used to keep track of the various syntactic keywords that are not captured in the existing AST.

The annotations, together with original source comments are made available in the ``pm_annotations`` field of ``ParsedModule``. Comments are only retained if ``Opt_KeepRawTokenStream`` is set in ``DynFlags`` before parsing.

The wiki page describing this feature is https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations

Note: in general the names of these are taken from the corresponding token, unless otherwise noted See note [Api annotations] above for details of the usage

Constructors

AnnAnyclass |
AnnAs |
AnnAt |
AnnBang | `!`
AnnBackquote | '`'
AnnBy |
AnnCase | case or lambda case
AnnClass |
AnnClose | '#)' or '#-}' etc
AnnCloseB | '|)'
AnnCloseBU | '|)', unicode variant
AnnCloseC | '}'
AnnCloseQ | '|]'
AnnCloseQU | '|]', unicode variant
AnnCloseP | ')'
AnnCloseS | ']'
AnnColon |
AnnComma | as a list separator
AnnCommaTuple | in a RdrName for a tuple
AnnDarrow | '=>'
AnnDarrowU | '=>', unicode variant
AnnData |
AnnDcolon | '::'
AnnDcolonU | '::', unicode variant
AnnDefault |
AnnDeriving |
AnnDo |
AnnDot | `.`
AnnDotdot | '..'
AnnElse |
AnnEqual |
AnnExport |
AnnFamily |
AnnForall |
AnnForallU | Unicode variant
AnnForeign |
AnnFunId | for function name in matches where there are multiple equations for the function.
AnnGroup |
AnnHeader | for CType
AnnHiding |
AnnIf |
AnnImport |
AnnIn |
AnnInfix | 'infix' or 'infixl' or 'infixr'
AnnInstance |
AnnLam |
AnnLarrow | '<-'
AnnLarrowU | '<-', unicode variant
AnnLet |
AnnMdo |
AnnMinus | `-`
AnnModule |
AnnNewtype |
AnnName | where a name loses its location in the AST, this carries it
AnnOf |
AnnOpen | '(#' or '{-# LANGUAGE' etc
AnnOpenB | '(|'
AnnOpenBU | '(|', unicode variant
AnnOpenC | '{'
AnnOpenE | '[e|' or '[e||'
AnnOpenEQ | '[|'
AnnOpenEQU | '[|', unicode variant
AnnOpenP | '('
AnnOpenPE | '$('
AnnOpenPTE | '$$('
AnnOpenS | '['
AnnPackageName |
AnnPattern |
AnnProc |
AnnQualified |
AnnRarrow | `->`
AnnRarrowU | `->`, unicode variant
AnnRec |
AnnRole |
AnnSafe |
AnnSemi | ';'
AnnSimpleQuote | '''
AnnSignature |
AnnStatic | `static`
AnnStock |
AnnThen |
AnnThIdSplice | `$`
AnnThIdTySplice | `$$`
AnnThTyQuote | double '''
AnnTilde | '~'
AnnType |
AnnUnit | `()` for types
AnnUsing |
AnnVal | e.g. INTEGER
AnnValStr | String value, will need quotes when output
AnnVbar | '|'
AnnVia | `via`
AnnWhere |
Annlarrowtail | `-<`
AnnlarrowtailU | `-<`, unicode variant
Annrarrowtail | `->`
AnnrarrowtailU | `->`, unicode variant
AnnLarrowtail | `-<<`
AnnLarrowtailU | `-<<`, unicode variant
AnnRarrowtail | `>>-`
AnnRarrowtailU | `>>-`, unicode variant
AnnEofPos |

#### Instances

Instances details

Eq AnnKeywordId # |
Instance details Defined in ApiAnnotation Methods (==) :: AnnKeywordId -> AnnKeywordId -> Bool # (/=) :: AnnKeywordId -> AnnKeywordId -> Bool #
Data AnnKeywordId # |
Instance details Defined in ApiAnnotation Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AnnKeywordId -> c AnnKeywordId Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AnnKeywordId Source # toConstr :: AnnKeywordId -> Constr Source # dataTypeOf :: AnnKeywordId -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AnnKeywordId) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnKeywordId) Source # gmapT :: (forall b. Data b => b -> b) -> AnnKeywordId -> AnnKeywordId Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r Source # gmapQ :: (forall d. Data d => d -> u) -> AnnKeywordId -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> AnnKeywordId -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId Source #
Ord AnnKeywordId # |
Instance details Defined in ApiAnnotation Methods compare :: AnnKeywordId -> AnnKeywordId -> Ordering # (<) :: AnnKeywordId -> AnnKeywordId -> Bool # (<=) :: AnnKeywordId -> AnnKeywordId -> Bool # (>) :: AnnKeywordId -> AnnKeywordId -> Bool # (>=) :: AnnKeywordId -> AnnKeywordId -> Bool # max :: AnnKeywordId -> AnnKeywordId -> AnnKeywordId # min :: AnnKeywordId -> AnnKeywordId -> AnnKeywordId #
Show AnnKeywordId # |
Instance details Defined in ApiAnnotation Methods showsPrec :: Int -> AnnKeywordId -> ShowS Source # show :: AnnKeywordId -> String Source # showList :: [AnnKeywordId] -> ShowS Source #
Outputable AnnKeywordId # |
Instance details Defined in ApiAnnotation Methods ppr :: AnnKeywordId -> SDoc # pprPrec :: Rational -> AnnKeywordId -> SDoc #

data AnnotationComment #

Constructors

AnnDocCommentNext String | something beginning '-- |'
AnnDocCommentPrev String | something beginning '-- ^'
AnnDocCommentNamed String | something beginning '-- $'
AnnDocSection Int String | a section heading
AnnDocOptions String | doc options (prune, ignore-exports, etc)
AnnLineComment String | comment starting by "--"
AnnBlockComment String | comment in {- -}

#### Instances

Instances details

Eq AnnotationComment # |
Instance details Defined in ApiAnnotation Methods (==) :: AnnotationComment -> AnnotationComment -> Bool # (/=) :: AnnotationComment -> AnnotationComment -> Bool #
Data AnnotationComment # |
Instance details Defined in ApiAnnotation Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AnnotationComment -> c AnnotationComment Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AnnotationComment Source # toConstr :: AnnotationComment -> Constr Source # dataTypeOf :: AnnotationComment -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AnnotationComment) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnotationComment) Source # gmapT :: (forall b. Data b => b -> b) -> AnnotationComment -> AnnotationComment Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r Source # gmapQ :: (forall d. Data d => d -> u) -> AnnotationComment -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> AnnotationComment -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> AnnotationComment -> m AnnotationComment Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnotationComment -> m AnnotationComment Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnotationComment -> m AnnotationComment Source #
Ord AnnotationComment # |
Instance details Defined in ApiAnnotation Methods compare :: AnnotationComment -> AnnotationComment -> Ordering # (<) :: AnnotationComment -> AnnotationComment -> Bool # (<=) :: AnnotationComment -> AnnotationComment -> Bool # (>) :: AnnotationComment -> AnnotationComment -> Bool # (>=) :: AnnotationComment -> AnnotationComment -> Bool # max :: AnnotationComment -> AnnotationComment -> AnnotationComment # min :: AnnotationComment -> AnnotationComment -> AnnotationComment #
Show AnnotationComment # |
Instance details Defined in ApiAnnotation Methods showsPrec :: Int -> AnnotationComment -> ShowS Source # show :: AnnotationComment -> String Source # showList :: [AnnotationComment] -> ShowS Source #
Outputable AnnotationComment # |
Instance details Defined in ApiAnnotation Methods ppr :: AnnotationComment -> SDoc # pprPrec :: Rational -> AnnotationComment -> SDoc #

getAnnotation :: ApiAnns -> SrcSpan -> AnnKeywordId -> [SrcSpan] #

Retrieve a list of annotation `SrcSpan`s based on the `SrcSpan` of the annotated AST element, and the known type of the annotation.

getAndRemoveAnnotation :: ApiAnns -> SrcSpan -> AnnKeywordId -> ([SrcSpan], ApiAnns) #

Retrieve a list of annotation `SrcSpan`s based on the `SrcSpan` of the annotated AST element, and the known type of the annotation. The list is removed from the annotations.

getAnnotationComments :: ApiAnns -> SrcSpan -> [Located AnnotationComment] #

Retrieve the comments allocated to the current `SrcSpan`

Note: A given `SrcSpan` may appear in multiple AST elements, beware of duplicates

getAndRemoveAnnotationComments :: ApiAnns -> SrcSpan -> ([Located AnnotationComment], ApiAnns) #

Retrieve the comments allocated to the current `SrcSpan`, and remove them from the annotations

unicodeAnn :: AnnKeywordId -> AnnKeywordId #

Convert a normal annotation into its unicode equivalent one

# Miscellaneous

cyclicModuleErr :: [ModSummary] -> SDoc #