HORIZON HASKELLDocslts/ghc-9.14.x3e2d5682026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 3e2d568 · 2026-10-11

  • Packageghc-9.14.1
  • Exports374
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceGHC.hs

Initialisation

5 declarations

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.

valuewithSignalHandlers :: ExceptionMonad m => m a -> m a
#

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

GHC Monad

9 declarations
newtypenewtype 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.

Instances12Monad, Functor, MonadFix, MonadFail, Applicative, MonadIO, …
newtypenewtype GhcT (m :: Type -> Type) a
#

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

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

Instances12Monad, Functor, MonadFix, MonadFail, Applicative, MonadIO, …
classclass (Functor m, ExceptionMonad m, HasDynFlags m, HasLogger m) => GhcMonad (m :: Type -> Type) 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

Instances3GhcMonad
datadata 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.

Instances1ContainsDynFlags
valuerunGhc
  1. :: Maybe FilePath

    See argument to initGhcMonad.

  2. -> Ghc a

    The action to perform.

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

valueinitGhcMonad :: 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.

Flags and settings

27 declarations
datadata DynFlags
#

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

Constructors

datadata GeneralFlag
#

Enumerates the simple on-or-off dynamic flags

Constructors

Instances3Enum, Eq, Show
datadata Severity
#

Used to describe warnings and errors o The message has a file/line/column heading, plus "warning:" or "error:", added by mkLocMessage o With SevIgnore the message is suppressed o Output is intended for end users

Constructors

  • SevIgnore

    Ignore this message, for example in case of suppression of warnings users don't want to see. See Note [Suppressing Messages]

  • SevWarning
  • SevError
Instances5Eq, Ord, Show, Outputable, ToJson
newtypenewtype Backend
#

A value of type Backend represents one of GHC's back ends. The set of back ends cannot be extended except by modifying the definition of Backend in this module.

The Backend type is abstract; that is, its value constructors are not exported. It's crucial that they not be exported, because a value of type Backend carries only the back end's name, not its behavior or properties. If Backend were not abstract, then code elsewhere in the compiler could depend directly on the name, not on the semantics, which would make it challenging to create a new back end. Because Backend is abstract, all the obligations of a new back end are enumerated in this module, in the form of functions that take Backend as an argument.

The issue of abstraction is discussed at great length in #20927 and !7442.

Instances1Show
  • Show BackendDefined in ghc-9.14.1 · GHC.Driver.Backend

    The Show instance is for messages only. If code depends on what's in the string, you deserve what happens to you.

valuegopt :: GeneralFlag -> DynFlags -> Bool
#

Test whether a GeneralFlag is set

Note that dynamicNow (i.e., dynamic objects built with `-dynamic-too`) always implicitly enables Opt_PIC, Opt_ExternalDynamicRefs, and disables Opt_SplitSections.

valuencgBackend :: Backend
#

The native code generator. Compiles Cmm code into textual assembler, then relies on an external assembler toolchain to produce machine code.

Only supports a few platforms (X86, PowerPC, SPARC).

See GHC.CmmToAsm.

valuellvmBackend :: Backend
#

The LLVM backend.

Compiles Cmm code into LLVM textual IR, then relies on LLVM toolchain to produce machine code.

It relies on LLVM support for the calling convention used by the NCG backend to produce code objects ABI compatible with it (see "cc 10" or "ghccc" calling convention in https://llvm.org/docs/LangRef.html#calling-conventions).

Supports a few platforms (X86, AArch64, s390x, ARM).

See GHC.CmmToLlvm

valueviaCBackend :: Backend
#

Via-C ("unregisterised") backend.

Compiles Cmm code into C code, then relies on a C compiler to produce machine code.

It produces code objects that are not ABI compatible with those produced by NCG and LLVM backends.

Produced code is expected to be less efficient than the one produced by NCG and LLVM backends because STG registers are not pinned into real registers. On the other hand, it supports more target platforms (those having a valid C toolchain).

See GHC.CmmToC

The ByteCode interpreter.

Produce ByteCode objects (BCO, see GHC.ByteCode) that can be interpreted. It is used by GHCi.

Currently some extensions are not supported (foreign primops).

See GHC.StgToByteCode

valuenoBackend :: Backend
#

A dummy back end that generates no code.

Use this back end to disable code generation. It is particularly useful when GHC is used as a library for other purpose than generating code (e.g. to generate documentation with Haddock) or when the user requested it (via `-fno-code`) for some reason.

datadata 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 GHC.Unit.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

Instances2Eq, Outputable
valuesetProgramDynFlags :: GhcMonad m => DynFlags -> m Bool
#

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

Returns a boolean indicating if preload units have changed and need to be reloaded.

valuesetProgramHUG :: GhcMonad m => HomeUnitGraph -> m Bool
#

Sets the program HomeUnitGraph.

Sets the given HomeUnitGraph as the HomeUnitGraph of the current session. If the package flags change, we reinitialise the UnitState of all HomeUnitEnvs in the current session.

This function unconditionally invalidates the module graph cache.

Precondition: the given HomeUnitGraph must have the same keys as the HomeUnitGraph of the current session. I.e., assuming the new HomeUnitGraph is called new_hug, then:

 do
   hug <- hsc_HUG <$> getSession
   pure $ unitEnv_keys new_hug == unitEnv_keys hug

If this precondition is violated, the function will crash.

Conceptually, similar to setProgramDynFlags, but performs the same check for all HomeUnitEnvs.

Find the package environment (if one exists)

We interpret the package environment as a set of package flags; to be specific, if we find a package environment file like

clear-package-db
global-package-db
package-db blah/package.conf.d
package-id id1
package-id id2

we interpret this as

[ -hide-all-packages
, -clear-package-db
, -global-package-db
, -package-db blah/package.conf.d
, -package-id id1
, -package-id id2
]

There's also an older syntax alias for package-id, which is just an unadorned package id

id1
id2

Logging

9 declarations

Targets

9 declarations
datadata 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).

These fields are strict because Targets are long lived.

Constructors

  • Target
    • targetId :: !TargetId

      module or filename

    • targetAllowObjCode :: !Bool

      object code allowed?

    • targetUnitId :: !UnitId

      id of the unit this target is part of

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

Instances1Outputable
datadata 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.

Instances2Eq, Outputable
datadata Phase
#

Untyped Phase description

Instances3Eq, Show, Outputable
  • Eq PhaseDefined in ghc-9.14.1 · GHC.Driver.Phases
  • Show PhaseDefined in ghc-9.14.1 · GHC.Driver.Phases
  • Outputable PhaseDefined in ghc-9.14.1 · GHC.Driver.Phases
valuesetTargets :: 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.

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

  • If it looks like a module name, interpret it as such

  • otherwise, this function throws a GhcException.

valueguessTargetId :: GhcMonad m => String -> m TargetId
#

Attempts to guess what TargetId 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

  • If it looks like a module name, interpret it as such

  • otherwise, this function throws a GhcException.

Loading/compiling the program

29 declarations
valuedepanal
  1. :: GhcMonad m
  2. => [ModuleName]

    excluded modules

  3. -> Bool

    allow duplicate roots

  4. -> 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. In case of errors, just throw them.

valueload :: GhcMonad f => LoadHowMuch -> f 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 backend (see DynFlags.backend field) compiling and loading may result in files being created on disk.

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

If errors are encountered during dependency analysis, the module depanalE returns together with the errors an empty ModuleGraph. After processing this empty ModuleGraph, the errors of depanalE are thrown. All other errors are reported using the defaultWarnErrLogger.

valueworkingDirectoryChanged :: 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).

datadata PkgQual
#

Package-qualifier after renaming

Renaming detects if "this" or the unit-id of the home-unit was used as a package qualifier.

Constructors

Instances5Eq, Data, Ord, Outputable, Binary

Compiling to Core

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.

Inspecting the module structure of the program

22 declarations
datadata ModuleGraph
#

A 'ModuleGraph' contains all the nodes from the home package (only). See 'ModuleGraphNode' for information about the nodes.

Modules need to be compiled. hs-boots need to be typechecked before the associated "real" module so modules with {-# SOURCE #-} imports can be built. Instantiations also need to be typechecked to ensure that the module fits the signature. Substantiation typechecking is roughly comparable to the check that the module and its hs-boot agree.

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

valueemptyMG :: ModuleGraph
#

Why do we ever need to construct empty graphs? Is it because of one shot mode?

Construct a module graph. This function should be the only entry point for building a ModuleGraph, since it is supposed to be built once and never modified.

If you ever find the need to build a ModuleGraph iteratively, don't add insert and update functions to the API since they become footguns. Instead, design an API that allows iterative construction without posterior modification, perhaps like what is done for building arrays from mutable arrays.

datadata ModSummary
#

Data for a module node in a ModuleGraph. Module nodes of the module graph are one of:

  • A regular Haskell source module

  • A hi-boot source module

Constructors

Instances1Outputable
datadata ModLocation
#

Module Location

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

For a module in another unit, the ml_hs_file_ospath and ml_obj_file_ospath components of ModLocation are undefined.

The locations specified by a ModLocation may or may not correspond to actual files yet: for example, even if the object file doesn't exist, the ModLocation still contains the path to where the object file will reside if/when it is created.

The paths of anything which can affect recompilation should be placed inside ModLocation.

When a ModLocation is created none of the filepaths will have -boot suffixes. This is because in --make mode the ModLocation is put in the finder cache which is indexed by ModuleName, when a ModLocation is retrieved from the FinderCache the boot suffixes are appended. The other case is in -c mode, there the ModLocation immediately gets given the boot suffixes in mkOneShotModLocation.

Constructors

Instances2Show, Outputable
valuetopSortModuleGraph
  1. :: Bool

    Drop hi-boot nodes? (see below)

  2. -> ModuleGraph
  3. -> Maybe [HomeUnitModule]

    Root module name. If Nothing, use the full graph.

  4. -> [SCC ModuleGraphNode]
#

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

47 declarations
datadata ModIface_ (phase :: ModIfacePhase)
#

A ModIface summarises everything we know about a compiled module.

See Note [Structure of ModIface] for information about what belongs in each field.

See Note [Strictness in ModIface] to learn about why all the fields are lazy.

See Note [Private fields in ModIface] to learn why we don't export any of the fields.

Instances2Binary, NFData
datadata SafeHaskellMode
#

The various Safe Haskell modes

Constructors

Instances4Eq, Show, NFData, Outputable

Printing

2 declarations
datadata NamePprCtx
#

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.

Interactive evaluation

0 declarations

Executing statements

datadata ExecResult
#

Constructors

Adding new declarations

Get/set the current context

valuesetContext :: 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 updates the icReaderEnv 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.)

valuegetContext :: 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.

valuesetGHCiMonad :: 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.

Inspecting the current context

Lookup the given ModuleName in the HomeUnitGraph.

Returns Nothing if no Module has the given ModuleName. Otherwise, returns all Modules that have the given ModuleName.

A ModuleName is generally not enough to uniquely identify a Module, since there can be multiple units exposing the same ModuleName in the case of multiple home units. Thus, this function may return more than one possible Module. We leave it up to the caller to decide how to handle the ambiguity. For example, GHCi may prompt the user to clarify which Module is the correct one.

valueisModuleTrusted :: 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.

valuegetInfo
  1. :: GhcMonad m
  2. => Bool
  3. -> Name
  4. -> 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 classes 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)

valuegetNameToInstancesIndex
  1. :: GhcMonad m
  2. => [Module]

    visible modules. An orphan instance will be returned if it is visible from at least one module in the list.

  3. -> Maybe [Module]

    modules to load. If this is not specified, we load modules for everything that is in scope unqualified.

  4. -> m (Messages TcRnMessage, 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

datadata TcRnExprMode
#

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

Constructors

  • TM_Inst

    Instantiate inferred quantifiers only (:type)

  • TM_Default

    Instantiate all quantifiers, and do eager defaulting (:type +d)

Looking up a Name

Compiling expressions

newtypenewtype HValue
#
Instances1Show
  • Show HValueDefined in ghci-9.14.1 · GHCi.RemoteTypes

Docs

Other

The debugger

datadata ModBreaks
#

All the information about the source-relevant breakpoints for a module

This information is constructed once during desugaring (with mkModBreaks) from breakpoint ticks and fixed/unchanged from there on forward. It could be exported as an abstract datatype because it should never be updated after construction, only queried.

The arrays can be indexed using the int in the corresponding BreakpointId (i.e. the BreakpointId whose Module matches the Module corresponding to these ModBreaks) with the accessors modBreaks_locs, modBreaks_vars, and modBreaks_decls.

Constructors

typetype BreakTickIndex = Int
#

Breakpoint tick index newtype BreakTickIndex = BreakTickIndex Int deriving (Eq, Ord, Data, Ix, NFData, Outputable)

datadata BreakpointId
#

Breakpoint identifier.

Indexes into the structures in the ModBreaks created during desugaring (after inserting the breakpoint ticks in the expressions). See Note [Breakpoint identifiers]

Constructors

Instances5Eq, Data, Ord, NFData, Outputable
datadata InternalBreakpointId
#

Internal breakpoint identifier

Indexes into the structures in the InternalModBreaks produced during ByteCode generation. See Note [Breakpoint identifiers]

Constructors

Instances4Eq, Ord, NFData, Outputable

Abstract syntax elements

0 declarations

Units

Modules

Names

datadata Name
#

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

Instances17Eq, Data, Ord, NFData, NamedThing, Uniquable, …
classclass NamedThing a where
#

A class allowing convenient access to the Name of various datatypes

Methods

Instances21NamedThing, …
datadata 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`
( ~ )

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

Instances8Eq, Data, Ord, Outputable, OutputableBndr, HasOccName, …

Identifiers

typetype Id = Var
#

Identifier

valueisImplicitId :: Id -> Bool
#

isImplicitId tells whether an Ids 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.

valueidDataCon :: 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

Type constructors

datadata 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 Type

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

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

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

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

If you edit this type, you may need to update the GHC formalism See Note [GHC Formalism] in GHC.Core.Lint

Instances5Eq, Data, NamedThing, Outputable, Uniquable

Type variables

typetype TyVar = Var
#

Type or kind Variable

Data constructors

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.

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

Classes

datadata Class
#
Instances5Eq, Data, NamedThing, Outputable, Uniquable

Instances

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

Instances3Data, NamedThing, Outputable

Types and Kinds

datadata Type
#
Instances3Data, Outputable, Eq
valuesplitForAllTyCoVars :: 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.

typetype Kind = Type
#

The key type representing kinds in the compiler.

typetype 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"

Entities

Syntax

module GHC.Hs

Fixities

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

Instances3Eq, Data, Outputable

Source locations

datadata SrcSpan
#

Source Span

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

Instances22Eq, Data, Show, NFData, HasAnnotation, HasLoc, …
datadata 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

Instances8Eq, Data, Ord, Show, NFData, ToJson, …

Located

datadata GenLocated l e
#

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

Constructors

  • L l e
Instances179Semigroup, HasAnnotation, NoAnn, Functor, Foldable, Traversable, …

Constructing Located

Deconstructing Located

Combining and comparing Located values

valueisSubspanOf
  1. :: SrcSpan

    The span that may be enclosed by the other

  2. -> SrcSpan

    The span it may be enclosed by

  3. -> Bool
#

Determines whether a span is enclosed by another one

Exceptions

3 declarations
datadata 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

Instances2Show, Exception

Token stream manipulations

5 declarations
datadata Token
#
Instances2Show, Outputable

Pure interface to the parser

1 declaration

API Annotations

1 declaration
datadata EpaComment
#

Constructors

Instances10Eq, Data, Show, Semigroup, HasAnnotation, HasLoc, …