HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebreakpoint-0.1.4.0Haskell2010

Debug.Breakpoint.GhcFacade

  • 706 types
  • 21 classes
  • 4057 values
classclass IsOutput doc => IsLine doc where
#

A class of types that represent a single logical line of text, with support for horizontal composition.

See Note [HLine versus HDoc] and Note [The outputable class hierarchy] for more details.

Methods

  • char :: Char -> doc
  • text :: String -> doc
  • ftext :: FastString -> doc
  • ztext :: FastZString -> doc
  • (<>) :: doc -> doc -> doc

    Join two docs together horizontally without a gap.

  • (<+>) :: doc -> doc -> doc

    Join two docs together horizontally with a gap between them.

  • sep :: [doc] -> doc

    Separate: is either like hsep or like vcat, depending on what fits.

  • fsep :: [doc] -> doc

    A paragraph-fill combinator. It's much like sep, only it keeps fitting things on one line until it can't fit any more.

  • hcat :: [doc] -> doc

    Concatenate docs horizontally without gaps.

  • hsep :: [doc] -> doc

    Concatenate docs horizontally with a space between each one.

  • dualLine :: SDoc -> HLine -> doc

    Prints as either the given SDoc or the given HLine, depending on which type the result is instantiated to. This should generally be avoided; see Note [dualLine and dualDoc] for details.

Instances2IsLine
  • IsLine HLineDefined in ghc-9.10.3 · GHC.Utils.Outputable
  • IsLine SDocDefined in ghc-9.10.3 · GHC.Utils.Outputable
datadata GenLocated l e
#

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

Constructors

  • L l e
Instances167Semigroup, HasAnnotation, NoAnn, Functor, Foldable, Traversable, …
datadata Class
#
Instances5Eq, Data, NamedThing, Outputable, Uniquable
datadata TcPlugin
#

Constructors

  • forall s. TcPlugin
    • tcPluginInit :: TcPluginM s

      Initialize plugin, when entering type-checker.

    • tcPluginSolve :: s -> TcPluginSolver

      Solve some constraints.

      This function will be invoked at two points in the constraint solving process: once to simplify Given constraints, and once to solve Wanted constraints. In the first case (and only in the first case), no Wanted constraints will be passed to the plugin.

      The plugin can either return a contradiction, or specify that it has solved some constraints (with evidence), and possibly emit additional constraints. These returned constraints must be Givens in the first case, and Wanteds in the second.

      Use \ _ _ _ _ -> pure $ TcPluginOk [] [] if your plugin does not provide this functionality.

    • tcPluginRewrite :: s -> UniqFM TyCon TcPluginRewriter

      Rewrite saturated type family applications.

      The plugin is expected to supply a mapping from type family names to rewriting functions. For each type family TyCon, the plugin should provide a function which takes in the given constraints and arguments of a saturated type family application, and return a possible rewriting. See TcPluginRewriter for the expected shape of such a function.

      Use \ _ -> emptyUFM if your plugin does not provide this functionality.

    • tcPluginStop :: s -> TcPluginM ()

      Clean up after the plugin, when exiting the type-checker.

datadata Plugin
#

Plugin is the compiler plugin data type. Try to avoid constructing one of these directly, and just modify some fields of defaultPlugin instead: this is to try and preserve source-code compatibility when we add fields to this.

Nonetheless, this API is preliminary and highly likely to change in the future.

Constructors

datadata FunDep pass
#

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata Plugins
#

Constructors

  • Plugins
    • staticPlugins :: ![StaticPlugin]

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

    • externalPlugins :: ![ExternalPlugin]

      External plugins loaded directly from libraries without loading module interfaces.

    • loadedPlugins :: ![LoadedPlugin]

      Plugins dynamically loaded after processing arguments. What will be loaded here is directed by DynFlags.pluginModNames. Arguments are loaded from DynFlags.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.

    • loadedPluginDeps :: !([Linkable], PkgsLoaded)

      The object files required by the loaded plugins See Note [Plugin dependencies]

datadata Name
#

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

Instances14Eq, Data, Ord, NFData, NamedThing, Outputable, …
datadata Env gbl lcl
#

Constructors

Instances8Quasi, MonadUnique, MonadThings, ContainsDynFlags, ContainsHooks, ContainsLogger, …
datadata FastString
#

A FastString is a UTF-8 encoded string together with a unique ID. All FastStrings are stored in a global hashtable to support fast O(1) comparison.

It is also associated with a lazy reference to the Z-encoding of this string which is used by the compiler internally.

Constructors

Instances14Eq, Data, Show, IsString, Semigroup, Monoid, …
classclass Outputable a where
#

Class designating that some type has an SDoc representation

Methods

Instances828Outputable, …
datadata Bag a
#
Instances11Functor, Foldable, Traversable, IsList, Data, Semigroup, …
  • Functor BagDefined in ghc-9.10.3 · GHC.Data.Bag
  • Foldable BagDefined in ghc-9.10.3 · GHC.Data.Bag
  • Traversable BagDefined in ghc-9.10.3 · GHC.Data.Bag
  • IsList (Bag a)Defined in ghc-9.10.3 · GHC.Data.Bag
  • Data a => Data (Bag a)Defined in ghc-9.10.3 · GHC.Data.Bag
  • Semigroup (Bag a)Defined in ghc-9.10.3 · GHC.Data.Bag
  • Monoid (Bag a)Defined in ghc-9.10.3 · GHC.Data.Bag
  • NFData a => NFData (Bag a)Defined in ghc-9.10.3 · GHC.Data.Bag
  • Outputable a => Outputable (Bag a)Defined in ghc-9.10.3 · GHC.Data.Bag
  • ToHie a => ToHie (Bag a)Defined in ghc-9.10.3 · GHC.Iface.Ext.Ast
  • type Item (Bag a) = aDefined in ghc-9.10.3 · GHC.Data.Bag
typetype Id = Var
#

Identifier

datadata Type
#

Constructors

  • TyVarTy Var

    Vanilla type or kind variable (*never* a coercion variable)

  • AppTy Type Type

    Type application to something other than a TyCon. Parameters:

    1) Function: must not be a TyConApp or CastTy, must be another AppTy, or TyVarTy See Note [Respecting definitional equality] (EQ1) about the no CastTy requirement

    2) Argument type

  • TyConApp TyCon [KindOrType]

    Application of a TyCon, including newtypes and synonyms. Invariant: saturated applications of FunTyCon must use FunTy and saturated synonyms must use their own constructors. However, unsaturated FunTyCons do appear as TyConApps. Parameters:

    1) Type constructor being applied to.

    2) Type arguments. Might not have enough type arguments here to saturate the constructor. Even type synonyms are not necessarily saturated; for example unsaturated type synonyms can appear as the right hand side of a type synonym.

  • ForAllTy !ForAllTyBinder Type

    A Π type. See Note [Why ForAllTy can quantify over a coercion variable] INVARIANT: If the binder is a coercion variable, it must be mentioned in the Type. See Note [Unused coercion variable in ForAllTy]

  • FunTy

    FUN m t1 t2 Very common, so an important special case See Note [Function types]

  • LitTy TyLit

    Type literals are similar to type constructors.

  • CastTy Type KindCoercion

    A kind cast. The coercion is always nominal. INVARIANT: The cast is never reflexive (EQ2) INVARIANT: The Type is not a CastTy (use TransCo instead) (EQ3) INVARIANT: The Type is not a ForAllTy over a tyvar (EQ4) See Note [Respecting definitional equality]

  • CoercionTy Coercion

    Injection of a Coercion into a type This should only ever be used in the RHS of an AppTy, in the list of a TyConApp, when applying a promoted GADT data constructor

Instances3Data, Outputable, Eq
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
valuetyConUnique :: TyCon -> Unique
#

A Unique of this TyCon. Invariant: identical to Unique of Name stored in tyConName field.

valuetyConRoles :: TyCon -> [Role]
#

The role for each type variable This list has length = tyConArity See also Note [TyCon Role signatures]

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

Instances4Eq, Data, Ord, Outputable
datadata Origin
#

Was this piece of code user-written or generated by the compiler?

See Note [Generated code and pattern-match checking].

Instances3Eq, Data, Outputable
newtypenewtype IORef a
#

A mutable variable in the IO monad.

Example11 expressions
import GHC.Internal.Data.IORefr <- newIORef 0readIORef r0writeIORef r 1readIORef r1atomicWriteIORef r 2readIORef r2modifyIORef' r (+ 1)readIORef r3atomicModifyIORef' r (\a -> (a + 1, ()))readIORef r4

See also STRef and Control.Concurrent.MVar.MVar.

Instances5NFData1, MonadState, Eq, NFData, CommandMonad
  • NFData1 IORefDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • MonadIO m => MonadState s (ReaderT (IORef s) m)Defined in haskeline-0.8.2.1 · System.Console.Haskeline.Monads
  • Eq (IORef a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IORef

    Pointer equality.

  • NFData (IORef a)Defined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Only strict in the reference and not the referenced value.

  • (MonadIO m, MonadMask m) => CommandMonad (InputCmdT m)Defined in haskeline-0.8.2.1 · System.Console.Haskeline.InputT
classclass Functor f => Applicative (f :: Type -> Type) where
#

A functor with application, providing operations to

  • embed pure expressions (pure), and

  • sequence computations and combine their results (<*> and liftA2).

A minimal complete definition must include implementations of pure and of either <*> or liftA2. If it defines both, then they must behave the same as their default definitions:

(<*>) = liftA2 id
liftA2 f x y = f Prelude.<$> x <*> y

Further, any definition must satisfy the following:

Identity
pure id <*> v = v
Composition
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
Homomorphism
pure f <*> pure x = pure (f x)
Interchange
u <*> pure y = pure ($ y) <*> u

The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:

As a consequence of these laws, the Functor instance for f will satisfy

It may be useful to note that supposing

forall x y. p (q x y) = f x . g y

it follows from the above that

liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v

If f is also a Monad, it should satisfy

(which implies that pure and <*> satisfy the applicative functor laws).

Methods

  • pure :: a -> f a

    Lift a value into the Structure.

    Examples
    Example1 expression
    pure 1 :: Maybe IntJust 1
    Example1 expression
    pure 'z' :: [Char]"z"
    Example1 expression
    pure (pure ":D") :: Maybe [String]Just [":D"]
  • (<*>) :: f (a -> b) -> f a -> f binfixl 4

    Sequential application.

    A few functors support an implementation of <*> that is more efficient than the default one.

    Example

    Used in combination with (Data.Functor.<$>), (<*>) can be used to build a record.

    Example1 expression
    data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
    Example3 expressions
    produceFoo :: Applicative f => f FooproduceBar :: Applicative f => f BarproduceBaz :: Applicative f => f Baz
    Example2 expressions
    mkState :: Applicative f => f MyStatemkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
  • liftA2 :: (a -> b -> c) -> f a -> f b -> f c

    Lift a binary function to actions.

    Some functors support an implementation of liftA2 that is more efficient than the default one. In particular, if fmap is an expensive operation, it is likely better to use liftA2 than to fmap over the structure and then use <*>.

    This became a typeclass method in 4.10.0.0. Prior to that, it was a function defined in terms of <*> and fmap.

    Example
    Example1 expression
    liftA2 (,) (Just 3) (Just 5)Just (3,5)
    Example1 expression
    liftA2 (+) [1, 2, 3] [4, 5, 6][5,6,7,6,7,8,7,8,9]
  • (*>) :: f a -> f b -> f binfixl 4

    Sequence actions, discarding the value of the first argument.

    Examples

    If used in conjunction with the Applicative instance for Maybe, you can chain Maybe computations, with a possible "early return" in case of Nothing.

    Example1 expression
    Just 2 *> Just 3Just 3
    Example1 expression
    Nothing *> Just 3Nothing

    Of course a more interesting use case would be to have effectful computations instead of just returning pure values.

    Example4 expressions
    import Data.Charimport GHC.Internal.Text.ParserCombinators.ReadPlet p = string "my name is " *> munch1 isAlpha <* eofreadP_to_S p "my name is Simon"[("Simon","")]
  • (<*) :: f a -> f b -> f ainfixl 4

    Sequence actions, discarding the value of the second argument.

Instances163Applicative, …
classclass IsOutput doc where
#

A superclass for IsLine and IsDoc that provides an identity, empty, as well as access to the shared SDocContext.

See Note [The outputable class hierarchy] for more details.

Methods

Instances3IsOutput
datadata PrimRep
#

A PrimRep is an abstraction of a non-void type. (Use PrimRepOrVoidRep if you want void types too.) It contains information that the code generator needs in order to pass arguments, return results, and store values of this type. See also Note [RuntimeRep and PrimRep] in GHC.Types.RepType and Note [VoidRep] in GHC.Types.RepType.

Constructors

Instances6Eq, Data, Ord, Show, Outputable, Binary
newtypenewtype LexicalFastString
#

Lexical FastString

This is a simple FastString wrapper with an Ord instance using lexicalCompareFS (i.e. which compares FastStrings on their String representation). Hence it is deterministic from one run to the other.

Instances6Eq, Data, Ord, Show, Outputable, Binary
value(<$>) :: Functor f => (a -> b) -> f a -> f b
#

An infix synonym for fmap.

The name of this operator is an allusion to Prelude.$. Note the similarities between their types:

 ($)  ::              (a -> b) ->   a ->   b
(<$>) :: Functor f => (a -> b) -> f a -> f b

Whereas Prelude.$ is function application, <$> is function application lifted over a Functor.

Examples

Convert from a Maybe Int to a Maybe String using show:

Example1 expression
show <$> NothingNothing
Example1 expression
show <$> Just 3Just "3"

Convert from an Either Int Int to an Either Int String using show:

Example1 expression
show <$> Left 17Left 17
Example1 expression
show <$> Right 17Right "17"

Double each element of a list:

Example1 expression
(*2) <$> [1,2,3][2,4,6]

Apply even to the second element of a pair:

Example1 expression
even <$> (2,2)(2,True)
datadata GenModule unit
#

A generic module is a pair of a unit identifier and a ModuleName.

Constructors

Instances10Functor, Outputable, Uniquable, Eq, Data, Ord, …
datadata FindResult
#

The result of searching for an imported module.

NB: FindResult manages both user source-import lookups (which can result in Module) as well as direct imports for interfaces (which always result in InstalledModule).

Constructors

datadata HsExpr p
#

A Haskell expression.

Constructors

Instances32Outputable, HasType, ToHie, DisambECP, DisambInfixOp, Data, …
datadata HsOverLit p
#

Haskell Overloaded Literal

Instances8Eq, Data, Ord, Outputable, ToHie, Anno, …
datadata PromDataConInfo
#

Some promoted datacons signify extra info relevant to GHC. For example, the IntRep constructor of RuntimeRep corresponds to the IntRep constructor of PrimRep. This data structure allows us to store this information right in the TyCon. The other approach would be to look up things like RuntimeRep's PrimRep by known-key every time. See also Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType

Constructors

datadata PrimElemRep
#
Instances7Enum, Eq, Data, Ord, Show, Outputable, …
datadata GhcPass (c :: Pass) where
#

Used as a data type index for the hsSyn AST; also serves as a singleton type for Pass

Instances1206CvtFlag, Eq, CollectPass, MapXRec, UnXRec, OutputableBndr, …
datadata HoleFitPluginR
#

HoleFitPluginR adds a TcRef to hole fit plugins so that plugins can track internal state. Note the existential quantification, ensuring that the state cannot be modified from outside the plugin.

datadata TcGblEnv
#

TcGblEnv describes the top-level of the module at the point at which the typechecker is finished work. It is this structure that is handed on to the desugarer For state that needs to be updated during the typechecking phase and returned at end, use a TcRef (= IORef).

Constructors

Instances3Quasi, ContainsModule, MonadThings
typetype TcM = TcRn
#

Historical "type-checking monad" (now it's just TcRn).

classclass (IsOutput doc, IsLine (Line doc)) => IsDoc doc where
#

A class of types that represent a multiline document, with support for vertical composition.

See Note [HLine versus HDoc] and Note [The outputable class hierarchy] for more details.

Associated types

  • type family Line doc

Methods

  • line :: Line doc -> doc
  • ($$) :: doc -> doc -> doc

    Join two docs together vertically. If there is no vertical overlap it "dovetails" the two onto one line.

  • lines_ :: [Line doc] -> doc
  • vcat :: [doc] -> doc

    Concatenate docs vertically with dovetailing.

  • dualDoc :: SDoc -> HDoc -> doc

    Prints as either the given SDoc or the given HDoc, depending on which type the result is instantiated to. This should generally be avoided; see Note [dualLine and dualDoc] for details.

Instances2IsDoc
  • IsDoc HDocDefined in ghc-9.10.3 · GHC.Utils.Outputable
  • IsDoc SDocDefined in ghc-9.10.3 · GHC.Utils.Outputable
datadata HsGroup p
#

Haskell Group

A HsDecl is categorised into a HsGroup before being fed to the renamer.

Instances4Data, Outputable
newtypenewtype ModuleName
#

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

Instances11Eq, Data, Ord, Show, NFData, Outputable, …
valuedefaultPlugin :: Plugin
#

Default plugin: does nothing at all, except for marking that safe inference has failed unless -fplugin-trustworthy is passed. For compatibility reason you should base all your plugin definitions on this default value.

valuewithPlugins :: Monad m => Plugins -> PluginOperation m a -> a -> m a
#

Perform an operation by using all of the plugins in turn.

valuewithPlugins_ :: Monad m => Plugins -> ConstPluginOperation m a -> a -> m ()
#

Perform a constant operation by using all of the plugins in turn.

typetype CommandLineOption = String
#

Command line options gathered from the -PModule.Name:stuff syntax are given to you as this type

datadata SDocContext
#

Constructors

newtypenewtype UnitId
#

A UnitId identifies a built library in a database and is used to generate unique symbols, etc. It's usually of the form:

pkgname-1.2:libname+hash

These UnitId are provided to us via the -this-unit-id flag.

The library in question may be definite or indefinite; if it is indefinite, none of the holes have been filled (we never install partially instantiated libraries as we can cheaply instantiate them on-the-fly, cf VirtUnit). Put another way, an installed unit id is either fully instantiated, or not instantiated at all.

Constructors

Instances19Eq, Data, Ord, Show, NFData, Outputable, …
datadata IE pass
#

Imported or exported entity.

Constructors

Instances13Eq, Data, Outputable, ToHie, HasHaddock, Anno, …
  • Eq (IE GhcPs)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • Eq (IE GhcRn)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • Eq (IE GhcTc)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • Data (IE GhcPs)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • Data (IE GhcRn)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • Data (IE GhcTc)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • OutputableBndrId p => Outputable (IE (GhcPass p))Defined in ghc-9.10.3 · GHC.Hs.ImpExp · orphan
  • ToHie (IEContext (LocatedA (IE GhcRn)))Defined in ghc-9.10.3 · GHC.Iface.Ext.Ast
  • HasHaddock (LocatedA (IE GhcPs))Defined in ghc-9.10.3 · GHC.Parser.PostProcess.Haddock
  • HasHaddock (LocatedL [LocatedA (IE GhcPs)])Defined in ghc-9.10.3 · GHC.Parser.PostProcess.Haddock

    Only for module exports, not module imports.

    module M (a, b, c) where -- use on this [LIE GhcPs] import I (a, b, c) -- do not use here!

    Imports cannot have documentation comments anyway.

  • type Anno (LocatedA (IE (GhcPass p))) = SrcSpanAnnADefined in ghc-9.10.3 · GHC.Hs.ImpExp · orphan
  • type Anno (IE (GhcPass p)) = SrcSpanAnnADefined in ghc-9.10.3 · GHC.Hs.ImpExp · orphan
  • type Anno [LocatedA (IE (GhcPass p))] = SrcSpanAnnLDefined in ghc-9.10.3 · GHC.Hs.ImpExp · orphan
datadata EpAnn ann
#

The exact print annotations (EPAs) are kept in the HsSyn AST for the GhcPs phase. We do not always have EPAs though, only for code that has been parsed as they do not exist for generated code. This type captures that they may be missing.

A goal of the annotations is that an AST can be edited, including moving subtrees from one place to another, duplicating them, and so on. This means that each fragment must be self-contained. To this end, each annotated fragment keeps track of the anchor position it was originally captured at, being simply the start span of the topmost element of the ast fragment. This gives us a way to later re-calculate all Located items in this layer of the AST, as well as any annotations captured. The comments associated with the AST fragment are also captured here.

The ann type parameter allows this general structure to be specialised to the specific set of locations of original exact print annotation elements. So for HsLet we have

type instance XLet GhcPs = EpAnn AnnsLet data AnnsLet = AnnsLet { alLet :: EpaLocation, alIn :: EpaLocation } deriving Data

The spacing between the items under the scope of a given EpAnn is normally derived from the original Anchor. But if a sub-element is not in its original position, the required spacing can be directly captured in the anchor_op field of the entry Anchor. This allows us to freely move elements around, and stitch together new AST fragments out of old ones, and have them still printed out in a precise way.

Constructors

  • EpAnn
    • entry :: !Anchor

      Base location for the start of the syntactic element holding the annotations.

    • anns :: !ann

      Annotations added by the Parser

    • comments :: !EpAnnComments

      Comments enclosed in the SrcSpan of the element this EpAnn is attached to

Instances146Functor, Eq, Semigroup, HasAnnotation, HasLoc, NoAnn, …
classclass NoAnn a where
#

Methods

  • noAnn :: a

    equivalent of mempty, but does not need Semigroup

Instances29NoAnn, …
classclass Outputable a => OutputableBndr a where
#

When we print a binder, we often want to print its type too. The OutputableBndr class encapsulates this idea.

Instances19OutputableBndr, …
newtypenewtype SDoc
#

Represents a pretty-printable document.

To display an SDoc, use printSDoc, printSDocLn, bufLeftRenderSDoc, or renderWithContext. Avoid calling runSDoc directly as it breaks the abstraction layer.

Instances8IsString, Outputable, IsLine, IsDoc, IsOutput, JsRender, …
familytype family Anno a
#
Instances103Anno, …
familytype family IdP p
#

Maps the "normal" id type for a given pass

Instances1IdP
classclass MapXRec p where
#

We can map over the underlying type contained in an XRec while preserving the annotation as is.

Methods

Instances1MapXRec
datadata NoExtField
#

A placeholder type for TTG extension points that are not currently unused to represent any particular value.

This should not be confused with DataConCantHappen, which are found in unused extension constructors and therefore should never be inhabited. In contrast, NoExtField is used in extension points (e.g., as the field of some constructor), so it must have an inhabitant to construct AST passes that manipulate fields with that extension point as their type.

Instances5Eq, Data, Ord, Outputable, ToHie
familytype family NoGhcTc p
#

See Note [NoGhcTc] in GHC.Hs.Extension. It has to be in this module because it is used like an extension point (in the data definitions of types that should be parameter-agnostic.

Instances1NoGhcTc
  • type NoGhcTc (GhcPass pass) = GhcPass (NoGhcTcPass pass)Defined in ghc-9.10.3 · GHC.Hs.Extension

    Marks that a field uses the GhcRn variant even when the pass parameter is GhcTc. Useful for storing HsTypes in GHC.Hs.Exprs, say, because HsType GhcTc should never occur. See Note [NoGhcTc]

classclass UnXRec p where
#

We can strip off the XRec to access the underlying data. See Note [XRec and SrcSpans in the AST]

Methods

Instances1UnXRec
familytype family XRec p a
#

GHC's L prefixed variants wrap their vanilla variant in this type family, to add SrcLoc info via Located. Other passes than GhcPass not interested in location information can define this as type instance XRec NoLocated a = a. See Note [XRec and SrcSpans in the AST]

Instances1XRec
classclass (NoGhcTcPass (NoGhcTcPass p) ~ NoGhcTcPass p, IsPass (NoGhcTcPass p)) => IsPass (p :: Pass) where
#

Allows us to check what phase we're in at GHC's runtime. For example, this class allows us to write > f :: forall p. IsPass p => HsExpr (GhcPass p) -> blah > f e = case ghcPass @p of > GhcPs -> ... in this RHS we have HsExpr GhcPs... > GhcRn -> ... in this RHS we have HsExpr GhcRn... > GhcTc -> ... in this RHS we have HsExpr GhcTc... which is very useful, for example, when pretty-printing. See Note [IsPass].

Methods

Instances3IsPass
datadata NewOrData
#

When we only care whether a data-type declaration is data or newtype, but not what constructors it has

Constructors

Instances3Eq, Data, Outputable
datadata Var
#

Variable

Essentially a typed Name, that may also contain some additional information about the Var and its use sites.

Instances15Data, Ord, NamedThing, Outputable, Uniquable, HasOccName, …
datadata HsSrcBang
#

Haskell Source Bang

Bangs on data constructor arguments as the user wrote them in the source code.

(HsSrcBang _ SrcUnpack SrcLazy) and (HsSrcBang _ SrcUnpack NoSrcStrict) (without StrictData) makes no sense, we emit a warning (in checkValidDataCon) and treat it like (HsSrcBang _ NoSrcUnpack SrcLazy)

Instances2Data, Outputable
datadata Sig pass
#

Signatures and pragmas

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata HsLocalBindsLR idL idR
#

Haskell Local Bindings with separate Left and Right identifier types

Bindings in a let expression or a where clause

Constructors

Instances6ToHie, Data, Outputable
datadata FixitySig pass
#

Fixity Signature

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata HsBindLR idL idR
#

Haskell Binding with separate Left and Right id's

Constructors

  • FunBind

    Function-like Binding

    FunBind is used for both functions f x = e and variables f = x -> e and strict variables !x = x + 1

    Reason 1: Special case for type inference: see GHC.Tc.Gen.Bind.tcMonoBinds.

    Reason 2: Instance decls can only have FunBinds, which is convenient. If you change this, you'll need to change e.g. rnMethodBinds

    But note that the form f :: a->a = ... parses as a pattern binding, just like (f :: a -> a) = ...

    Strict bindings have their strictness recorded in the SrcStrictness of their MatchContext. See Note [FunBind vs PatBind] for details about the relationship between FunBind and PatBind.

    AnnKeywordIds

  • PatBind

    Pattern Binding

    The pattern is never a simple variable; That case is done by FunBind. See Note [FunBind vs PatBind] for details about the relationship between FunBind and PatBind.

  • VarBind

    Variable Binding

    Dictionary binding and suchlike. All VarBinds are introduced by the type checker

  • PatSynBind (XPatSynBind idL idR) (PatSynBind idL idR)

    Patterns Synonym Binding

  • XHsBindsLR !(XXHsBindsLR idL idR)
Instances8HasType, ToHie, Data, Outputable, Anno, …
datadata HsMultAnn pass
#

Multiplicity annotations, on binders, are always resolved (to a unification variable if there is no annotation) during type-checking. The resolved multiplicity is stored in the extension fields.

Constructors

Instances3Data
datadata HsValBindsLR idL idR
#

Haskell Value bindings with separate Left and Right identifier types (not implicit parameters) Used for both top level and nested bindings May contain pattern synonym bindings

Constructors

  • ValBinds (XValBinds idL idR) (LHsBindsLR idL idR) [LSig idR]

    Value Bindings In

    Before renaming RHS; idR is always RdrName Not dependency analysed Recursive by default

  • XValBindsLR !(XXValBindsLR idL idR)

    Value Bindings Out

    After renaming RHS; idR can be Name or Id Dependency analysed, later bindings in the list may depend on earlier ones.

Instances6ToHie, Data, Outputable
datadata IPBind id
#

Implicit parameter bindings.

Constructors

Instances6Data, Outputable, ToHie, Anno
typetype LHsBindLR idL idR = XRec idL (HsBindLR idL idR)
#

Located Haskell Binding with separate Left and Right identifier types

typetype LHsBindsLR idL idR = Bag (LHsBindLR idL idR)
#

Located Haskell Bindings with separate Left and Right identifier types

typetype LSig pass = XRec pass (Sig pass)
#

Located Signature

datadata PatSynBind idL idR
#

Pattern Synonym binding

Constructors

Instances6ToHie, Data, Outputable
datadata RecordPatSynField pass
#

Record Pattern Synonym Field

Constructors

Instances5Data, Outputable, ToHie
datadata HsDecl p
#

A Haskell Declaration

Constructors

Instances7Data, Outputable, HasHaddock, Anno, …
datadata AnnDecl pass
#

Annotation Declaration

Instances6Data, Outputable, ToHie, Anno
datadata DerivStrategy pass
#

Which technique the user explicitly requested when deriving an instance.

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata SpliceDecoration
#

A splice can appear with various decorations wrapped around it. This data type captures explicitly how it was originally written, for use in the pretty printer.

Constructors

Instances4Eq, Data, Show, Outputable
datadata ForeignExport pass
#
Instances5Data, Outputable, ToHie
datadata ForeignImport pass
#
Instances5Data, Outputable, ToHie
datadata TyClDecl pass
#

A type or class declaration.

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata FamilyInfo pass
#

Constructors

Instances5Data, Outputable, ToHie
datadata InstDecl pass
#
Instances6Data, Outputable, ToHie, Anno
datadata ClsInstDecl pass
#

Class Instance Declaration - AnnKeywordId : AnnInstance, AnnWhere, AnnOpen,AnnClose, For details on above see Note [exact print annotations] in GHC.Parser.Annotation

Instances6Data, Outputable, ToHie, Anno
datadata ConDecl pass
#
data T b = forall a. Eq a => MkT a b
  MkT :: forall b a. Eq a => MkT a b

data T b where
     MkT1 :: Int -> T Int

data T = Int MkT Int
       | MkT2

data T a where
     Int MkT Int :: T Int

data Constructor Declaration

Constructors

Instances7Data, Outputable, ToHie, HasHaddock, Anno, …
datadata DataDefnCons a
#

Whether a data-type declaration is data or newtype, and its constructors.

Constructors

Instances7Functor, Foldable, Traversable, Eq, Data, HasLoc, …
newtypenewtype DataFamInstDecl pass
#

Data Family Instance Declaration

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata DerivClauseTys pass
#

The types mentioned in a single deriving clause. This can come in two forms, DctSingle or DctMulti, depending on whether the types are surrounded by enclosing parentheses or not. These parentheses are semantically different than HsParTy. For example, deriving () means "derive zero classes" rather than "derive an instance of the 0-tuple".

DerivClauseTys use LHsSigType because deriving clauses can mention type variables that aren't bound by the datatype, e.g.

data T b = ... deriving (C [a])

should produce a derived instance for C [a] (T b).

Constructors

Instances7Data, Outputable, ToHie, HasHaddock, Anno, …
datadata DefaultDecl pass
#

Default Declaration

Instances6Data, Outputable, ToHie, Anno
datadata DerivDecl pass
#

Stand-alone 'deriving instance' declaration

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata DocDecl pass
#

Documentation comment Declaration

Instances4Data, Outputable, ToHie, Anno
datadata FamEqn pass rhs
#

Family Equation

One equation in a type family instance declaration, data family instance declaration, or type family default. See Note [Type family instance declarations in HsSyn] See Note [Family instance declaration binders]

Constructors

Instances10Data, HasLoc, ToHie, Anno, …
datadata FamilyDecl pass
#
Instances6Data, Outputable, ToHie, Anno
datadata FamilyResultSig pass
#
Instances5Data, ToHie, Anno
datadata ForeignDecl pass
#
Instances6Data, Outputable, ToHie, Anno
datadata HsConDeclGADTDetails pass
#

The arguments in a GADT constructor. Unlike Haskell98-style constructors, GADT constructors cannot be declared with infix syntax. As a result, we do not use HsConDetails here, as InfixCon would be an unrepresentable state. (There is a notion of infix GADT constructors for the purposes of derived Show instances—see Note [Infix GADT constructors] in GHC.Tc.TyCl—but that is an orthogonal concern.)

Instances4Data, ToHie
datadata HsDataDefn pass
#

Haskell Data type Definition

Constructors

Instances8Data, HasLoc, Outputable, ToHie, HasHaddock, …
datadata HsDerivingClause pass
#

A single deriving clause of a data declaration.

Constructors

Instances9Data, Outputable, ToHie, HasHaddock, Anno, …
typetype HsFamEqnPats pass = [LHsTypeArg pass]
#

HsFamEqnPats represents patterns on the left-hand side of a type instance, e.g. `type instance F k (a :: k) = a` has patterns `k` and `(a :: k)`.

HsFamEqnPats used to be called HsTyPats but it was renamed to avoid confusion with a different notion of type patterns, see #23657.

datadata RuleDecl pass
#

Rule Declaration

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata RuleDecls pass
#

Rule Declarations

Instances6Data, Outputable, ToHie, Anno
datadata InjectivityAnn pass
#

If the user supplied an injectivity annotation it is represented using InjectivityAnn. At the moment this is a single injectivity condition - see Note [Injectivity annotation]. `Located name` stores the LHS of injectivity condition. `[Located name]` stores the RHS of injectivity condition. Example:

type family Foo a b c = r | r -> a c where ...

This will be represented as "InjectivityAnn r [a, c]"

Instances5Data, ToHie, Anno
datadata RoleAnnotDecl pass
#

Role Annotation Declaration

Instances6Data, Outputable, ToHie, Anno
datadata RuleBndr pass
#

Rule Binder

Instances6Data, Outputable, ToHie, Anno
datadata SpliceDecl p
#
Instances6Data, Outputable, ToHie, Anno
datadata StandaloneKindSig pass
#
Instances7Data, Outputable, ToHie, Anno, …
datadata TyClGroup pass
#
Instances5Data, Outputable, ToHie
datadata TyFamInstDecl pass
#

Type Family Instance Declaration

Instances6Data, Outputable, ToHie, Anno
datadata WarnDecl pass
#

Warning pragma Declaration

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata WarnDecls pass
#

Warning pragma Declarations

Instances6Data, Outputable, ToHie, Anno
datadata ApplicativeArg idL
#

Applicative Argument

Constructors

Instances5Data, Outputable, ToHie
datadata StmtLR idL idR body
#

Exact print annotations when in qualifier lists or guards - AnnKeywordId : AnnVbar, AnnComma,AnnThen, AnnBy,AnnBy, AnnGroup,AnnUsing

Constructors

Instances20ToHie, Data, Outputable, Anno, …
datadata ArithSeqInfo id
#

Arithmetic Sequence Information

Constructors

Instances5Data, Outputable, ToHie
datadata HsStmtContext fn
#

Haskell Statement Context.

Constructors

Instances2Data, Outputable
datadata HsMatchContext fn
#

Haskell Match Context

Context of a pattern match. This is more subtle than it would seem. See Note [FunBind vs PatBind].

Constructors

Instances2Data, Outputable
datadata HsQuote p
#

Haskell (Untyped) Quote = Expr + Pat + Type + Var

Instances5Data, Outputable, ToHie
datadata DotFieldOcc p
#
Instances5Data, Outputable, Anno
typetype FailOperator id = Maybe (SyntaxExpr id)
#

The fail operator

This is used for `.. <-` "bind statements" in do notation, including non-monadic "binds" in applicative.

The fail operator is 'Just expr' if it potentially fail monadically. if the pattern match cannot fail, or shouldn't fail monadically (regular incomplete pattern exception), it is Nothing.

See Note [Monad fail : Rebindable syntax, overloaded strings] for the type of expression in the Just case, and why it is so.

See Note [Failing pattern matches in Stmts] for which contexts for 'BindStmt's should use the monadic fail and which shouldn't.

newtypenewtype FieldLabelStrings p
#

Constructors

Instances7Data, Outputable, OutputableBndr, Anno, …
datadata GRHS p body
#

Guarded Right Hand Side.

Constructors

Instances10Data, ToHie, Anno, …
datadata GRHSs p body
#

Guarded Right-Hand Sides

GRHSs are used both for pattern bindings and for Matches

Constructors

Instances7Data, ToHie, …
datadata HsCmd id
#
Instances32Outputable, ToHie, DisambECP, Data, Anno, Body, …
datadata HsCmdTop p
#

Haskell Top-level Command

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata HsLit x
#

Haskell Literal

Constructors

Instances5Eq, Data, Outputable
datadata HsPragE p
#

A pragma, written as {-# ... #-}, that may appear within an expression.

Instances4Data, Outputable
datadata HsUntypedSplice id
#
Instances5Data, ToHie, Anno
datadata HsTupArg id
#

Haskell Tuple Argument

Constructors

Instances4Data, ToHie
typetype LGRHS id body = XRec id (GRHS id body)
#

Located Guarded Right-Hand Side

typetype LHsCmd id = XRec id (HsCmd id)
#

Located Haskell Command (for arrow syntax)

typetype LHsCmdTop p = XRec p (HsCmdTop p)
#

Top-level command, introducing a new arrow. This may occur inside a proc (where the stack is empty) or as an argument of a command-forming operator.

Located Haskell Top-level Command

datadata LHsRecUpdFields p where
#

Haskell Record Update Fields.

Instances3Data
typetype LHsTupArg id = XRec id (HsTupArg id)
#

Located Haskell Tuple Argument

HsTupArg is used for tuple sections (,a,) is represented by ExplicitTuple [Missing ty1, Present a, Missing ty3] Which in turn stands for (x:ty1 y:ty2. (x,a,y))

typetype LStmt id body = XRec id (StmtLR id id body)
#

Located do block Statement

typetype LStmtLR idL idR body = XRec idL (StmtLR idL idR body)
#

Located Statement with separate Left and Right id's

datadata MatchGroup p body
#

Constructors

Instances7Data, ToHie, …
datadata Match p body
#

Constructors

Instances14ToHie, Data, Outputable, Anno, …
datadata ParStmtBlock idL idR
#

Parenthesised Statement Block

Constructors

Instances5Data, Outputable
typetype Stmt id body = StmtLR id id body
#

do block Statement

familytype family SyntaxExpr p
#

Syntax Expression

SyntaxExpr is represents the function used in interpreting rebindable syntax. In the parser, we have no information to supply; in the renamer, we have the name of the function (but see Note [Monad fail : Rebindable syntax, overloaded strings] for a wrinkle) and in the type-checker we have a more elaborate structure SyntaxExprTc.

In some contexts, rebindable syntax is not implemented, and so we have constructors to represent that possibility in both the renamer and typechecker instantiations.

E.g. (>>=) is filled in before the renamer by the appropriate Name for (>>=), and then instantiated by the type checker with its type args etc

Instances1SyntaxExpr
classclass WrapXRec p a where
#

The trivial wrapper that carries no additional information See Note [XRec and SrcSpans in the AST]

Methods

Instances1WrapXRec
datadata ConDeclField pass
#

Constructor Declaration Field

Instances8Data, Outputable, ToHie, Anno, …
familytype family XDo x
#
Instances3XDo
familytype family XFunBind x x'
#
Instances3XFunBind
  • type XFunBind (GhcPass pL) GhcPs = NoExtFieldDefined in ghc-9.10.3 · GHC.Hs.Binds · orphan
  • type XFunBind (GhcPass pL) GhcRn = NameSetDefined in ghc-9.10.3 · GHC.Hs.Binds · orphan

    After the renamer (but before the type-checker), the FunBind extension field contains the locally-bound free variables of this defn. See Note [Bind free vars]

  • type XFunBind (GhcPass pL) GhcTc = (HsWrapper, [CoreTickish])Defined in ghc-9.10.3 · GHC.Hs.Binds · orphan

    After the type-checker, the FunBind extension field contains the ticks to put on the rhs, if any, and a coercion from the type of the MatchGroup to the type of the Id. Example:

         f :: Int -> forall a. a -> a
         f x y = y
    

    Then the MatchGroup will have type (Int -> a' -> a') (with a free type variable a'). The coercion will take a CoreExpr of this type and convert it to a CoreExpr of type Int -> forall a'. a' -> a' Notice that the coercion captures the free a'.

familytype family XHsQTvs x
#
Instances3XHsQTvs
familytype family XHsWC x b
#
Instances3XHsWC
familytype family XLam x
#
Instances1XLam
familytype family XMG x b
#
Instances3XMG
familytype family XTick x
#
datadata HsTyLit pass
#

Haskell Type Literal

Instances4Data, Outputable
typetype ExportDoc pass = LHsDoc pass
#

A docstring attached to an export list item.

datadata IEWrappedName p
#

A name in an import or export specification which may have adornments. Used primarily for accurate pretty printing of ParsedSource, and API Annotation placement. The GHC.Parser.Annotation is the location of the adornment in the original source.

Constructors

Instances11Eq, Data, Outputable, OutputableBndr, HasOccName, ToHie, …
datadata IEWildcard
#

Wildcard in an import or export sublist, like the .. in import Mod ( T(Mk1, Mk2, ..) ).

Constructors

  • NoIEWildcard

    no wildcard in this list

  • IEWildcard Int

    wildcard after the given # of items in this list The Int is in the range [0..n], where n is the length of the list.

Instances2Eq, Data
  • Eq IEWildcardDefined in ghc-9.10.3 · Language.Haskell.Syntax.ImpExp
  • Data IEWildcardDefined in ghc-9.10.3 · Language.Haskell.Syntax.ImpExp
datadata ImportDecl pass
#

Import Declaration

A single Haskell import declaration.

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata IsBootInterface
#

Indicates whether a module name is referring to a boot interface (hs-boot file) or regular module (hs file). We need to treat boot modules specially when building compilation graphs, since they break cycles. Regular source files and signature files are treated equivalently.

Instances5Eq, Data, Ord, Show, Binary
typetype LIE pass = XRec pass (IE pass)
#

Located Import or Export

datadata OverLitVal
#

Overloaded Literal Value

Constructors

Instances4Eq, Data, Ord, Outputable
datadata Pat p
#

Constructors

Instances7Data, Outputable, HasType, ToHie, Anno, …
datadata HsConPatTyArg p
#

Type argument in a data constructor pattern, e.g. the @a in f (Just @a x) = ....

Constructors

Instances4Data, Outputable
datadata HsFieldBind lhs rhs
#

Haskell Field Binding

For details on above see Note [exact print annotations] in GHC.Parser.Annotation

Constructors

Instances7Functor, Foldable, Traversable, ToHie, Data, Outputable, …
datadata HsRecFields p arg
#

Haskell Record Fields

HsRecFields is used only for patterns and expressions (not data type declarations)

Instances5ToHie, Data, Outputable
datadata AmbiguousFieldOcc pass
#

Ambiguous Field Occurrence

Represents an *occurrence* of a field that is potentially ambiguous after the renamer, with the ambiguity resolved by the typechecker. We always store the RdrName that the user originally wrote, and store the selector function after the renamer (for unambiguous occurrences) or the typechecker (for ambiguous occurrences).

See Note [HsRecField and HsRecUpdField] in GHC.Hs.Pat. See Note [Located RdrNames] in GHC.Hs.Expr.

Instances8Data, Outputable, OutputableBndr, ToHie, Anno, …
typetype BangType pass = HsType pass
#

Bang Type

In the parser, strictness and packedness annotations bind more tightly than docstrings. This means that when consuming a BangType (and looking for HsBangTy) we must be ready to peer behind a potential layer of HsDocTy. See #15206 for motivation and getBangType for an example.

datadata FieldOcc pass
#

Field Occurrence

Represents an *occurrence* of a field. This may or may not be a binding occurrence (e.g. this type is used in ConDeclField and RecordPatSynField which bind their fields, but also in HsRecField for record construction and patterns, which do not).

We store both the RdrName the user originally wrote, and after the renamer we use the extension field to store the selector function.

Constructors

Instances10Eq, Data, Outputable, ToHie, OutputableBndr, Anno, …
datadata HsType pass
#

Haskell Type

Constructors

Instances15Data, Outputable, ToHie, DisambTD, HasHaddock, Anno, …
datadata HsArg p tm ty
#

Arguments in an expression/type after splitting

Constructors

Instances6Data, HasLoc, Outputable, ToHie
datadata HsArrow pass
#

Denotes the type of arrows in the surface language

Constructors

Instances4Data, Outputable
datadata HsBndrVis pass
#
Instances6CvtFlag, Data, OutputableBndrFlag, RepTV
datadata HsConDetails tyarg arg rec
#

Describes the arguments to a data constructor. This is a common representation for several constructor-related concepts, including:

  • The arguments in a Haskell98-style constructor declaration (see HsConDeclH98Details in GHC.Hs.Decls).

  • The arguments in constructor patterns in case/function definitions (see HsConPatDetails in GHC.Hs.Pat).

  • The left-hand side arguments in a pattern synonym binding (see HsPatSynDetails in GHC.Hs.Binds).

One notable exception is the arguments in a GADT constructor, which uses a separate data type entirely (see HsConDeclGADTDetails in GHC.Hs.Decls). This is because GADT constructors cannot be declared with infix syntax, unlike the concepts above (#18844).

Constructors

Instances3Data, Outputable, ToHie
datadata HsForAllTelescope pass
#

The type variable binders in an HsForAllTy. See also Note [Variable Specificity and Forall Visibility] in GHC.Tc.Gen.HsType.

Constructors

Instances4Data, Outputable
newtypenewtype HsIPName
#

These names are used early on to store the names of implicit parameters. They completely disappear after type-checking.

Constructors

Instances6Eq, Data, Outputable, OutputableBndr, ToHie, Anno
datadata HsOuterTyVarBndrs flag pass
#

The outermost type variables in a type that obeys the forall-or-nothing rule. See Note [forall-or-nothing rule].

Constructors

Instances6ToHie, Data, Outputable, Anno
datadata HsPatSigType pass
#

Types that can appear in pattern signatures, as well as the signatures for term-level binders in RULES. See Note [Pattern signature binders and scoping].

This is very similar to HsSigWcType, but with slightly different semantics: see Note [HsType binders]. See also Note [The wildcard story for types].

Constructors

Instances5Data, Outputable, ToHie
datadata LHsQTyVars pass
#

Located Haskell Quantified Type Variables

Instances5Data, Outputable, ToHie
datadata HsScaled pass a
#

This is used in the syntax. In constructor declaration. It must keep the arrow representation.

Constructors

Instances5Data, ToHie, HasHaddock
  • Data thing => Data (HsScaled GhcPs thing)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • Data thing => Data (HsScaled GhcRn thing)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • Data thing => Data (HsScaled GhcTc thing)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • ToHie a => ToHie (HsScaled GhcRn a)Defined in ghc-9.10.3 · GHC.Iface.Ext.Ast
  • HasHaddock a => HasHaddock (HsScaled GhcPs a)Defined in ghc-9.10.3 · GHC.Parser.PostProcess.Haddock
datadata HsSigType pass
#

A type signature that obeys the forall-or-nothing rule. In other words, an LHsType that uses an HsOuterSigTyVarBndrs to represent its outermost type variable quantification. See Note [Representing type signatures].

Instances8Data, Outputable, ToHie, HasHaddock, Anno, …
datadata HsTyPat pass
#

Constructors

Instances5Data, Outputable, ToHie
datadata HsTyVarBndr flag pass
#

Haskell Type Variable Binder The flag annotates the binder. It is Specificity in places where explicit specificity is allowed (e.g. x :: forall {a} b. ...) or () in other places.

Constructors

Instances10ToHie, Data, NamedThing, Outputable, Anno, …
datadata HsWildCardBndrs pass thing
#

Haskell Wildcard Binders

Constructors

Instances7ToHie, Data, Outputable, HasHaddock, …
valuenoTypeArgs :: [Void]
#

An empty list that can be used to indicate that there are no type arguments allowed in cases where HsConDetails is applied to Void.

datadata HsModule p
#

Haskell Module

All we actually declare here is the top-level structure for a module.

Constructors

Instances3Data, Outputable, HasHaddock
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.

Constructors

Instances3Data, NamedThing, Outputable
typetype FastStringEnv a = UniqFM FastString a
#

A non-deterministic set of FastStrings. See Note [Deterministic UniqFM] in GHC.Types.Unique.DFM for explanation why it's not deterministic and why it matters. Use DFastStringEnv if the set eventually gets converted into a list or folded over in a way where the order changes the generated code.

newtypenewtype IOEnv env a
#
Instances22Quasi, GhcMonad, Monad, Functor, MonadFix, MonadFail, …
datadata TcRnMessage where
#

An error which might arise during typechecking/renaming.

Instances4Generic, Diagnostic, Rep, DiagnosticOpts
datadata PromotionErr
#
Instances3Generic, Outputable, Rep
typetype ErrCtxt = (Bool, TidyEnv -> ZonkM (TidyEnv, SDoc))
#

Additional context to include in an error message, e.g. "In the type signature ...", "In the ambiguity check for ...", etc.

typetype TcRef a = IORef a
#

Type alias for IORef; the convention is we'll use this for mutable bits of data in the typechecker which are updated during typechecking and returned at the end.

datadata CompleteMatch
#

A list of conlikes which represents a complete pattern match. These arise from COMPLETE signatures. See also Note [Implementation of COMPLETE pragmas].

Instances1Outputable
classclass HasOccName name where
#

Other names in the compiler add additional information to an OccName. This class provides a consistent way to access the underlying OccName.

Methods

Instances12HasOccName, …
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

Instances7Eq, Data, Ord, Show, ToJson, Outputable, …
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, …
typetype TcTyVar = Var
#

Type variable that might be a metavariable

typetype TyVar = Var
#

Type or kind Variable

datadata ImportAvails
#

ImportAvails summarises what was imported from where, irrespective of whether the imported things are actually used or not. It is used:

  • when processing the export list,

  • when constructing usage info for the interface file,

  • to identify the list of directly imported modules for initialisation purposes and for optimised overlap checking of family instances,

  • when figuring out what things are really unused

Constructors

  • ImportAvails
    • imp_mods :: ImportedMods

      Domain is all directly-imported modules

      See the documentation on ImportedModsVal in GHC.Unit.Module.Imported for the meaning of the fields.

      We need a full ModuleEnv rather than a ModuleNameEnv here, because we might be importing modules of the same name from different packages. (currently not the case, but might be in the future).

    • imp_direct_dep_mods :: InstalledModuleEnv ModuleNameWithIsBoot

      Home-package modules directly imported by the module being compiled.

    • imp_dep_direct_pkgs :: Set UnitId

      Packages directly needed by the module being compiled

    • imp_trust_own_pkg :: Bool

      Do we require that our own package is trusted? This is to handle efficiently the case where a Safe module imports a Trustworthy module that resides in the same package as it. See Note [Trust Own Package] in GHC.Rename.Names

    • imp_trust_pkgs :: Set UnitId

      This records the packages the current module needs to trust for Safe Haskell compilation to succeed. A package is required to be trusted if we are dependent on a trustworthy module in that package. See Note [Tracking Trust Transitively] in GHC.Rename.Names

    • imp_boot_mods :: InstalledModuleEnv ModuleNameWithIsBoot

      Domain is all modules which have hs-boot files, and whether we should import the boot version of interface file. Only used in one-shot mode to populate eps_is_boot.

    • imp_sig_mods :: [ModuleName]

      Signature modules below this one

    • imp_orphs :: [Module]

      Orphan modules below us in the import tree (and maybe including us for imported modules)

    • imp_finsts :: [Module]

      Family instance modules below us in the import tree (and maybe including us for imported modules)

datadata GenWithIsBoot mod
#

This data type just pairs a value mod with an IsBootInterface flag. In practice, mod is usually a Module or ModuleName'.

Instances8Functor, Foldable, Traversable, Eq, Ord, Show, …

Union two ImportAvails

This function is a key part of Import handling, basically for each import we create a separate ImportAvails structure and then union them all together with this function.

valueunsafeTcPluginTcM :: TcM a -> TcPluginM a
#

This function provides an escape for direct access to the TcM monad. It should not be used lightly, and the provided TcPluginM API should be favoured instead.

valuedePluginInit :: ()
#

Initialize plugin, when entering type-checker.

valuedePluginStop :: ()
#

Clean up after the plugin, when exiting the type-checker.

datadata FrontendResult
#

FrontendResult describes the result of running the frontend of a Haskell module. Currently one always gets a FrontendTypecheck, since running the frontend involves typechecking a program. hs-sig merges are not handled here.

This data type really should be in GHC.Driver.Env, but it needs to have a TcGblEnv which is only defined here.

datadata NameShape
#

A NameShape is a substitution on Names that can be used to refine the identities of a hole while we are renaming interfaces (see GHC.Iface.Rename). Specifically, a NameShape for ns_module_name A, defines a mapping from {A.T} (for some OccName T) to some arbitrary other Name.

The most intriguing thing about a NameShape, however, is how it's constructed. A NameShape is *implied* by the exported AvailInfos of the implementor of an interface: if an implementor of signature <H> exports M.T, you implicitly define a substitution from {H.T} to M.T. So a NameShape is computed from the list of AvailInfos that are exported by the implementation of a module, or successively merged together by the export lists of signatures which are joining together.

It's not the most obvious way to go about doing this, but it does seem to work!

NB: Can't boot this and put it in NameShape because then we start pulling in too many DynFlags things.

datadata RewriteEnv
#

A RewriteEnv carries the necessary context for performing rewrites (i.e. type family reductions and following filled-in metavariables) in the solver.

Constructors

  • RE
    • re_loc :: !CtLoc

      In which context are we rewriting?

      Type-checking plugins might want to use this location information when emitting new Wanted constraints when rewriting type family applications. This ensures that such Wanted constraints will, when unsolved, give rise to error messages with the correct source location.

    • re_flavour :: !CtFlavour
    • re_eq_rel :: !EqRel

      At what role are we rewriting?

      See Note [Rewriter EqRels] in GHC.Tc.Solver.Rewrite

    • re_rewriters :: !TcRef RewriterSet

      See Note [Wanteds rewrite Wanteds]

typetype RnM = TcRn
#

Historical "renaming monad" (now it's just TcRn).

For rewriting type family applications, a type-checking plugin provides a function of this type for each type family TyCon.

The function is provided with the current set of Given constraints, together with the arguments to the type family. The type family application will always be fully saturated.

datadata TcPluginSolveResult
#

Result of running a solver plugin.

Constructors

  • TcPluginSolveResult
    • tcPluginInsolubleCts :: [Ct]

      Insoluble constraints found by the plugin.

      These constraints will be added to the inert set, and reported as insoluble to the user.

    • tcPluginSolvedCts :: [(EvTerm, Ct)]

      Solved constraints, together with their evidence.

      These are removed from the inert set, and the evidence for them is recorded.

    • tcPluginNewCts :: [Ct]

      New constraints that the plugin wishes to emit.

      These will be added to the work list.

patternpattern TcPluginContradiction :: [Ct] -> TcPluginSolveResult
#

The plugin found a contradiction. The returned constraints are removed from the inert set, and recorded as insoluble.

The returned list of constraints should never be empty.

patternpattern TcPluginOk :: [(EvTerm, Ct)] -> [Ct] -> TcPluginSolveResult
#

The plugin has not found any contradictions,

The first field is for constraints that were solved. The second field contains new work, that should be processed by the constraint solver.

datadata ForeignSrcLang
#

Foreign formats supported by GHC via TH

Constructors

Instances5Eq, Show, Generic, Binary, Rep
datadata GenUnit uid
#

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

1) It can be a RealUnit, in which case we just have a DefUnitId that uniquely identifies some fully compiled, installed library we have on disk.

2) It can be an VirtUnit. 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 InstantiatedUnit, which explicitly records the instantiation, so that we can substitute over it.

Constructors

  • RealUnit !(Definite uid)

    Installed definite unit (either a fully instantiated unit or a closed unit)

  • VirtUnit !(GenInstantiatedUnit uid)

    Virtual unit instantiated on-the-fly. It may be definite if all the holes are instantiated but we don't have code objects for it.

  • HoleUnit

    Fake hole unit

Instances11Data, Ord, Show, NFData, Outputable, Binary, …
datadata OccName
#

Occurrence Name

In this context that means: "classified (i.e. as a type name, value name, etc) but not qualified and not yet resolved"

Instances8Eq, Data, Ord, NFData, Outputable, Binary, …
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"

newtypenewtype Unique
#

Unique identifier.

The type of unique identifiers that are used in many places in GHC for fast ordering and equality tests. You should generate these with the functions from the UniqSupply module

These are sometimes also referred to as "keys" in comments in GHC.

Instances4Eq, Show, Outputable, Uniquable

Locate a module that was imported by the user. We have the module's name, and possibly a package name. Without a package name, this function will use the search path and the known exposed packages to find the module, if a package is specified then only that package is searched for the module.

classclass NamedThing a where
#

A class allowing convenient access to the Name of various datatypes

Methods

Instances20NamedThing, …
datadata DeltaPos
#

Spacing between output items when exact printing. It captures the spacing from the current print position on the page to the position required for the thing about to be printed. This is either on the same line in which case is is simply the number of spaces to emit, or it is some number of lines down, with a given column offset. The exact printing algorithm keeps track of the column offset pertaining to the current anchor position, so the deltaColumn is the additional spaces to add in this case. See https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations for details.

Constructors

Instances5Eq, Data, Ord, Show, Outputable
datadata EpaLocation' a
#

The anchor for an AnnKeywordId. The Parser inserts the EpaSpan variant, giving the exact location of the original item in the parsed source. This can be replaced by the EpaDelta version, to provide a position for the item relative to the end of the previous item in the source. This is useful when editing an AST prior to exact printing the changed one. The list of comments in the EpaDelta variant captures any comments between the prior output and the thing being marked here, since we cannot otherwise sort the relative order.

Instances10Semigroup, HasAnnotation, HasLoc, NoAnn, Eq, Data, …
datadata NoComments
#
Instances11Eq, Data, Ord, Show, Semigroup, HasAnnotation, …
classclass HasLoc a where
#

Methods

  • getHasLoc :: a -> SrcSpan

    conveniently calculate locations for things without locations attached

Instances10HasLoc, …
datadata AddEpAnn
#

Captures an annotation, storing the AnnKeywordId and its location. The parser only ever inserts EpaLocation fields with a RealSrcSpan being the original location of the annotation in the source file. The EpaLocation can also store a delta position if the AST has been modified and needs to be pretty printed again. The usual way an AddEpAnn is created is using the mj ("make jump") function, and then it can be inserted into the appropriate annotation.

Instances4Eq, Data, NoAnn, Outputable
datadata AnnContext
#

Exact print annotation for the Context data type.

Constructors

Instances6Data, NoAnn, Outputable, ToHie, HasHaddock
datadata AnnKeywordId
#

Exact print 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 otherwise captured in the AST.

The wiki page describing this feature is https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations https://gitlab.haskell.org/ghc/ghc/-/wikis/implementing-trees-that-grow/in-tree-api-annotations

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

Constructors

Instances6Eq, Data, Ord, Show, NoAnn, Outputable
datadata AnnList
#

Annotation for the "container" of a list. This captures surrounding items such as braces if present, and introductory keywords such as where.

Constructors

Instances7Eq, Data, NoAnn, Outputable, ToHie, HasHaddock, …
  • Eq AnnListDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Data AnnListDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • NoAnn AnnListDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Outputable AnnListDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • ToHie (LBooleanFormula (LocatedN Name))Defined in ghc-9.10.3 · GHC.Iface.Ext.Ast
  • ToHie (LocatedL [LocatedA (ConDeclField GhcRn)])Defined in ghc-9.10.3 · GHC.Iface.Ext.Ast
  • HasHaddock (LocatedL [LocatedA (IE GhcPs)])Defined in ghc-9.10.3 · GHC.Parser.PostProcess.Haddock

    Only for module exports, not module imports.

    module M (a, b, c) where -- use on this [LIE GhcPs] import I (a, b, c) -- do not use here!

    Imports cannot have documentation comments anyway.

datadata AnnListItem
#

Annotation for items appearing in a list. They can have one or more trailing punctuations items, such as commas or semicolons.

Instances125Eq, Semigroup, NoAnn, Outputable, HasType, HasHaddock, …
datadata AnnPragma
#

exact print annotation used for capturing the locations of annotations in pragmas.

Instances5Eq, Data, NoAnn, Outputable, ToHie
datadata AnnSortKey tag
#

Captures the sort order of sub elements for ValBinds, ClassDecl, ClsInstDecl

Constructors

Instances5Eq, Data, Semigroup, Monoid, Outputable
datadata BindTag
#

Used to track of interleaving of binds and signatures for ValBind

Instances5Eq, Data, Ord, Show, Outputable
  • Eq BindTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Data BindTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Ord BindTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Show BindTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Outputable BindTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
datadata DeclTag
#

Used to track interleaving of class methods, class signatures, associated types and associate type defaults in ClassDecl and ClsInstDecl.

Instances5Eq, Data, Ord, Show, Outputable
  • Eq DeclTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Data DeclTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Ord DeclTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Show DeclTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Outputable DeclTagDefined in ghc-9.10.3 · GHC.Parser.Annotation
datadata EpAnnComments
#

When we are parsing we add comments that belong a particular AST element, and print them together with the element, interleaving them into the output stream. But when editing the AST to move fragments around it is useful to be able to first separate the comments into those occurring before the AST element and those following it. The EpaCommentsBalanced constructor is used to do this. The GHC parser will only insert the EpaComments form.

Instances4Eq, Data, Semigroup, Outputable
datadata EpLayout
#

Layout information for declarations.

Constructors

  • EpExplicitBraces !(EpToken "{") !(EpToken "}")

    Explicit braces written by the user.

    class C a where { foo :: a; bar :: a }
    
  • EpVirtualBraces !Int

    Virtual braces inserted by the layout algorithm.

    class C a where
      foo :: a
      bar :: a
    
  • EpNoLayout

    Empty or compiler-generated blocks do not have layout information associated with them.

Instances1Data
datadata EpToken (tok :: Symbol)
#

A token stored in the syntax tree. For example, when parsing a let-expression, we store EpToken "let" and EpToken "in". The locations of those tokens can be used to faithfully reproduce (exactprint) the original program text.

Instances3Eq, Data, NoAnn
datadata EpUniToken (tok :: Symbol) (utok :: Symbol)
#

With UnicodeSyntax, there might be multiple ways to write the same token. For example an arrow could be either -> or →. This choice must be recorded in order to exactprint such tokens, so instead of EpToken "->" we introduce EpUniToken "->" "→".

Instances2Data, NoAnn
datadata EpaComment
#

Constructors

Instances10Eq, Data, Show, Semigroup, HasAnnotation, HasLoc, …
datadata HasE
#

Some template haskell tokens have two variants, one with an e the other not:

 [| or [e|
 [|| or [e||

This type indicates whether the e is present or not.

Instances4Eq, Data, Ord, Show
  • Eq HasEDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Data HasEDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Ord HasEDefined in ghc-9.10.3 · GHC.Parser.Annotation
  • Show HasEDefined in ghc-9.10.3 · GHC.Parser.Annotation
datadata IsUnicodeSyntax
#

Certain tokens can have alternate representations when unicode syntax is enabled. This flag is attached to those tokens in the lexer so that the original source representation can be reproduced in the corresponding EpAnnotation

Instances5Eq, Data, Ord, Show, Outputable
datadata NameAdornment
#

A NameAnn can capture the locations of surrounding adornments, such as parens or backquotes. This data type identifies what particular pair are being used.

Constructors

Instances4Eq, Data, Ord, Outputable
datadata NameAnn
#

exact print annotations for a RdrName. There are many kinds of adornment that can be attached to a given RdrName. This type captures them, as detailed on the individual constructors.

Instances6Eq, Data, NoAnn, Outputable, ToHie
datadata NoEpAnns
#
Instances16Eq, Data, Ord, NoAnn, Outputable, ToHie, …
datadata ParenType
#

Detail of the "brackets" used in an AnnParen exact print annotation.

Constructors

Instances5Eq, Data, Ord, Show, Outputable
datadata TrailingAnn
#

Captures the location of punctuation occurring between items, normally in a list. It is captured as a trailing annotation.

Instances3Eq, Data, Outputable
valuel2l :: (HasLoc a, HasAnnotation b) => a -> b
#

Helper function for converting annotation types. Discards any annotations

typetype Anchor = EpaLocation
#

An Anchor records the base location for the start of the syntactic element holding the annotations, and is used as the point of reference for calculating delta positions for contained annotations. It is also normally used as the reference point for the spacing of the element relative to its container. If the AST element is moved, that relationship is tracked in the anchor_op instead.

datadata BindingSite
#

BindingSite is used to tell the thing that prints binder what language construct is binding the identifier. This can be used to decide how much info to print. Also see Note [Binding-site specific printing] in GHC.Core.Ppr

Constructors

Instances1Eq
valuewhenPprDebug :: IsOutput doc => doc -> doc
#

Says what to do with -dppr-debug; without, return empty

newtypenewtype BufPos
#

0-based offset identifying the raw location in the StringBuffer.

The lexer increments the BufPos every time a character (UTF-8 code point) is read from the input buffer. As UTF-8 is a variable-length encoding and StringBuffer needs a byte offset for indexing, a BufPos cannot be used for indexing.

The parser guarantees that BufPos are monotonic. See #17632. This means that syntactic constructs that appear later in the StringBuffer are guaranteed to have a higher BufPos. Contrast that with RealSrcLoc, which does *not* make the analogous guarantee about higher line/column numbers.

This is due to #line and {-# LINE ... #-} pragmas that can arbitrarily modify RealSrcLoc. Notice how setSrcLoc and resetAlrLastLoc in GHC.Parser.Lexer update PsLoc, modifying RealSrcLoc but preserving BufPos.

Monotonicity makes BufPos useful to determine the order in which syntactic elements appear in the source. Consider this example (haddockA041 in the test suite):

haddockA041.hs {-# LANGUAGE CPP #-} -- | Module header documentation module Comments_and_CPP_include where #include "IncludeMe.hs"

IncludeMe.hs: -- | Comment on T data T = MkT -- ^ Comment on MkT

After the C preprocessor runs, the StringBuffer will contain a program that looks like this (unimportant lines at the beginning removed):

# 1 "haddockA041.hs" {-# LANGUAGE CPP #-} -- | Module header documentation module Comments_and_CPP_include where # 1 "IncludeMe.hs" 1 -- | Comment on T data T = MkT -- ^ Comment on MkT # 7 "haddockA041.hs" 2

The line pragmas inserted by CPP make the error messages more informative. The downside is that we can't use RealSrcLoc to determine the ordering of syntactic elements.

With RealSrcLoc, we have the following location information recorded in the AST: * The module name is located at haddockA041.hs:3:8-31 * The Haddock comment "Comment on T" is located at IncludeMe:1:1-17 * The data declaration is located at IncludeMe.hs:2:1-32

Is the Haddock comment located between the module name and the data declaration? This is impossible to tell because the locations are not comparable; they even refer to different files.

On the other hand, with BufPos, we have the following location information: * The module name is located at 846-870 * The Haddock comment "Comment on T" is located at 898-915 * The data declaration is located at 916-928

Aside: if you're wondering why the numbers are so high, try running ghc -E haddockA041.hs and see the extra fluff that CPP inserts at the start of the file.

For error messages, BufPos is not useful at all. On the other hand, this is exactly what we need to determine the order of syntactic elements: 870 < 898, therefore the Haddock comment appears *after* the module name. 915 < 916, therefore the Haddock comment appears *before* the data declaration.

We use BufPos in in GHC.Parser.PostProcess.Haddock to associate Haddock comments with parts of the AST using location information (#17544).

Constructors

Instances4Eq, Data, Ord, Show
  • Eq BufPosDefined in ghc-9.10.3 · GHC.Types.SrcLoc
  • Data BufPosDefined in ghc-9.10.3 · GHC.Types.SrcLoc
  • Ord BufPosDefined in ghc-9.10.3 · GHC.Types.SrcLoc
  • Show BufPosDefined in ghc-9.10.3 · GHC.Types.SrcLoc
datadata PsLoc
#

A location as produced by the parser. Consists of two components:

  • The location in the file, adjusted for #line and {-# LINE ... #-} pragmas (RealSrcLoc)

  • The location in the string buffer (BufPos) with monotonicity guarantees (see #17632)

Instances3Eq, Ord, Show
  • Eq PsLocDefined in ghc-9.10.3 · GHC.Types.SrcLoc
  • Ord PsLocDefined in ghc-9.10.3 · GHC.Types.SrcLoc
  • Show PsLocDefined in ghc-9.10.3 · GHC.Types.SrcLoc

Tests whether the first span "contains" the other span, meaning that it covers at least as much source code. True where spans are equal.

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

valueleftmostColumn :: Int
#

Indentation level is 1-indexed, so the leftmost column is 1.

Test for definitions internally generated by GHC. This predicate is used to suppress printing of internal definitions in some debug prints

valueisSymOcc :: OccName -> Bool
#

Test if the OccName is that for any operator (whether it is a data constructor or variable or whatever)

valueisValOcc :: OccName -> Bool
#

Value OccNamess are those that are either in the variable, field name or data constructor namespaces

valuemkDFunOcc
  1. :: String

    Typically the class and type glommed together e.g. OrdMaybe. Only used in debug mode, for extra clarity

  2. -> Bool

    Is this a hs-boot instance DFun?

  3. -> OccSet

    avoid these Occs

  4. -> OccName

    E.g. $f3OrdMaybe

#
valuemkInstTyTcOcc
  1. :: String

    Family name, e.g. Map

  2. -> OccSet

    avoid these Occs

  3. -> OccName
    R:Map
#

Derive a name for the representation type constructor of a data/newtype instance.

valuemkOccEnv_C
  1. :: (a -> a -> a)

    old -> new -> result

  2. -> [(OccName, a)]
  3. -> OccEnv a
#

Create an OccEnv from a list, combining different values with the same OccName using the combining function.

valuenonDetFoldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b
#

Fold over an OccEnv. Non-deterministic, unless the folding function is commutative (i.e. a1 f ( a2 f b ) == a2 f ( a1 f b ) for all a1, a2, b).

Haskell 98 encourages compilers to suppress warnings about unused names in a pattern if they start with _: this implements that test

classclass Uniquable a where
#

Class of things that we can obtain a Unique from

Methods

Instances36Uniquable, …
newtypenewtype HLine
#

Represents a single line of output that can be efficiently printed directly to a Handle (actually a BufHandle). See Note [SDoc versus HDoc] and Note [HLine versus HDoc] for more details.

Instances3IsLine, IsOutput, JsRender
datadata Boxity
#
Instances4Eq, Data, Outputable, Binary
  • Eq BoxityDefined in ghc-9.10.3 · Language.Haskell.Syntax.Basic
  • Data BoxityDefined in ghc-9.10.3 · Language.Haskell.Syntax.Basic
  • Outputable BoxityDefined in ghc-9.10.3 · GHC.Types.Basic · orphan
  • Binary BoxityDefined in ghc-9.10.3 · GHC.Types.Basic · orphan
valuenameIsLocalOrFrom :: Module -> Name -> Bool
#

Returns True if the name is (a) Internal (b) External but from the specified module (c) External but from the interactive package

The key idea is that False means: the entity is defined in some other module you can find the details (type, fixity, instances) in some interface file those details will be stored in the EPT or HPT

True means: the entity is defined in this module or earlier in the GHCi session you can find details (type, fixity, instances) in the TcGblEnv or TcLclEnv

The isInteractiveModule part is because successive interactions of a GHCi session each give rise to a fresh module (Ghci1, Ghci2, etc), but they all come from the magic interactive package; and all the details are kept in the TcLclEnv, TcGblEnv, NOT in the HPT or EPT. See Note [The interactive package] in GHC.Runtime.Context

valuenameStableString :: Name -> String
#

Get a string representation of a Name that's unique and stable across recompilations. Used for deterministic generation of binds for derived instances. eg. "$aeson_70dylHtv1FFGeai1IoxcQr$Data.Aeson.Types.Internal$String"

valuepprTickyName :: Module -> Name -> SDoc
#

Print a ticky ticky styled name

Module argument is the module to use for internal and system names. When printing the name in a ticky profile, the module name is included even for local things. However, ticky uses the format "x (M)" rather than "M.x". Hence, this function provides a separation from normal styling.

valuestableNameCmp :: Name -> Name -> Ordering
#

Compare Names lexicographically This only works for Names that originate in the source code or have been tidied.

typetype TyCoVar = Id
#

Type or Coercion Variable

valueisTyVar :: Var -> Bool
#

Is this a type-level (i.e., computationally irrelevant, thus erasable) variable? Satisfies isTyVar = not . isId.

datadata FinderOpts
#

Locations and information the finder cares about.

Should be taken from DynFlags via initFinderOpts.

Constructors

Instances1Show
newtypenewtype Definite unit
#

A definite unit (i.e. without any free module hole)

Constructors

Instances7Functor, Eq, Ord, Outputable, Uniquable, Binary, …
valuetoUnitId :: Unit -> UnitId
#

Return the UnitId of the Unit. For on-the-fly instantiated units, return the UnitId of the indefinite unit this unit is an instance of.

valuepunctuate
  1. :: IsLine doc
  2. => doc

    The punctuation

  3. -> [doc]

    The list that will have punctuation added between every adjacent pair of elements

  4. -> [doc]

    Punctuated list

#
classclass IsUnitId u where
#

Class for types that are used as unit identifiers (UnitKey, UnitId, Unit)

We need this class because we create new unit ids for virtual units (see VirtUnit) and they have to to be made from units with different kinds of identifiers.

Methods

Instances4IsUnitId
datadata GenInstantiatedUnit unit
#

An instantiated unit.

It identifies an indefinite library (with holes) that has been instantiated.

This unit may be indefinite or not (i.e. with remaining holes or not). If it is definite, we don't know if it has already been compiled and installed in a database. Nevertheless, we have a mechanism called "improvement" to try to match a fully instantiated unit with existing compiled and installed units: see Note [VirtUnit to RealUnit improvement].

An indefinite unit identifier pretty-prints to something like p[H=H,A=aimpl:A>] (p is the UnitId, and the brackets enclose the module substitution).

Constructors

Instances5Outputable, Binary, Eq, Ord
valuefsToUnit :: FastString -> Unit
#

Create a new simple unit identifier from a FastString. Internally, this is primarily used to specify wired-in unit identifiers.

valuemainUnitId :: UnitId
#

This is the package Id for the current program. It is the default package Id if you don't specify a package name. We don't add this prefix to symbol names, since there can be only one main package per program.

Generate a uniquely identifying hash (internal unit-id) for an instantiated unit.

This is a one-way function. If the indefinite unit has not been instantiated at all, we return its unit-id.

This hash is completely internal to GHC and is not used for symbol names or file paths. It is different from the hash Cabal would produce for the same instantiated unit.

Calculate the free holes of a Module. If this set is non-empty, this module was defined in an indefinite library that had required signatures.

If a module has free holes, that means that substitutions can operate on it; if it has no free holes, substituting over a module has no effect.

typetype Mult = Type
#

Mult is a type alias for Type.

Mult must contain Type because multiplicity variables are mere type variables (of kind Multiplicity) in Haskell. So the simplest implementation is to make Mult be Type.

Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon) - Many: GHC.Types.Many (= manyDataCon) - Multiplication: GHC.Types.MultMul (= multMulTyCon)

So that Mult feels a bit more structured, we provide pattern synonyms and smart constructors for these.

valuesetEnv :: env' -> IOEnv env' a -> IOEnv env a
#

Perform a computation with a different environment

valueupdEnv :: (env -> env') -> IOEnv env' a -> IOEnv env a
#

Perform a computation with an altered environment

datadata HoleSort
#

Used to indicate which sort of hole we have.

Constructors

  • ExprHole HoleExprRef

    Either an out-of-scope variable or a "true" hole in an expression (TypedHoles). The HoleExprRef says where to write the the erroring expression for -fdefer-type-errors.

  • TypeHole

    A hole in a type (PartialTypeSignatures)

  • ConstraintHole

    A hole in a constraint, like @f :: (_, Eq a) => ... Differentiated from TypeHole because a ConstraintHole is simplified differently. See Note [Do not simplify ConstraintHoles] in GHC.Tc.Solver.

Instances1Outputable
datadata DelayedError
#

A delayed error, to be reported after constraint solving, in order to benefit from deferred unifications.

Constructors

Instances1Outputable
datadata Hole
#

A hole stores the information needed to report diagnostics about holes in terms (unbound identifiers or underscores) or in types (also called wildcards, as used in partial type signatures). See Note [Holes].

Constructors

Instances1Outputable
datadata NotConcreteError
#

Why did we require that a certain type be concrete?

Constructors

Instances1Outputable
datadata CtOrigin
#

Constructors

Instances1Outputable
datadata OverlapFlag
#

The semantics allowed for overlapping instances for a particular instance. See Note [Safe Haskell isSafeOverlap] in GHC.Core.InstEnv for a explanation of the isSafeOverlap field.

Instances4Eq, Data, Outputable, Binary
valuefoldlM_ :: (Monad m, Foldable t) => (a -> b -> m a) -> a -> t b -> m ()
#

Monadic version of foldl that discards its result

valuemapAccumLM
  1. :: (Monad m, Traversable t)
  2. => (acc -> x -> m (acc, y))

    combining function

  3. -> acc

    initial state

  4. -> t x

    inputs

  5. -> m (acc, t y)

    final state, outputs

#

Monadic version of mapAccumL

valuemapAndUnzip3M :: Monad m => (a -> m (b, c, d)) -> [a] -> m ([b], [c], [d])
#

mapAndUnzipM for triples

valuemapAndUnzip5M
  1. :: Monad m
  2. => a -> m (b, c, d, e, f)
  3. -> [a]
  4. -> m ([b], [c], [d], [e], [f])
#
valuepartitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])
#

Monadic version of partition

valueunlessM :: Monad m => m Bool -> m () -> m ()
#

Monadic version of unless, taking the condition in the monad

valuewhenM :: Monad m => m Bool -> m () -> m ()
#

Monadic version of when, taking the condition in the monad

valuezipWith3M :: Monad m => (a -> b -> c -> m d) -> [a] -> [b] -> [c] -> m [d]
#
valuezipWith3M_ :: Monad m => (a -> b -> c -> m d) -> [a] -> [b] -> [c] -> m ()
#
valuezipWith4M
  1. :: Monad m
  2. => a -> b -> c -> d -> m e
  3. -> [a]
  4. -> [b]
  5. -> [c]
  6. -> [d]
  7. -> m [e]
#

Default style for error messages, when we don't know NamePprCtx It's a bit of a hack because it doesn't take into account what's in scope Only used for desugarer warnings, and typechecker errors in interface sigs

valuehang
  1. :: SDoc

    The header

  2. -> Int

    Amount to indent the hung body

  3. -> SDoc

    The hung body, indented and placed below the header

  4. -> SDoc
#
valueaddErrCtxt :: SDoc -> TcM a -> TcM a
#

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

valueaddLandmarkErrCtxt :: SDoc -> TcM a -> TcM a
#

Add a fixed landmark message to the error context. A landmark message is always sure to be reported, even if there is a lot of context. It also doesn't count toward the maximum number of contexts reported.

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

Unconditionally dump some trace output

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

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

The accumulator is not updated if the action fails

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

Run thing_inside in an interleaved thread. It shares everything with the parent thread, so this is DANGEROUS.

It throws an error if the computation fails

It's used for lazily type-checking interface signatures, which is pretty benign.

See Note [Masking exceptions in forkM]

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

initIfaceLoad can be used when there's no chance that the action will call typecheckIface when inside a module loop and hence tcIfaceGlobal.

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

This is used when we are doing to call typecheckModule on an ModIface, if it's part of a loop with some other modules then we need to use their IORef TypeEnv vars when typechecking but crucially not our own.

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

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

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

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

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

valuesetInGeneratedCode :: TcRn a -> TcRn a
#

Mark the inner computation as being done inside generated code.

See Note [Error contexts in generated code]

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

tcCollectingUsage thing_inside runs thing_inside and returns the usage information which was collected as part of the execution of thing_inside. Careful: tcCollectingUsage thing_inside itself does not report any usage information, it's up to the caller to incorporate the returned usage information into the larger context appropriately.

valuetcScalingUsage :: Mult -> TcM a -> TcM a
#

tcScalingUsage mult thing_inside runs thing_inside and scales all the usage information by mult.

valuemapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c])
#

The mapAndUnzipM function maps its first argument over a list, returning the result as a pair of lists. This function is mainly used with complicated data structures or a state monad.

valuefoldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
#

Left-to-right monadic fold over the elements of a structure.

Given a structure t with elements (a, b, ..., w, x, y), the result of a fold with an operator function f is equivalent to:

foldlM f z t = do
    aa <- f z a
    bb <- f aa b
    ...
    xx <- f ww x
    yy <- f xx y
    return yy -- Just @return z@ when the structure is empty

For a Monad m, given two functions f1 :: a -> m b and f2 :: b -> m c, their Kleisli composition (f1 >=> f2) :: a -> m c is defined by:

(f1 >=> f2) a = f1 a >>= f2

Another way of thinking about foldlM is that it amounts to an application to z of a Kleisli composition:

foldlM f z t =
    flip f a >=> flip f b >=> ... >=> flip f x >=> flip f y $ z

The monadic effects of foldlM are sequenced from left to right.

If at some step the bind operator (>>=) short-circuits (as with, e.g., mzero in a MonadPlus), the evaluated effects will be from an initial segment of the element sequence. If you want to evaluate the monadic effects in right-to-left order, or perhaps be able to short-circuit after processing a tail of the sequence of elements, you'll need to use foldrM instead.

If the monadic effects don't short-circuit, the outermost application of f is to the rightmost element y, so that, ignoring effects, the result looks like a left fold:

((((z `f` a) `f` b) ... `f` w) `f` x) `f` y
Examples

Basic usage:

Example2 expressions
let f a e = do { print e ; return $ e : a }foldlM f [] [0..3]0123[3,2,1,0]
valuefoldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
#

Right-to-left monadic fold over the elements of a structure.

Given a structure t with elements (a, b, c, ..., x, y), the result of a fold with an operator function f is equivalent to:

foldrM f z t = do
    yy <- f y z
    xx <- f x yy
    ...
    bb <- f b cc
    aa <- f a bb
    return aa -- Just @return z@ when the structure is empty

For a Monad m, given two functions f1 :: a -> m b and f2 :: b -> m c, their Kleisli composition (f1 >=> f2) :: a -> m c is defined by:

(f1 >=> f2) a = f1 a >>= f2

Another way of thinking about foldrM is that it amounts to an application to z of a Kleisli composition:

foldrM f z t = f y >=> f x >=> ... >=> f b >=> f a $ z

The monadic effects of foldrM are sequenced from right to left, and e.g. folds of infinite lists will diverge.

If at some step the bind operator (>>=) short-circuits (as with, e.g., mzero in a MonadPlus), the evaluated effects will be from a tail of the element sequence. If you want to evaluate the monadic effects in left-to-right order, or perhaps be able to short-circuit after an initial sequence of elements, you'll need to use foldlM instead.

If the monadic effects don't short-circuit, the outermost application of f is to the leftmost element a, so that, ignoring effects, the result looks like a right fold:

a `f` (b `f` (c `f` (... (x `f` (y `f` z))))).
Examples

Basic usage:

Example2 expressions
let f i acc = do { print i ; return $ i : acc }foldrM f [] [0..3]3210[0,1,2,3]
classclass Monad m => MonadIO (m :: Type -> Type) where
#

Monads in which IO computations may be embedded. Any monad built by applying a sequence of monad transformers to the IO monad will be an instance of this class.

Instances should satisfy the following laws, which state that liftIO is a transformer of monads:

Methods

  • liftIO :: IO a -> m a

    Lift a computation from the IO monad. This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations (i.e. IO is the base monad for the stack).

    Example
    import Control.Monad.Trans.State -- from the "transformers" library
    
    printState :: Show s => StateT s IO ()
    printState = do
      state <- get
      liftIO $ print state

    Had we omitted liftIO, we would have ended up with this error:

    • Couldn't match type ‘IO’ with ‘StateT s IO’
     Expected type: StateT s IO ()
       Actual type: IO ()

    The important part here is the mismatch between StateT s IO () and IO ().

    Luckily, we know of a function that takes an IO a and returns an (m a): liftIO, enabling us to run the program and see the expected results:

    > evalStateT printState "hello"
    "hello"
    
    > evalStateT printState 3
    3
    
Instances37MonadIO, …

The context for a representation-polymorphism check.

For example, when typechecking (a :: k) -> ..., we are checking the type a because it's the type of a term variable bound in a lambda, so we use FRRBinder.

Constructors

Instances1Outputable
classclass Monad m => MonadFix (m :: Type -> Type) where
#

Monads having fixed points with a 'knot-tying' semantics. Instances of MonadFix should satisfy the following laws:

Purity

mfix (return . h) = return (fix h)

Left shrinking (or Tightening)

mfix (\x -> a >>= \y -> f x y) = a >>= \y -> mfix (\x -> f x y)

Sliding

mfix (liftM h . f) = liftM h (mfix (f . h))

, for strict

h

.

Nesting

mfix (\x -> mfix (\y -> f x y)) = mfix (\x -> f x x)

This class is used in the translation of the recursive do notation supported by GHC and Hugs.

Methods

  • mfix :: (a -> m a) -> m a

    The fixed point of a monadic computation. mfix f executes the action f only once, with the eventual output fed back as the input. Hence f should not be strict, for then mfix f would diverge.

Instances55MonadFix, …
newtypenewtype NonDetFastString
#

Non-deterministic FastString

This is a simple FastString wrapper with an Ord instance using uniqCompareFS (i.e. which compares FastStrings on their Uniques). Hence it is not deterministic from one run to the other.

Instances6Eq, Data, Ord, Show, Outputable, Binary
valuemkChunkified
  1. :: ([a] -> a)

    "Small" constructor function, of maximum input arity mAX_TUPLE_SIZE

  2. -> [a]

    Possible "big" list of things to construct from

  3. -> a

    Constructed thing made possible by recursive decomposition

#

Lifts a "small" constructor into a "big" constructor by recursive decomposition

Is the given type definitely unlifted? See Type#type_classification for what an unlifted type is.

Panics on representation-polymorphic types; See mightBeUnliftedType for a more approximate predicate that behaves better in the presence of representation polymorphism.

valuefoldBag :: (r -> r -> r) -> (a -> r) -> r -> Bag a -> r
#
datadata AbsBinds
#

Typechecked, generalised bindings, used in the output to the type checker. See Note [AbsBinds].

Constructors

Instances1Data
  • Data AbsBindsDefined in ghc-9.10.3 · GHC.Hs.Instances · orphan
datadata SyntaxExprTc
#

An expression with wrappers, used for rebindable syntax

This should desugar to

syn_res_wrap $ syn_expr (syn_arg_wraps[0] arg0)
                        (syn_arg_wraps[1] arg1) ...

where the actual arguments come from elsewhere in the AST.

Instances3Data, Outputable, ToHie
valuenoExpr :: HsExpr (GhcPass p)
#

This is used for rebindable-syntax pieces that are too polymorphic for tcSyntaxOp (trS_fmap and the mzip in ParStmt)

datadata HsWrapper
#
Instances5Data, Semigroup, Monoid, Outputable, ToHie
  • Data HsWrapperDefined in ghc-9.10.3 · GHC.Tc.Types.Evidence
  • Semigroup HsWrapperDefined in ghc-9.10.3 · GHC.Tc.Types.Evidence

    The Semigroup instance is a bit fishy, since WpCompose, as a data constructor, is "syntactic" and not associative. Concretely, if a, b, and c aren't WpHole:

    (a <> b) <> c ?= a <> (b <> c)

    >

    (a `WpCompose` b) `WpCompose` c /= @ a `WpCompose` (b `WpCompose` c)

    However these two associations are are "semantically equal" in the sense that they produce equal functions when passed to GHC.HsToCore.Binds.dsHsWrapper.

  • Monoid HsWrapperDefined in ghc-9.10.3 · GHC.Tc.Types.Evidence
  • Outputable HsWrapperDefined in ghc-9.10.3 · GHC.Tc.Types.Evidence
  • ToHie (LocatedA HsWrapper)Defined in ghc-9.10.3 · GHC.Iface.Ext.Ast
datadata TyConFlavour tc
#

Paints a picture of what a TyCon represents, in broad strokes. This is used towards more informative error messages.

Instances5Functor, Eq, Data, NFData, Outputable
datadata GenReason
#

This metadata stores the information as to why was the piece of code generated It is useful for generating the right error context See Part 3 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do

Instances3Eq, Data, Outputable
datadata DoPmc
#

Whether to run pattern-match checks in generated code.

See Note [Generated code and pattern-match checking].

Instances3Eq, Data, Outputable
valueisId :: Var -> Bool
#

Is this a value-level (i.e., computationally relevant) Identifier? Satisfies isId = not . isTyVar.

classclass UnXRec p => CollectPass p where
#

This class specifies how to collect variable identifiers from extension patterns in the given pass. Consumers of the GHC API that define their own passes should feel free to implement instances in order to make use of functions which depend on it.

In particular, Haddock already makes use of this, with an instance for its DocNameI pass so that it can reuse the code in GHC for collecting binders.

Methods

Instances1CollectPass

Returns all the binding names of the decl. The first one is guaranteed to be the name of the decl. The first component represents all binding names except record fields; the second represents field occurrences. For record fields mentioned in multiple constructors, the SrcLoc will be from the first occurrence.

Each returned (Located name) has a SrcSpan for the whole declaration. See Note [SrcSpan for binders]

Should we treat this as an unlifted bind? This will be true for any bind that binds an unlifted variable, but we must be careful around AbsBinds. See Note [isUnliftedHsBind]. For usage information, see Note [Strict binds checks] is GHC.HsToCore.Binds.

Collect all record wild card binders in the given pattern.

These are all the variables bound in all (possibly nested) record wildcard patterns appearing inside the pattern.

See Note [Collecting implicit binders].

datadata CollectFlag p where
#

Indicate if evidence binders and type variable binders have to be collected.

This type enumerates the modes of collecting bound variables | evidence | type | term | ghc | | binders | variables | variables | pass | -------------------------------------------- CollNoDictBinders | no | no | yes | any | CollWithDictBinders | yes | no | yes | GhcTc | CollVarTyVarBinders | no | yes | yes | GhcRn |

See Note [Dictionary binders in ConPatOut]

Constructors

datadata Specificity
#

Whether an Invisible argument may appear in source Haskell.

Constructors

  • InferredSpec

    the argument may not appear in source Haskell, it is only inferred.

  • SpecifiedSpec

    the argument may appear in source Haskell, but isn't required.

Instances10Eq, Data, Ord, NFData, Binary, OutputableBndrFlag, …
datadata Coercion
#
Instances3Data, Outputable, Eq
typetype PostTcExpr = HsExpr GhcTc
#

Post-Type checking Expression

PostTcExpr is an evidence expression attached to the syntax tree by the type checker (c.f. postTcType).

valuepprWithCommas
  1. :: (a -> SDoc)

    The pretty printing function to use

  2. -> [a]

    The things to be pretty printed

  3. -> SDoc

    SDoc where the things have been pretty printed, comma-separated and finally packed into a paragraph.

#
valuelookupUniqSet :: Uniquable key => UniqSet key -> key -> Maybe key
#

What's the point you might ask? We might have changed an object without it's key changing. In which case this lookup makes sense.

typetype Arity = Int
#

The number of value arguments that can be applied to a value before it does "real work". So: fib 100 has arity 0 x -> fib x has arity 1 See also Note [Definition of arity] in GHC.Core.Opt.Arity

datadata NamespaceSpecifier
#

Optional namespace specifier for fixity signatures, WARNINIG and DEPRECATED pragmas.

Examples:

{-# WARNING in "x-partial" data Head "don't use this pattern synonym" #-} -- ↑ DataNamespaceSpecifier

{-# DEPRECATED type D "This type was deprecated" #-} -- ↑ TypeNamespaceSpecifier

infixr 6 data $ -- ↑ DataNamespaceSpecifier

Instances3Eq, Data, Outputable
datadata OverlapMode
#

Constructors

  • NoOverlap SourceText

    This instance must not overlap another NoOverlap instance. However, it may be overlapped by Overlapping instances, and it may overlap Overlappable instances.

  • Overlappable SourceText

    Silently ignore this instance if you find a more specific one that matches the constraint you are trying to resolve

    Example: constraint (Foo [Int]) instance Foo [Int] instance {-# OVERLAPPABLE #-} Foo [a]

    Since the second instance has the Overlappable flag, the first instance will be chosen (otherwise its ambiguous which to choose)

  • Overlapping SourceText

    Silently ignore any more general instances that may be used to solve the constraint.

    Example: constraint (Foo [Int]) instance {-# OVERLAPPING #-} Foo [Int] instance Foo [a]

    Since the first instance has the Overlapping flag, the second---more general---instance will be ignored (otherwise it is ambiguous which to choose)

  • Overlaps SourceText

    Equivalent to having both Overlapping and Overlappable flags.

  • Incoherent SourceText

    Behave like Overlappable and Overlapping, and in addition pick an arbitrary one if there are multiple matching candidates, and don't worry about later instantiation

    Example: constraint (Foo [b]) instance {-# INCOHERENT -} Foo [Int] instance Foo [a] Without the Incoherent flag, we'd complain that instantiating b would change which instance was chosen. See also Note [Incoherent instances] in GHC.Core.InstEnv

  • NonCanonical SourceText

    Behave like Incoherent, but the instance choice is observable by the program behaviour. See Note [Coherence and specialisation: overview].

    We don't have surface syntax for the distinction between Incoherent and NonCanonical instances; instead, the flag `-f{no-}specialise-incoherents` (on by default) controls whether INCOHERENT instances are regarded as Incoherent or NonCanonical.

Instances7Eq, Data, Outputable, Binary, ToHie, Anno, …
datadata Role
#

See Note [Roles] in GHC.Core.Coercion

Order of constructors matters: the Ord instance coincides with the *super*typing relation on roles.

Instances7Eq, Data, Ord, Outputable, Binary, Anno, …
  • Eq RoleDefined in ghc-9.10.3 · Language.Haskell.Syntax.Basic
  • Data RoleDefined in ghc-9.10.3 · Language.Haskell.Syntax.Basic
  • Ord RoleDefined in ghc-9.10.3 · Language.Haskell.Syntax.Basic
  • Outputable RoleDefined in ghc-9.10.3 · GHC.Core.Coercion.Axiom · orphan
  • Binary RoleDefined in ghc-9.10.3 · GHC.Core.Coercion.Axiom · orphan
  • type Anno (Maybe Role) = EpAnnCODefined in ghc-9.10.3 · GHC.Hs.Decls · orphan
  • type Anno (Maybe Role) = EpAnnCODefined in ghc-9.10.3 · GHC.Hs.Decls · orphan
valuecat :: [SDoc] -> SDoc
#

A paragraph-fill combinator. It's much like sep, only it keeps fitting things on one line until it can't fit any more.

valuefcat :: [SDoc] -> SDoc
#

This behaves like fsep, but it uses <> for horizontal composition rather than <+>

classclass OutputableP env a where
#

Outputable class with an additional environment value

See Note [The OutputableP class]

Methods

Instances45OutputableP, …
familytype family Line doc
#
Instances2Line
  • type Line HDoc = HLineDefined in ghc-9.10.3 · GHC.Utils.Outputable
  • type Line SDoc = SDocDefined in ghc-9.10.3 · GHC.Utils.Outputable
newtypenewtype HDoc
#

Represents a (possibly empty) sequence of lines that can be efficiently printed directly to a Handle (actually a BufHandle). See Note [SDoc versus HDoc] and Note [HLine versus HDoc] for more details.

Instances3IsDoc, IsOutput, Line
  • IsDoc HDocDefined in ghc-9.10.3 · GHC.Utils.Outputable
  • IsOutput HDocDefined in ghc-9.10.3 · GHC.Utils.Outputable
  • type Line HDoc = HLineDefined in ghc-9.10.3 · GHC.Utils.Outputable
valuecoloured :: PprColour -> SDoc -> SDoc
#

Apply the given colour/style for the argument.

Only takes effect if colours are enabled.

valuedoOrDoes :: [a] -> SDoc
#

Determines the form of to do appropriate for the length of a list:

doOrDoes [] = text "do"
doOrDoes ["Hello"] = text "does"
doOrDoes ["Hello", "World"] = text "do"
valuedoublePrec :: Int -> Double -> SDoc
#

doublePrec p n shows a floating point number n with p digits of precision after the decimal point.

valuehasOrHave :: [a] -> SDoc
#

"has" or "have" depending on the length of a list.

valueifPprDebug :: IsOutput doc => doc -> doc -> doc
#

Says what to do with and without -dppr-debug

valueisOrAre :: [a] -> SDoc
#

Determines the form of to be appropriate for the length of a list:

isOrAre [] = text "are"
isOrAre ["Hello"] = text "is"
isOrAre ["Hello", "World"] = text "are"
valueitOrThey :: [a] -> SDoc
#

it or they, depeneding on the length of the list.

itOrThey [x]   = text "it"
itOrThey [x,y] = text "they"
itOrThey []    = text "they"  -- probably avoid this
valueitsOrTheir :: [a] -> SDoc
#

Determines the form of possessive appropriate for the length of a list:

itsOrTheir [x]   = text "its"
itsOrTheir [x,y] = text "their"
itsOrTheir []    = text "their"  -- probably avoid this
valueplural :: [a] -> SDoc
#

Determines the pluralisation suffix appropriate for the length of a list:

plural [] = char 's'
plural ["Hello"] = empty
plural ["Hello", "World"] = char 's'
valuepprQuotedList :: Outputable a => [a] -> SDoc
#

Returns the comma-separated concatenation of the quoted pretty printed things.

[x,y,z]  ==>  `x', `y', `z'
valuepprWithBars
  1. :: (a -> SDoc)

    The pretty printing function to use

  2. -> [a]

    The things to be pretty printed

  3. -> SDoc

    SDoc where the things have been pretty printed, bar-separated and finally packed into a paragraph.

#
valuepunctuateFinal
  1. :: IsLine doc
  2. => doc

    The interstitial punctuation

  3. -> doc

    The final punctuation

  4. -> [doc]

    The list that will have punctuation added between every adjacent pair of elements

  5. -> [doc]

    Punctuated list

#

Punctuate a list, e.g. with commas and dots.

sep $ punctuateFinal comma dot [text "ab", text "cd", text "ef"]
ab, cd, ef.
valuesingular :: [a] -> SDoc
#

Determines the singular verb suffix appropriate for the length of a list:

singular [] = empty
singular["Hello"] = char 's'
singular ["Hello", "World"] = empty
valuespeakN :: Int -> SDoc
#

Converts an integer to a verbal multiplicity:

speakN 0 = text "none"
speakN 5 = text "five"
speakN 10 = text "10"
valuespeakNOf :: Int -> SDoc -> SDoc
#

Converts an integer and object description to a statement about the multiplicity of those objects:

speakNOf 0 (text "melon") = text "no melons"
speakNOf 1 (text "melon") = text "one melon"
speakNOf 3 (text "melon") = text "three melons"
valuespeakNth :: Int -> SDoc
#

Converts an integer to a verbal index:

speakNth 1 = text "first"
speakNth 5 = text "fifth"
speakNth 21 = text "21st"
valuethisOrThese :: [a] -> SDoc
#

Determines the form of subject appropriate for the length of a list:

thisOrThese [x]   = text "This"
thisOrThese [x,y] = text "These"
thisOrThese []    = text "These"  -- probably avoid this
newtypenewtype PDoc a
#

Wrapper for types having a Outputable instance when an OutputableP instance is required.

Constructors

Instances1OutputableP
typetype QueryQualifyModule = Module -> Bool
#

For a given module, we need to know whether to print it with a package name to disambiguate it.

typetype QueryQualifyPackage = Unit -> Bool
#

For a given package, we need to know whether to print it with the component id to disambiguate it.

Outputs string for pragma name for any of INLINEINLINABLENOINLINE. This differs from the Outputable instance for the InlineSpec type where the pragma name string as well as the accompanying SourceText (if any) is printed.

newtypenewtype IdSig
#

A type signature in generated code, notably the code generated for record selectors. We simply record the desired Id itself, replete with its name, type and IdDetails. Otherwise it's just like a type signature: there should be an accompanying binding

Constructors

Instances1Data
  • Data IdSigDefined in ghc-9.10.3 · GHC.Hs.Binds

Extracts the name for a SPECIALIZE instance pragma. In hsSigDoc, the src field of SpecInstSig signature contains the SourceText for a SPECIALIZE instance pragma of the form: "SourceText {-# SPECIALIZE"

Extraction ensures that all variants of the pragma name (with a Z or an S) are output exactly as used in the pragma.

valuemapAccumBagL
  1. :: (acc -> x -> (acc, y))

    combining function

  2. -> acc

    initial state

  3. -> Bag x

    inputs

  4. -> (acc, Bag y)

    final state, outputs

#
valuemapAccumBagLM
  1. :: Monad m
  2. => (acc -> x -> m (acc, y))

    combining function

  3. -> acc

    initial state

  4. -> Bag x

    inputs

  5. -> m (acc, Bag y)

    final state, outputs

#
typetype ConTag = Int
#

A *one-index* constructor tag

Type of the tags associated with each constructor possibility or superclass selector

datadata InsideLam
#

Inside Lambda

Constructors

  • IsInsideLam

    Occurs inside a non-linear lambda Substituting a redex for this occurrence is dangerous because it might duplicate work.

  • NotInsideLam
Instances3Eq, Semigroup, Monoid
  • Eq InsideLamDefined in ghc-9.10.3 · GHC.Types.Basic
  • Semigroup InsideLamDefined in ghc-9.10.3 · GHC.Types.Basic

    If any occurrence of an identifier is inside a lambda, then the occurrence info of that identifier marks it as occurring inside a lambda

  • Monoid InsideLamDefined in ghc-9.10.3 · GHC.Types.Basic
datadata InterestingCxt
#

Interesting Context

Constructors

Instances3Eq, Semigroup, Monoid
  • Eq InterestingCxtDefined in ghc-9.10.3 · GHC.Types.Basic
  • Semigroup InterestingCxtDefined in ghc-9.10.3 · GHC.Types.Basic

    If there is any interesting identifier occurrence, then the aggregated occurrence info of that identifier is considered interesting.

  • Monoid InterestingCxtDefined in ghc-9.10.3 · GHC.Types.Basic
datadata OccInfo
#

identifier Occurrence Information

Constructors

Instances2Eq, Outputable
datadata OneShotInfo
#

If the Id is a lambda-bound variable then it may have lambda-bound variable info. Sometimes we know whether the lambda binding this variable is a "one-shot" lambda; that is, whether it is applied at most once.

This information may be useful in optimisation, as computations may safely be floated inside such a lambda without risk of duplicating work.

See also Note [OneShotInfo overview] above.

Constructors

Instances2Eq, Outputable
newtypenewtype PprPrec
#

A general-purpose pretty-printing precedence type.

Constructors

Instances3Eq, Ord, Show
  • Eq PprPrecDefined in ghc-9.10.3 · GHC.Types.Basic
  • Ord PprPrecDefined in ghc-9.10.3 · GHC.Types.Basic
  • Show PprPrecDefined in ghc-9.10.3 · GHC.Types.Basic
datadata DefaultingStrategy
#

Specify whether to default kind variables, and type variables of kind RuntimeRepLevityMultiplicity.

Constructors

  • DefaultKindVars

    Default kind variables:

    • default kind variables of kind Type to Type,

    • default RuntimeRepLevityMultiplicity kind variables to LiftedRepLiftedMany, respectively.

    When this strategy is used, it means that we have determined that the variables we are considering defaulting are all kind variables.

    Usually, we pass this option when -XNoPolyKinds is enabled.

  • NonStandardDefaulting NonStandardDefaultingStrategy

    Default (or don't default) non-standard variables, of kinds RuntimeRep, Levity and Multiplicity.

Instances1Outputable

Specify whether to default type variables of kind RuntimeRepLevityMultiplicity.

Constructors

  • DefaultNonStandardTyVars

    Default type variables of the given kinds:

    • default RuntimeRep variables to LiftedRep

    • default Levity variables to Lifted

    • default Multiplicity variables to Many

  • TryNotToDefaultNonStandardTyVars

    Try not to default type variables of the kinds RuntimeRepLevityMultiplicity.

    Note that these might get defaulted anyway, if they are kind variables and `-XNoPolyKinds` is enabled.

Instances1Outputable
valuefIRST_TAG :: ConTag
#

Tags are allocated from here for real constructors or for superclass selectors

valuepprAlternative
  1. :: (a -> SDoc)

    The pretty printing function to use

  2. -> a

    The things to be pretty printed

  3. -> ConTag

    Alternative (one-based)

  4. -> Arity

    Arity

  5. -> SDoc

    SDoc where the alternative havs been pretty printed and finally packed into a paragraph.

#

Pretty print an alternative in an unboxed sum e.g. "| a | |".

valuerequiresPMC :: Origin -> Bool
#

Does this Origin require us to run pattern-match checking, or should we skip these checks?

See Note [Generated code and pattern-match checking].

typetype ConTagZ = Int
#

A *zero-indexed* constructor tag

datadata EP a
#

Embedding Projection pair

Constructors

typetype FullArgCount = Int
#

FullArgCount is the number of type or value arguments in an application, or the number of type or value binders in a lambda. Note: it includes both type and value arguments!

typetype JoinArity = Int
#

The number of arguments that a join point takes. Unlike the arity of a function, this is a purely syntactic property and is fixed when the join point is created (or converted from a value). Both type and value arguments are counted.

typetype RepArity = Int
#

Representation Arity

The number of represented arguments that can be applied to a value before it does "real work". So: fib 100 has representation arity 0 x -> fib x has representation arity 1 (# x, y #) -> fib (x + y) has representation arity 2

typetype VisArity = Int
#

Syntactic (visibility) arity, i.e. the number of visible arguments. See Note [Visibility and arity]

datadata FamTyConFlav
#

Information pertaining to the expansion of a type synonym (type)

Constructors

Instances1Outputable
datadata AlgTyConRhs
#

Represents right-hand-sides of TyCons for algebraic types

Constructors

  • AbstractTyCon

    Says that we know nothing about this data type, except that it's represented by a pointer. Used when we export a data type abstractly into an .hi file.

  • DataTyCon

    Information about those TyCons derived from a data declaration. This includes data types with no constructors at all.

    • data_cons :: [DataCon]

      The data type constructors; can be empty if the user declares the type to have no constructors

      INVARIANT: Kept in order of increasing DataCon tag (see the tag assignment in mkTyConTagMap)

    • data_cons_size :: Int

      Cached value: length data_cons

    • is_enum :: Bool

      Cached value: is this an enumeration type? See Note [Enumeration types]

    • is_type_data :: Bool
    • data_fixed_lev :: Bool

      True if the data type constructor has a known, fixed levity when fully applied to its arguments, False otherwise.

      This can only be False with UnliftedDatatypes, e.g.

      data A :: TYPE (BoxedRep l) where { MkA :: Int -> A }

      This boolean is cached to make it cheaper to check for levity and representation-polymorphism in tcHasFixedRuntimeRep.

  • TupleTyCon
  • SumTyCon

    An unboxed sum type.

    • data_cons :: [DataCon]

      The data type constructors; can be empty if the user declares the type to have no constructors

      INVARIANT: Kept in order of increasing DataCon tag (see the tag assignment in mkTyConTagMap)

    • data_cons_size :: Int

      Cached value: length data_cons

  • NewTyCon

    Information about those TyCons derived from a newtype declaration

    • data_con :: DataCon

      The unique constructor for the newtype. It has no existentials

    • nt_rhs :: Type

      Cached value: the argument type of the constructor, which is just the representation type of the TyCon (remember that newtypes do not exist at runtime so need a different representation type).

      The free TyVars of this type are the tyConTyVars from the corresponding TyCon

    • nt_etad_rhs :: ([TyVar], Type)

      Same as the nt_rhs, but this time eta-reduced. Hence the list of TyVars in this field may be shorter than the declared arity of the TyCon.

    • nt_co :: CoAxiom Unbranched
    • nt_fixed_rep :: Bool

      True if the newtype has a known, fixed representation when fully applied to its arguments, False otherwise. This can only ever be False with UnliftedNewtypes.

      Example:

      newtype N (a :: TYPE r) = MkN a

      Invariant: nt_fixed_rep nt = tcHasFixedRuntimeRep (nt_rhs nt)

      This boolean is cached to make it cheaper to check if a variable binding is representation-polymorphic in tcHasFixedRuntimeRep.

datadata AlgTyConFlav
#

Describes the flavour of an algebraic type constructor. For classes and data families, this flavour includes a reference to the parent TyCon.

Constructors

  • VanillaAlgTyCon TyConRepName

    An ordinary algebraic type constructor. This includes unlifted and representation-polymorphic datatypes and newtypes and unboxed tuples, but NOT unboxed sums; see UnboxedSumTyCon.

  • UnboxedSumTyCon

    An unboxed sum type constructor. This is distinct from VanillaAlgTyCon because we currently don't allow unboxed sums to be Typeable since there are too many of them. See #13276.

  • ClassTyCon Class TyConRepName

    Type constructors representing a class dictionary. See Note [ATyCon for classes] in GHC.Core.TyCo.Rep

  • DataFamInstTyCon (CoAxiom Unbranched) TyCon [Type]

    Type constructors representing an *instance* of a *data* family. Parameters:

    1) The type family in question

    2) Instance types; free variables are the tyConTyVars of the current TyCon (not the family one). INVARIANT: the number of types matches the arity of the family TyCon

    3) A CoTyCon identifying the representation type with the type instance family

Instances1Outputable
valuemkTcTyCon
  1. :: Name
  2. -> [TyConBinder]
  3. -> Kind

    result kind only

  4. -> [(Name, TcTyVar)]

    Scoped type variables;

  5. -> Bool

    Is this TcTyCon generalised already?

  6. -> TyConFlavour TyCon

    What sort of TyCon this represents

  7. -> TyCon
#

Makes a tycon suitable for use during type-checking. It stores a variety of details about the definition of the TyCon, but no right-hand side. It lives only during the type-checking of a mutually-recursive group of tycons; it is then zonked to a proper TyCon in zonkTcTyCon. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.TyCl

valuemkTyConTy :: TyCon -> Type
#

(mkTyConTy tc) returns (TyConApp tc []) but arranges to share that TyConApp among all calls See Note [Sharing nullary TyConApps] So it's just an alias for tyConNullaryTy!

datadata ForAllTyFlag
#

ForAllTyFlag

Is something required to appear in source Haskell (Required), permitted by request (Specified) (visible type application), or prohibited entirely from appearing in source Haskell (Inferred)? See Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in GHC.Core.TyCo.Rep

Instances7Eq, Data, Ord, NFData, Binary, Outputable, …
valueboxingDataCon :: Type -> BoxingInfo b
#

Given a type ty, if ty is not of kind Type, return a data constructor that will box it, and the type of the boxed thing, which does now have kind Type. See Note [Boxing constructors]

Built-in syntax isn't "in scope" so these OccNames map to wired-in Names with BuiltInSyntax. However, this should only be necessary while resolving names produced by Template Haskell splices since we take care to encode built-in syntax names specially in interface files. See Note [Symbol table representation of names] in GHC.Iface.Binary.

Moreover, there is no need to include names of things that the user can't write (e.g. type representation bindings like $tc(,,,)).

valuemkBoxedTupleTy :: [Type] -> Type
#

Build the type of a small tuple that holds the specified type of thing Flattens 1-tuples. See Note [One-tuples].

valuemkTupleTy :: Boxity -> [Type] -> Type
#

Make a tuple type. The list of types should not include any RuntimeRep specifications. Boxed 1-tuples are flattened. See Note [One-tuples]

valuemkTupleTy1 :: Boxity -> [Type] -> Type
#

Make a tuple type. The list of types should not include any RuntimeRep specifications. Boxed 1-tuples are *not* flattened. See Note [One-tuples] and Note [Don't flatten tuples from HsSyn] in GHC.Core.Make

Should this name be considered in-scope, even though it technically isn't?

This ensures that we don't filter out information because, e.g., Data.Kind.Type isn't imported.

See Note [pretendNameIsInScope].

Given a RuntimeRep, applies TYPE to it. On the fly it rewrites TYPE LiftedRep --> liftedTypeKind (a synonym) TYPE UnliftedRep --> unliftedTypeKind (ditto) TYPE ZeroBitRep --> zeroBitTypeKind (ditto) NB: no need to check for TYPE (BoxedRep Lifted), TYPE (BoxedRep Unlifted) because those inner types should already have been rewritten to LiftedRep and UnliftedRep respectively, by mkTyConApp

see Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim. See Note [Using synonyms to compress types] in GHC.Core.Type

typetype KindOrType = Type
#

The key representation of types within the compiler

datadata FunTyFlag
#

The non-dependent version of ForAllTyFlag. See Note [FunTyFlag] Appears here partly so that it's together with its friends ForAllTyFlag and ForallVisFlag, but also because it is used in IfaceType, rather early in the compilation chain

Instances5Eq, Data, Ord, Outputable, Binary
datadata PiTyBinder
#

A PiTyBinder represents an argument to a function. PiTyBinders can be dependent (Named) or nondependent (Anon). They may also be visible or not. See Note [PiTyBinders]

Instances2Data, Outputable
datadata UnivCoProvenance
#

For simplicity, we have just one UnivCo that represents a coercion from some type to some other type, with (in general) no restrictions on the type. The UnivCoProvenance specifies more exactly what the coercion really is and why a program should (or shouldn't!) trust the coercion. It is reasonable to consider each constructor of UnivCoProvenance as a totally independent coercion form; their only commonality is that they don't tell you what types they coercion between. (That info is in the UnivCo constructor of Coercion.

Constructors

  • PhantomProv KindCoercion

    See Note [Phantom coercions]. Only in Phantom roled coercions

  • ProofIrrelProv KindCoercion

    From the fact that any two coercions are considered equivalent. See Note [ProofIrrelProv]. Can be used in Nominal or Representational coercions

  • PluginProv String

    From a plugin, which asserts that this coercion is sound. The string is for the use of the plugin.

Instances2Data, Outputable
valuemkForAllTy :: ForAllTyBinder -> Type -> Type
#

Like mkTyCoForAllTy, but does not check the occurrence of the binder See Note [Unused coercion variable in ForAllTy]

valuemkNakedTyConTy :: TyCon -> Type
#

mkNakedTyConTy creates a nullary TyConApp. In general you should rather use GHC.Core.Type.mkTyConTy, which picks the shared nullary TyConApp from inside the TyCon (via tyConNullaryTy. But we have to build the TyConApp tc [] in that TyCon field; that's what mkNakedTyConTy is for.

typetype KnotTied (ty :: k) = ty
#

A type labeled KnotTied might have knot-tied tycons in it. See Note [Type checking recursive type and class declarations] in GHC.Tc.TyCl

typetype LevityType = Type
#

Type synonym used for types of kind Levity.

valuetcEqTyConApps :: TyCon -> [Type] -> TyCon -> [Type] -> Bool
#

Check whether two TyConApps are the same; if the number of arguments are different, just checks the common prefix of arguments.

valuetyCoFVsOfType :: Type -> FV
#

The worker for tyCoFVsOfType and tyCoFVsOfTypeList. The previous implementation used unionVarSet which is O(n+m) and can make the function quadratic. It's exported, so that it can be composed with other functions that compute free variables. See Note [FV naming conventions] in GHC.Utils.FV.

Eta-expanded because that makes it run faster (apparently) See Note [FV eta expansion] in GHC.Utils.FV for explanation.

typetype ErrorMsgType = Type
#

A type of kind ErrorMessage (from the GHC.TypeError module).

valueisConcreteType :: Type -> Bool
#

Tests whether the given type is concrete, i.e. it whether it consists only of concrete type constructors, concrete type variables, and applications.

See Note [Concrete types] in GHC.Tc.Utils.Concrete.

valuepiResultTys :: HasDebugCallStack => Type -> [Type] -> Type
#

(piResultTys f_ty [ty1, .., tyn]) gives the type of (f ty1 .. tyn) where f :: f_ty piResultTys is interesting because: 1. f_ty may have more for-alls than there are args 2. Less obviously, it may have fewer for-alls For case 2. think of: piResultTys (forall a.a) [forall b.b, Int] This really can happen, but only (I think) in situations involving undefined. For example: undefined :: forall a. a Term: undefined (forall b. b->b) Int This term should have type (Int -> Int), but notice that there are more type args than foralls in undefineds type.

valuesplitAppTys :: HasDebugCallStack => Type -> (Type, [Type])
#

Recursively splits a type as far as is possible, leaving a residual type being applied to and the type arguments applied to it. Never fails, even if that means returning an empty list of type applications.

tcSplitTyConApp_maybe splits a type constructor application into its type constructor and applied types.

Differs from splitTyConApp_maybe in that it does *not* split types headed with (=>), as that's not a TyCon in the type-checker.

Note that this may fail (in funTyConAppTy_maybe) in the case of a FunTy with an argument of unknown kind FunTy (e.g. `FunTy (a :: k) Int`, since the kind of a isn't of the form `TYPE rep`. This isn't usually a problem but may be temporarily the case during canonicalization: see Note [Decomposing FunTy] in GHC.Tc.Solver.Equality and Note [The Purely Kinded Type Invariant (PKTI)] in GHC.Tc.Gen.HsType, Wrinkle around FunTy

Consequently, you may need to zonk your type before using this function.

valueevId :: EvId -> EvExpr
#

Any sort of evidence Id, including coercions

datadata SkolemInfoAnon
#

SkolemInfoAnon stores the origin of a skolem type variable (e.g. bound by a user-written forall, the header of a data declaration, a deriving clause, ...).

This information is displayed when reporting an error message, such as

"Couldn't match k with l"

This allows us to explain where the type variable came from.

When several skolem type variables are bound at once, prefer using SkolemInfo, which stores a Unique which allows these type variables to be reported

Instances1Outputable
datadata UserTypeCtxt
#
Instances1Eq
datadata CtIrredReason
#

Used to indicate extra information about why a CIrredCan is irreducible

Constructors

  • IrredShapeReason

    This constraint has a non-canonical shape (e.g. c Int, for a variable c)

  • NonCanonicalReason CheckTyEqResult

    An equality where some invariant other than (TyEq:H) of CEqCan is not satisfied; the CheckTyEqResult states exactly why

  • ReprEqReason

    An equality that cannot be decomposed because it is representational. Example: a b ~R# Int. These might still be solved later. INVARIANT: The constraint is a representational equality constraint

  • ShapeMismatchReason

    A nominal equality that relates two wholly different types, like Int ~# Bool or a b ~# 3. INVARIANT: The constraint is a nominal equality constraint

  • AbstractTyConReason

    An equality like T a b c ~ Q d e where either T or Q is an abstract type constructor. See Note [Skolem abstract data] in GHC.Core.TyCon. INVARIANT: The constraint is an equality constraint between two TyConApps

  • PluginReason

    A typechecker plugin returned this in the pluginBadCts field of TcPluginProgress

Instances1Outputable
datadata TcEvDest
#

A place for type-checking evidence to go after it is generated.

  • Wanted equalities use HoleDest,

  • other Wanteds use EvVarDest.

Constructors

  • EvVarDest EvVar

    bind this var to the evidence EvVarDest is always used for non-type-equalities e.g. class constraints

  • HoleDest CoercionHole

    fill in this hole with the evidence HoleDest is always used for type-equalities See Note [Coercion holes] in GHC.Core.TyCo.Rep

Instances1Outputable

Is a type a canonical LHS? That is, is it a tyvar or an exactly-saturated type family application? Does not look through type synonyms.

Does this constraint contain an user error message?

That is, the type is either of the form Unsatisfiable err, or it contains a type of the form TypeError msg, either at the top level or nested inside the type.

valueinsolubleCt :: Ct -> Bool
#

Returns True of constraints that are definitely insoluble, as well as TypeError constraints. Can return True for Given constraints, unlike insolubleWantedCt.

The function is tuned for application after constraint solving i.e. assuming canonicalisation has been done That's why it looks only for IrredCt; all insoluble constraints are put into CIrredCan

Checks whether a the given wanted constraints are solved, i.e. that there are no simple constraints left and all the implications are solved.

True if taking superclasses of givens, or of wanteds (to perhaps expose more equalities or functional dependencies) might help to solve this constraint. See Note [When superclasses help]

valuetyCoVarsOfCtList :: Ct -> [TcTyCoVar]
#

Returns free variables of constraints as a deterministically ordered list. See Note [Deterministic FV] in GHC.Utils.FV.

typetype CtFlavourRole = (CtFlavour, EqRel)
#

Whether or not one Ct can rewrite another is determined by its flavour and its equality relation. See also Note [Flavours with roles] in GHC.Tc.Solver.InertSet

typetype ExpansionFuel = Int
#

Says how many layers of superclasses can we expand. Invariant: ExpansionFuel should always be >= 0 see Note [Expanding Recursive Superclasses and ExpansionFuel]

datadata NotConcreteReason
#

Why did we decide that a type was not concrete?

Constructors

typetype Xi = TcType
#

A Xi-type is one that has been fully rewritten with respect to the inert set; that is, it has been rewritten by the algorithm in GHC.Tc.Solver.Rewrite. (Historical note: Xi, for years and years, meant that a type was type-family-free. It does *not* mean this any more.)

datadata MetaInfo
#

What restrictions are on this metavariable around unification? These are checked in GHC.Tc.Utils.Unify.checkTopShape

Constructors

  • TauTv

    This MetaTv is an ordinary unification variable A TauTv is always filled in with a tau-type, which never contains any ForAlls.

  • TyVarTv

    A variant of TauTv, except that it should not be unified with a type, only with a type variable See Note [TyVarTv] in GHC.Tc.Utils.TcMType

  • RuntimeUnkTv

    A unification variable used in the GHCi debugger. It is allowed to unify with a polytype, unlike TauTv

  • CycleBreakerTv
  • ConcreteTv ConcreteTvOrigin

    A unification variable that can only be unified with a concrete type, in the sense of Note [Concrete types] in GHC.Tc.Utils.Concrete. See Note [ConcreteTv] in GHC.Tc.Utils.Concrete. See also Note [The Concrete mechanism] in GHC.Tc.Utils.Concrete for an overview of how this works in context.

Instances1Outputable
valueeqType :: Type -> Type -> Bool
#

Type equality on source types. Does not look through newtypes, PredTypes or type families, but it does look through type synonyms. This first checks that the kinds of the types are equal and then checks whether the types are equal, ignoring casts and coercions. (The kind check is a recursive call, but since all kinds have type Type, there is no need to check the types of kinds.) See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep.

valuescopedSort :: [TyCoVar] -> [TyCoVar]
#

Do a topological sort on a list of tyvars, so that binders occur before occurrences E.g. given [ a::k, k::*, b::k ] it'll return a well-scoped list [ k::*, a::k, b::k ]

This is a deterministic sorting operation (that is, doesn't depend on Uniques).

It is also meant to be stable: that is, variables should not be reordered unnecessarily. This is specified in Note [ScopedSort] See also Note [Ordering of implicit variables] in GHC.Rename.HsType

valueisCoVarType :: Type -> Bool
#

Does this type classify a core (unlifted) Coercion? At either role nominal or representational (t1 ~# t2) or (t1 ~R# t2) See Note [Types for coercions, predicates, and evidence] in GHC.Core.TyCo.Rep

valueisFunTy :: Type -> Bool
#

Is this a function? Note: `forall {b}. Show b => b -> IO b` will not be considered a function by this function. It would merely be a forall wrapping a function type.

valuemkCoreApps
  1. :: CoreExpr

    function

  2. -> [CoreExpr]

    arguments

  3. -> CoreExpr
#

Construct an expression which represents the application of a number of expressions to another. The leftmost expression in the list is applied first

valuechunkify :: [a] -> [[a]]
#

Split a list into lists that are small enough to have a corresponding tuple arity. The sub-lists of the result all have length <= mAX_TUPLE_SIZE But there may be more than mAX_TUPLE_SIZE sub-lists

valuemkBigCoreTup :: [CoreExpr] -> CoreExpr
#

Build a "big" tuple holding the specified expressions One-tuples are flattened; see Note [Flattening one-tuples] Arguments don't have to have kind Type; ones that do not are boxed This function crashes (in wrapBox) if given a non-Type argument that it doesn't know how to box.

valuemkBigCoreVarTup :: [Id] -> CoreExpr
#

Build a big tuple holding the specified variables One-tuples are flattened; see Note [Flattening one-tuples] Arguments don't have to have kind Type

valuemkBigTupleCase
  1. :: MonadUnique m
  2. => [Id]

    The tuple identifiers to pattern match on; Bring these into scope in the body

  3. -> CoreExpr

    Body of the case

  4. -> CoreExpr

    Scrutinee

  5. -> m CoreExpr
#

A generalization of mkBigTupleSelector, allowing the body of the case to be an arbitrary expression.

To avoid shadowing, we use uniques to invent new variables.

If necessary we pattern match on a "big" tuple.

valuemkBigTupleSelector
  1. :: [Id]

    The Ids to pattern match the tuple against

  2. -> Id

    The Id to select

  3. -> Id

    A variable of the same type as the scrutinee

  4. -> CoreExpr

    Scrutinee

  5. -> CoreExpr

    Selector expression

#

Builds a selector which scrutinises the given expression and extracts the one name from the list given. If you want the no-shadowing rule to apply, the caller is responsible for making sure that none of these names are in scope.

If there is just one Id in the tuple, then the selector is just the identity.

If necessary, we pattern match on a "big" tuple.

A tuple selector is not linear in its argument. Consequently, the case expression built by mkBigTupleSelector must consume its scrutinee Many times. And all the argument variables must have multiplicity Many.

mkBigTupleSelectorSolo is like mkBigTupleSelector but one-tuples are NOT flattened (see Note [Flattening one-tuples])

valuemkBigTupleSelectorSolo
  1. :: [Id]

    The Ids to pattern match the tuple against

  2. -> Id

    The Id to select

  3. -> Id

    A variable of the same type as the scrutinee

  4. -> CoreExpr

    Scrutinee

  5. -> CoreExpr

    Selector expression

#

Builds a selector which scrutinises the given expression and extracts the one name from the list given. If you want the no-shadowing rule to apply, the caller is responsible for making sure that none of these names are in scope.

If there is just one Id in the tuple, then the selector is just the identity.

If necessary, we pattern match on a "big" tuple.

A tuple selector is not linear in its argument. Consequently, the case expression built by mkBigTupleSelector must consume its scrutinee Many times. And all the argument variables must have multiplicity Many.

Construct an expression which represents the application of a number of expressions to that of a data constructor expression. The leftmost expression in the list is applied first

valuemkCoreLams :: [CoreBndr] -> CoreExpr -> CoreExpr
#

Create a lambda where the given expression has a number of variables bound over it. The leftmost binder is that bound by the outermost lambda in the result

Bind a binding group over an expression, using a let or case as appropriate (see GHC.Core#let_can_float_invariant)

valuemkCoreLets :: [CoreBind] -> CoreExpr -> CoreExpr
#

Bind a list of binding groups over an expression. The leftmost binding group becomes the outermost group in the resulting expression

valuemkCoreTup :: [CoreExpr] -> CoreExpr
#

Build a small tuple holding the specified expressions One-tuples are flattened; see Note [Flattening one-tuples]

Build a small unboxed tuple holding the specified expressions. Do not include the RuntimeRep specifiers; this function calculates them for you. Does not flatten one-tuples; see Note [Flattening one-tuples]

valuemkCoreVarTupTy :: [Id] -> Type
#

Build the type of a small tuple that holds the specified variables One-tuples are flattened; see Note [Flattening one-tuples]

valuemkWildValBinder :: Mult -> Type -> Id
#

Make a wildcard binder. This is typically used when you need a binder that you expect to use only at a *binding* site. Do not use it at occurrence sites because it has a single, fixed unique, and it's very easy to get into difficulties with shadowing. That's why it is used so little.

See Note [WildCard binders] in GHC.Core.Opt.Simplify.Env

valuesortQuantVars :: [Var] -> [Var]
#

Sort the variables, putting type and covars first, in scoped order, and then other Ids

It is a deterministic sort, meaning it doesn't look at the values of Uniques. For explanation why it's important See Note [Unique Determinism] in GHC.Types.Unique.

valuesplitTyConApp :: Type -> (TyCon, [Type])
#

Attempts to tease a type apart into a type constructor and the application of a number of arguments to that constructor. Panics if that is not possible. See also splitTyConApp_maybe

typetype TcTypeFRR = TcType
#

A type which has a syntactically fixed RuntimeRep as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete.

typetype DFunId = Id
#

Dictionary Function Identifier

datadata EvTypeable
#

Instructions on how to make a Typeable dictionary. See Note [Typeable evidence terms]

Constructors

Instances2Data, Outputable

Identifies the lambda-bound dictionaries of an HsWrapper. This is used (only) to allow the pattern-match overlap checker to know what Given dictionaries are in scope.

We specifically do not collect dictionaries bound in a WpLet. These are either superclasses of lambda-bound ones, or (extremely numerous) results of binding Wanted dictionaries. We definitely don't want all those cluttering up the Given dictionaries for pattern-match overlap checking!

valuemkWpFun
  1. :: HsWrapper
  2. -> HsWrapper
  3. -> Scaled TcTypeFRR

    the "from" type of the first wrapper MUST have a fixed RuntimeRep

  4. -> TcType

    Either "from" type or "to" type of the second wrapper (used only when the second wrapper is the identity)

  5. -> HsWrapper
#

Smart constructor to create a WpFun HsWrapper.

PRECONDITION: the "from" type of the first wrapper must have a syntactically fixed RuntimeRep (see Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete).

valueunwrapIP :: Type -> CoercionR
#

Create a Coercion that unwraps an implicit-parameter dictionary to expose the underlying value. We expect the Type to have the form `IP sym ty`, and return a Coercion `co :: IP sym ty ~ ty`

valuemightBeLiftedType :: Type -> Bool
#

Returns:

  • False if the type is guaranteed unlifted or

  • True if it lifted, OR we aren't sure (e.g. in a representation-polymorphic case)

valuehasNoBinding :: Id -> Bool
#

Returns True of an Id which may not have a binding, even though it is defined in this module.

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

valueidFunRepArity :: Id -> RepArity
#

This function counts all arguments post-unarisation, which includes arguments with no runtime representation -- see Note [Unarisation and arity]

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.

valueisStrictId :: Id -> Bool
#

isStrictId says whether either (a) the Id has a strict demand placed on it or (b) definitely has a "strict type", such that it can always be evaluated strictly (i.e an unlifted type) We need to check (b) as well as (a), because when the demand for the given id hasn't been computed yet but id has a strict type, we still want `isStrictId id` to be True. Returns False if the type is levity polymorphic; False is always safe.

valueisWorkerLikeId :: Id -> Bool
#

An Id for which we might require all callers to pass strict arguments properly tagged + evaluated.

See Note [CBV Function Ids]

valuemkExportedLocalId :: IdDetails -> Name -> Type -> Id
#

Create a local Id that is marked as exported. This prevents things attached to it from being removed as dead code. See Note [Exported LocalIds]

valuemkTemplateLocal :: Int -> Type -> Id
#

Create a template local: a family of system local Ids in bijection with Ints, typically used in unfoldings

valuesetIdType :: Id -> Type -> Id
#

Not only does this set the Id Type, it also evaluates the type to try and reduce space usage

valuezapIdUnfolding :: Id -> Id
#

Similar to trimUnfolding, but also removes evaldness info.

Why a particular typeclass application couldn't be looked up.

Constructors

Instances2Generic, Rep

True when when the instance heads are the same e.g. both are Eq [(a,b)] Used for overriding in GHCi Obviously should be insensitive to alpha-renaming

Collects the names of concrete types and type constructors that make up the head of a class instance. For instance, given `class Foo a b`:

`instance Foo (Either (Maybe Int) a) Bool` would yield [Either, Maybe, Int, Bool]

Used in the implementation of ":info" in GHCi.

The tcSplitSigmaTy is because of instance Foo a => Baz T where ... The decl is an orphan if Baz and T are both not locally defined, even if Foo *is* locally defined

Set of visible orphan modules, according to what modules have been directly imported. This is based off of the dep_orphs field, which records transitively reachable orphan modules (modules that define orphan instances).

valuetcSplitSigmaTy :: Type -> ([TyVar], ThetaType, Type)
#

Split a sigma type into its parts. This only splits invisible type variable binders, as these are the only forms of binder that the typechecker will implicitly instantiate.

datadata TyFamEqnValidityInfo
#

Information about a type family equation, used for validity checking of closed type family equations and associated type family default equations.

This type exists to delay validity-checking after typechecking type declaration groups, to avoid cyclic evaluation inside the typechecking knot.

See Note [Type-checking default assoc decls] in GHC.Tc.TyCl.

Constructors

  • NoVI

    Used for equations which don't need any validity checking, for example equations imported from another module.

  • VI

    Information necessary for validity checking of a type family equation.

    • vi_loc :: SrcSpan
    • vi_qtvs :: [TcTyVar]

      LHS quantified type variables

    • vi_non_user_tvs :: TyVarSet

      non-user-written type variables (for error message reporting)

      Example: with -XPolyKinds, typechecking type instance forall a. F = () introduces the kind variable k for the kind of a. See #23734.

    • vi_pats :: [Type]

      LHS patterns

    • vi_rhs :: Type

      RHS of the equation

      NB: for associated type family default declarations, this is the RHS *before* applying the substitution from Note [Type-checking default assoc decls] in GHC.Tc.TyCl.

valueeqTypes :: [Type] -> [Type] -> Bool
#

Type equality on lists of types, looking through type synonyms but not newtypes.

valuemayLookIdentical :: Type -> Type -> Bool
#

Returns True if the visible part of the types might look equal, even if they are really unequal (in the invisible bits)

This function is very similar to tc_eq_type but it is much more heuristic. Notably, it is always safe to return True, even with types that might (in truth) be unequal -- this affects error messages only (Originally there were one function with an extra flag, but the result was hard to understand.)

Returns free variables of types, including kind variables as a deterministic set. For type synonyms it does not expand the synonym.

valuetyCoVarsOfTypesList :: [Type] -> [TyCoVar]
#

Returns free variables of types, including kind variables as a deterministically ordered list. For type synonyms it does not expand the synonym.

datadata Subst
#

Type & coercion & id substitution

The Subst data type defined in this module contains substitution for tyvar, covar and id. However, operations on IdSubstEnv (mapping from Id to CoreExpr) that require the definition of the Expr data type are defined in GHC.Core.Subst to avoid circular module dependency.

Instances1Outputable
valueextendTvSubst :: Subst -> TyVar -> Type -> Subst
#

Add a substitution for a TyVar to the Subst The TyVar *must* be a real TyVar, and not a CoVar You must ensure that the in-scope set is such that Note [The substitution invariant] holds after extending the substitution like this.

valuemkTvSubstPrs :: [(TyVar, Type)] -> Subst
#

Generates the in-scope set for the TCvSubst from the types in the incoming environment. No CoVars, please! The InScopeSet is just a thunk so with a bit of luck it'll never be evaluated

Substitute within a Coercion disabling sanity checks. The problems that the sanity checks in substCo catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substCoUnchecked to substCo and remove this function. Please don't use in new code.

Coercion substitution, see zipTvSubst. Disables sanity checks. The problems that the sanity checks in substCo catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substCoUnchecked to substCo and remove this function. Please don't use in new code.

Substitute within a ThetaType disabling the sanity checks. The problems that the sanity checks in substTys catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substThetaUnchecked to substTheta and remove this function. Please don't use in new code.

Substitute within a Type after adding the free variables of the type to the in-scope set. This is useful for the case when the free variables aren't already in the in-scope set or easily available. See also Note [The substitution invariant].

valuesubstTyUnchecked :: Subst -> Type -> Type
#

Substitute within a Type disabling the sanity checks. The problems that the sanity checks in substTy catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substTyUnchecked to substTy and remove this function. Please don't use in new code.

valuesubstTyWithUnchecked :: [TyVar] -> [Type] -> Type -> Type
#

Type substitution, see zipTvSubst. Disables sanity checks. The problems that the sanity checks in substTy catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substTyUnchecked to substTy and remove this function. Please don't use in new code.

valuesubstTysUnchecked :: Subst -> [Type] -> [Type]
#

Substitute within several Types disabling the sanity checks. The problems that the sanity checks in substTys catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substTysUnchecked to substTys and remove this function. Please don't use in new code.

valueisFamFreeTyCon :: TyCon -> Bool
#

Is this tycon neither a type family nor a synonym that expands to a type family?

valueisGenerativeTyCon :: TyCon -> Role -> Bool
#

isGenerativeTyCon is true of TyCons for which this property holds (where r is the role passed in): If (T tys ~r t), then (t's head ~r T). See also Note [Decomposing TyConApp equalities] in GHC.Tc.Solver.Equality

NB: at Nominal role, isGenerativeTyCon is simple: isGenerativeTyCon tc Nominal = not (isTypeFamilyTyCon tc || isSynonymTyCon tc)

valueappTyForAllTyFlags :: Type -> [Type] -> [ForAllTyFlag]
#

Given a Type and a list of argument types to which the Type is applied, determine each argument's visibility (Inferred, Specified, or Required).

Most of the time, the arguments will be Required, but not always. Consider f :: forall a. a -> Type. In f Type Bool, the first argument (Type) is Specified and the second argument (Bool) is Required. It is precisely this sort of higher-rank situation in which appTyForAllTyFlags comes in handy, since f Type Bool would be represented in Core using AppTys. (See also #15792).

valuecoreView :: Type -> Maybe Type
#

This function strips off the top layer only of a type synonym application (if any) its underlying representation type. Returns Nothing if there is nothing to look through.

This function does not look through type family applications.

By being non-recursive and inlined, this case analysis gets efficiently joined onto the case analysis that the caller is already doing

valueisForAllTy :: Type -> Bool
#

Checks whether this is a proper forall (with a named binder)

valueisLiftedTypeKind :: Kind -> Bool
#

Returns True if the argument is (lifted) Type or Constraint See Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim

valueisTYPEorCONSTRAINT :: Kind -> Bool
#

Does this classify a type allowed to have values? Responds True to things like *, TYPE Lifted, TYPE IntRep, TYPE v, Constraint.

True of a kind `TYPE _` or `CONSTRAINT _`

valueisUnliftedTypeKind :: Kind -> Bool
#

Returns True if the kind classifies unlifted types (like Int#) and False otherwise. Note that this returns False for representation-polymorphic kinds, which may be specialized to a kind that classifies unlifted types.

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.

The context in which a representation-polymorphism check was performed.

Does not include the type on which the check was performed; see FixedRuntimeRepOrigin for that.

Constructors

  • FRRRecordCon !RdrName !(HsExpr GhcTc)

    Record fields in record construction must have a fixed runtime representation.

  • FRRRecordUpdate !Name !(HsExpr GhcRn)

    Record fields in record updates must have a fixed runtime representation.

    Test case: RepPolyRecordUpdate.

  • FRRBinder !Name

    Variable binders must have a fixed runtime representation.

    Test cases: LevPolyLet, RepPolyPatBind.

  • FRRRepPolyId !Name !RepPolyId !(Position 'Neg)

    Types appearing in negative position in the type of a representation-polymorphic Id must have a fixed runtime representation.

    This includes:

    • arguments,

    Test cases: RepPolyMagic, RepPolyRightSection, RepPolyWrappedVar, T14561b, T17817.

    • continuation result types, such as in catch#, keepAlive# and control0#.

    Test case: T21906.

  • FRRRepPolyUnliftedNewtype !DataCon

    A partial application of the constructor of a representation-polymorphic unlifted newtype in which the argument type does not have a fixed runtime representation.

    Test cases: UnliftedNewtypesLevityBinder, UnliftedNewtypesCoerceFail.

  • FRRPatBind

    Pattern binds must have a fixed runtime representation.

    Test case: RepPolyInferPatBind.

  • FRRPatSynArg

    Pattern synonym arguments must have a fixed runtime representation.

    Test case: RepPolyInferPatSyn.

  • FRRCase

    The type of the scrutinee in a case statement must have a fixed runtime representation.

    Test cases: RepPolyCase{1,2}.

  • FRRDataConPatArg !DataCon !Int

    An instantiation of a newtype/data constructor pattern in which an argument type does not have a fixed runtime representation.

    Test case: T20363.

  • FRRUnboxedTuple !Int

    The RuntimeRep arguments to unboxed tuples must be concrete RuntimeReps.

    Test case: RepPolyTuple.

  • FRRUnboxedTupleSection !Int

    Tuple sections must have a fixed runtime representation.

    Test case: RepPolyTupleSection.

  • FRRUnboxedSum !(Maybe Int)

    The RuntimeRep arguments to unboxed sums must be concrete RuntimeReps.

    Test cases: RepPolySum.

  • FRRBodyStmt !StmtOrigin !Int

    The body of a do expression or a monad comprehension must have a fixed runtime representation.

    Test cases: RepPolyDoBody{1,2}, RepPolyMcBody.

  • FRRBodyStmtGuard

    Arguments to a guard in a monad comprehension must have a fixed runtime representation.

    Test case: RepPolyMcGuard.

  • FRRBindStmt !StmtOrigin

    Arguments to (>>=) arising from a do expression or a monad comprehension must have a fixed runtime representation.

    Test cases: RepPolyDoBind, RepPolyMcBind.

  • FRRBindStmtGuard

    A value bound by a pattern guard must have a fixed runtime representation.

    Test cases: none.

  • FRRArrow !FRRArrowContext

    A representation-polymorphism check arising from arrow notation.

    See FRRArrowContext for more details.

  • FRRExpectedFunTy !ExpectedFunTyOrigin !Int

    A representation-polymorphic check arising from a call to matchExpectedFunTys or matchActualFunTy.

    See ExpectedFunTyOrigin for more details.

Instances1Outputable

Use this when you can't specify a helpful origin for some skolem type variable.

We're hoping to be able to get rid of this entirely, but for the moment it's still needed.

datadata SyntaxOpType
#

What to expect for an argument to a rebindable-syntax operator. Quite like Type, but allows for holes to be filled in by tcSyntaxOp. The callback called from tcSyntaxOp gets a list of types; the meaning of these types is determined by a left-to-right depth-first traversal of the SyntaxOpType tree. So if you pass in

SynAny `SynFun` (SynList `SynFun` SynType Int) `SynFun` SynAny

you'll get three types back: one for the first SynAny, the element type of the list, and one for the last SynAny. You don't get anything for the SynType, because you've said positively that it should be an Int, and so it shall be.

You'll also get three multiplicities back: one for each function arrow. See also Note [Linear types] in Multiplicity.

This is defined here to avoid defining it in GHC.Tc.Gen.Expr boot file.

Constructors

datadata InferResult
#

Constructors

  • IR
    • ir_uniq :: Unique

      This Unique is for debugging only

    • ir_lvl :: TcLevel

      See Note [TcLevel of ExpType] in GHC.Tc.Utils.TcMType

    • ir_frr :: Maybe FixedRuntimeRepContext

      See Note [FixedRuntimeRep context in ExpType] in GHC.Tc.Utils.TcMType

    • ir_ref :: IORef (Maybe TcType)

      The type that fills in this hole should be a Type, that is, its kind should be TYPE rr for some rr :: RuntimeRep.

      Additionally, if the ir_frr field is Just frr_orig then rr must be concrete, in the sense of Note [Concrete types] in GHC.Tc.Utils.Concrete.

Instances1Outputable
datadata PatersonSize
#

The Paterson size of a given type, in the sense of Note [Paterson conditions] in GHC.Tc.Validity

  • after expanding synonyms,

  • ignoring coercions (as they are not user written).

Constructors

  • PS_TyFam TyCon

    The type mentions a type family, so the size could be anything.

  • PS_Vanilla

    The type does not mention a type family.

    • ps_tvs :: [TyVar]

      free tyvars, including repetitions;

    • ps_size :: Int

      number of type constructors and variables

Instances1Outputable
valueambigTkvsOfTy :: TcType -> ([Var], [Var])
#

Returns the (kind, type) variables in a type that are as-yet-unknown: metavariables and RuntimeUnks

valueisFloatingPrimTy :: Type -> Bool
#

Is the type inhabited by machine floating-point numbers?

Used to check that we don't use floating-point literal patterns in Core.

See #9238 and Note [Rules for floating-point comparisons] in GHC.Core.Opt.ConstantFold.

valueisNextArgVisible :: TcType -> Bool
#

Should this type be applied to a visible argument? E.g. (s t): is t a visible argument of s?

When this says True, ignore this class constraint during a termination check See (PS1) in Note [The PatersonSize of a type]

valueisTyFamFree :: Type -> Bool
#

Check that a type does not contain any type family applications.

valuetcTyFamInsts :: Type -> [(TyCon, [Type])]
#

Finds outermost type-family applications occurring in a type, after expanding synonyms. In the list (F, tys) that is returned we guarantee that tys matches F's arity. For example, given type family F a :: * -> * (arity 1) calling tcTyFamInsts on (Maybe (F Int Bool) will return (F, [Int]), not (F, [Int,Bool])

This is important for its use in deciding termination of type instances (see #11581). E.g. type instance G [Int] = ...(F Int <big type>)... we don't need to take <big type> into account when asking if the calls on the RHS are smaller than the LHS

valuetcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])]
#

Like tcTyFamInsts, except that the output records whether the type family and its arguments occur as an invisible argument in some type application. This information is useful because it helps GHC know when to turn on -fprint-explicit-kinds during error reporting so that users can actually see the type family being mentioned.

As an example, consider:

class C a
data T (a :: k)
type family F a :: k
instance C (T @(F Int) (F Bool))

There are two occurrences of the type family F in that C instance, so tcTyFamInstsAndVis (C (T @(F Int) (F Bool))) will return:

[ (True,  F, [Int])
, (False, F, [Bool]) ]

F Int is paired with True since it appears as an invisible argument to C, whereas F Bool is paired with False since it appears an a visible argument to C.

See also Note [Showing invisible bits of types in error messages] in GHC.Tc.Errors.Ppr.

valuetyConVisibilities :: TyCon -> [Bool]
#

For every arg a tycon can take, the returned list says True if the argument is taken visibly, and False otherwise. Ends with an infinite tail of Trues to allow for oversaturation.

datadata PatersonCondFailure
#

Why did the Paterson conditions fail; that is, why was the context P not Paterson-smaller than the head H?

See Note [Paterson conditions] in GHC.Tc.Validity.

Constructors

  • PCF_TyVar [TyVar]

    Some type variables occur more often in P than in H. See (PC1) in Note [Paterson conditions] in GHC.Tc.Validity.

  • PCF_Size
  • PCF_TyFam TyCon

    P contains a type family. See (PC3) in Note [Paterson conditions] in GHC.Tc.Validity.

A TcSigmaTypeFRR is a TcSigmaType which has a syntactically fixed RuntimeRep in the sense of Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete.

In particular, this means that:

This property is important in functions such as matchExpectedFunTys, where we want to provide argument types which have a known runtime representation. See Note [Return arguments with a fixed RuntimeRep.

valueisInjectiveTyCon :: TyCon -> Role -> Bool
#

isInjectiveTyCon is true of TyCons for which this property holds (where r is the role passed in): If (T a1 b1 c1) ~r (T a2 b2 c2), then (a1 ~r1 a2), (b1 ~r2 b2), and (c1 ~r3 c2) (where r1, r2, and r3, are the roles given by tyConRolesX tc r) See also Note [Decomposing TyConApp equalities] in GHC.Tc.Solver.Equality

valuecloseOverKindsList :: [TyVar] -> [TyVar]
#

Add the kind variables free in the kinds of the tyvars in the given set. Returns a deterministically ordered list.

All type constructors occurring in the type; looking through type synonyms, but not newtypes. When it finds a Class, it returns the class TyCon.

valuecomposeTCvSubst :: Subst -> Subst -> Subst
#

Composes two substitutions, applying the second one provided first, like in function composition. This function leaves IdSubstEnv untouched because IdSubstEnv is not used during substitution for types.

valueisEmptyTCvSubst :: Subst -> Bool
#

Checks whether the tyvar and covar environments are empty. This function should be used over isEmptySubst when substituting for types, because types currently do not contain expressions; we can safely disregard the expression environment when deciding whether to skip a substitution. Using isEmptyTCvSubst gives us a non-trivial performance boost (up to 70% less allocation for T18223)

valuezapSubst :: Subst -> Subst
#

Remove all substitutions that might have been built up while preserving the in-scope set originally called zapSubstEnv

valuetidyVarBndrs :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar])
#

This tidies up a type for printing in an error message, or in an interface file.

It doesn't change the uniques at all, just the print names.

valueexpandSynTyCon_maybe
  1. :: TyCon
  2. -> [tyco]

    Arguments to TyCon

  3. -> ExpandSynResult tyco

    Returns a TyVar substitution, the body type of the synonym (not yet substituted) and any arguments remaining from the application ^ Expand a type synonym application Return Nothing if the TyCon is not a synonym, or if not enough arguments are supplied

#
valueisConcreteTyCon :: TyCon -> Bool
#

Is this TyCon concrete? More specifically, if tys are all concrete, is (T tys) concrete? (for synonyms this requires us to look at the RHS) Used for representation polymorphism checks. See Note [Concrete types] in GHC.Tc.Utils.Concrete

Is this a forgetful type synonym? If this is a type synonym whose RHS does not mention one (or more) of its bound variables, returns True. Thus, False means that all bound variables appear on the RHS; True may not mean anything, as the test to set this flag is conservative.

valueisTcTyCon :: TyCon -> Bool
#

Is this a TcTyCon? (That is, one only used during type-checking?)

Does this TyCon have a syntactically fixed RuntimeRep when fully applied, as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete?

False is safe. True means we're sure. Does only a quick check, based on the TyCon's category.

See Note [Representation-polymorphic TyCons]

True iff we can decompose (T a b c) into ((T a b) c) I.e. is it injective and generative w.r.t nominal equality? That is, if (T a b) ~N d e f, is it always the case that (T ~N d), (a ~N e) and (b ~N f)? Specifically NOT true of synonyms (open and otherwise)

It'd be unusual to call tyConMustBeSaturated on a regular H98 type synonym, because you should probably have expanded it first But regardless, it's not decomposable

valuecoAxNthLHS :: CoAxiom br -> Int -> Type
#

Get the type on the LHS of a coercion induced by a type/data family instance.

valuecoreFullView :: Type -> Type
#

Iterates coreView until there is no more to synonym to expand. NB: coreFullView is non-recursive and can be inlined; core_full_view is the recursive one See Note [Inlining coreView].

valuedropRuntimeRepArgs :: [Type] -> [Type]
#

Drops prefix of RuntimeRep constructors in TyConApps. Useful for e.g. dropping 'LiftedRep arguments of unboxed tuple TyCon applications:

dropRuntimeRepArgs [ 'LiftedRep, 'IntRep , String, Int# ] == [String, Int#]

valueexpandTypeSynonyms :: Type -> Type
#

Expand out all type synonyms. Actually, it'd suffice to expand out just the ones that discard type variables (e.g. type Funny a = Int) But we don't know which those are currently, so we just expand all.

expandTypeSynonyms only expands out type synonyms mentioned in the type, not in the kinds of any TyCon or TyVar mentioned in the type.

Keep this synchronized with synonymTyConsOfType

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

Just like piResultTys but for a single argument Try not to iterate piResultTy, because it's inefficient to substitute one variable at a time; instead use 'piResultTys"

Extract the Levity of a type. For example, getLevity Int = Lifted, or getLevity (Array# Int) = Unlifted.

Panics if this is not possible. Does not look through type family applications.

Extracts a list of run-time arguments from a function type, looking through newtypes to the right of arrows.

Examples:

   newtype Identity a = I a

   getRuntimeArgTys (Int -> Bool -> Double) == [(Int, FTF_T_T), (Bool, FTF_T_T)]
   getRuntimeArgTys (Identity Int -> Bool -> Double) == [(Identity Int, FTF_T_T), (Bool, FTF_T_T)]
   getRuntimeArgTys (Int -> Identity (Bool -> Identity Double)) == [(Int, FTF_T_T), (Bool, FTF_T_T)]
   getRuntimeArgTys (forall a. Show a => Identity a -> a -> Int -> Bool)
            == [(Show a, FTF_C_T), (Identity a, FTF_T_T),(a, FTF_T_T),(Int, FTF_T_T)]

Note that, in the last case, the returned types might mention an out-of-scope type variable. This function is used only when we really care about the kinds of the returned types, so this is OK.

  • *Warning**: this function can return an infinite list. For example:

  newtype N a = MkN (a -> N a)
  getRuntimeArgTys (N a) == repeat (a, FTF_T_T)
valueisAlgType :: Type -> Bool
#

See Type#type_classification for what an algebraic type is. Should only be applied to types, as opposed to e.g. partially saturated type constructors

valueisBoxedType :: Type -> Bool
#

See Type#type_classification for what a boxed type is. Panics on representation-polymorphic types; See mightBeUnliftedType for a more approximate predicate that behaves better in the presence of representation polymorphism.

valueisLinearType :: Type -> Bool
#

isLinear t returns True of a if t is a type of (curried) function where at least one argument is linear (or otherwise non-unrestricted). We use this function to check whether it is safe to eta reduce an Id in CorePrep. It is always safe to return True, because True deactivates the optimisation.

True = a term of this type cannot be bottom This identifies the types described by Note [NON-BOTTOM-DICTS invariant] in GHC.Core NB: unlifted types are not terminating types! e.g. you can write a term (loop 1)::Int# that diverges.

valueisTypeLikeKind :: Kind -> Bool
#

Is this kind equivalent to TYPE r (for some unknown r)?

This considers Constraint to be distinct from *.

Determine whether a type could be the type of a join point of given total arity, according to the polymorphism rule. A join point cannot be polymorphic in its return type, since given join j a b x y z = e1 in e2, the types of e1 and e2 must be the same, and a and b are not in scope for e2. (See Note [The polymorphism rule of join points] in GHC.Core.) Returns False also if the type simply doesn't have enough arguments.

Note that we need to know how many arguments (type *and* value) the putative join point takes; for instance, if j :: forall a. a -> Int then j could be a binary join point returning an Int, but it could *not* be a unary join point returning a -> Int.

TODO: See Note [Excess polymorphism and join points]

Check whether a kind is of the form `TYPE (BoxedRep Lifted)` or `TYPE (BoxedRep Unlifted)`.

Returns:

  • `Just Lifted` for `TYPE (BoxedRep Lifted)` and Type,

  • `Just Unlifted` for `TYPE (BoxedRep Unlifted)` and UnliftedType,

  • Nothing for anything else, e.g. `TYPE IntRep`, `TYPE (BoxedRep l)`, etc.

Extract the RuntimeRep classifier of a type from its kind. For example, kindRep * = LiftedRep; Panics if this is not possible. Treats * and Constraint as the same

Given a Levity, apply BoxedRep to it On the fly, rewrite BoxedRep Lifted --> liftedRepTy (a synonym) BoxedRep Unlifted --> unliftedRepTy (ditto) See Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim. See Note [Using synonyms to compress types] in GHC.Core.Type

valuemkFamilyTyConApp :: TyCon -> [Type] -> Type
#

Given a family instance TyCon and its arg types, return the corresponding family type. E.g:

data family T a
data instance T (Maybe b) = MkT b

Where the instance tycon is :RTL, so:

mkFamilyTyConApp :RTL Int  =  T (Maybe Int)

Given a `[RuntimeRep]`, apply TupleRep to it On the fly, rewrite TupleRep [] -> zeroBitRepTy (a synonym) See Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim. See Note [Using synonyms to compress types] in GHC.Core.Type

valuemkTyConBindersPreferAnon
  1. :: [TyVar]

    binders

  2. -> TyCoVarSet

    free variables of result

  3. -> [TyConBinder]
#

Given a list of type-level vars and the free vars of a result kind, makes PiTyBinders, preferring anonymous binders if the variable is, in fact, not dependent. e.g. mkTyConBindersPreferAnon (k:*),(b:k),(c:k) We want (k:*) Named, (b:k) Anon, (c:k) Anon

All non-coercion binders are visible.

valuenewTyConInstRhs :: TyCon -> [Type] -> Type
#

Unwrap one layer of newtype on a type constructor and its arguments, using an eta-reduced version of the newtype if possible. This requires tys to have at least newTyConInstArity tycon elements.

valuepartitionInvisibles :: [(a, ForAllTyFlag)] -> ([a], [a])
#

Given a list of things paired with their visibilities, partition the things into (invisible things, visible things).

Check whether a type (usually of kind RuntimeRep) is lifted, unlifted, or unknown. Returns Nothing if the type isn't of kind RuntimeRep.

`runtimeRepLevity_maybe rr` returns:

  • `Just Lifted` if rr is `LiftedRep :: RuntimeRep`

  • `Just Unlifted` if rr is definitely unlifted, e.g. IntRep

  • Nothing if not known (e.g. it's a type variable or a type family application).

valuesplitAppTy_maybe :: Type -> Maybe (Type, Type)
#

Attempt to take a type application apart, whether it is a function, type constructor, or plain type application. Note that type family applications are NEVER unsaturated by this!

valuesplitForAllTyVars :: Type -> ([TyVar], Type)
#

Like splitForAllTyCoVars, but split only for tyvars. 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.

(splitRuntimeRep_maybe rr) takes a Type rr :: RuntimeRep, and returns the (TyCon,[Type]) for the RuntimeRep, if possible, where the TyCon is one of the promoted DataCons of RuntimeRep. Remember: the unique on TyCon that is a a promoted DataCon is the same as the unique on the DataCon See Note [Promoted data constructors] in GHC.Core.TyCon May not be possible if rr is a type variable or type family application

valuetyConAppNeedsKindSig
  1. :: Bool

    Should specified binders count towards injective positions in the kind of the TyCon? (If you're using visible kind applications, then you want True here.

  2. -> TyCon
  3. -> Int

    The number of args the TyCon is applied to.

  4. -> Bool

    Does T t_1 ... t_n need a kind signature? (Where n is the number of arguments)

#

Does a TyCon (that is applied to some number of arguments) need to be ascribed with an explicit kind signature to resolve ambiguity if rendered as a source-syntax type? (See Note [When does a tycon application need an explicit kind signature?] for a full explanation of what this function checks for.)

Given a TyCon and a list of argument types to which the TyCon is applied, determine each argument's visibility (Inferred, Specified, or Required).

Wrinkle: consider the following scenario:

T :: forall k. k -> k
tyConForAllTyFlags T [forall m. m -> m -> m, S, R, Q]

After substituting, we get

T (forall m. m -> m -> m) :: (forall m. m -> m -> m) -> forall n. n -> n -> n

Thus, the first argument is invisible, S is visible, R is invisible again, and Q is visible.

valuetymult :: a -> Scaled a
#

Scale a payload by Many; used for type arguments in core

Returns True if a type has a syntactically fixed runtime rep, as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete.

This function is equivalent to `isFixedRuntimeRepKind . typeKind` but much faster.

Precondition: The type has kind (TYPE blah)

datadata TyCoMapper env (m :: Type -> Type)
#

This describes how a "map" operation over a type/coercion should behave

Constructors

This function identifies PromotedDataCon's from data constructors in `data T = K1 | K2`, promoted by -XDataKinds. These type constructors are printed with a tick mark 'K1 and 'K2, and similarly have a tick mark added to their OccName's.

In contrast, constructors in `type data T = K1 | K2` are printed and represented with their original undecorated names. See Note [Type data declarations] in GHC.Rename.Module

valueisDataTyCon :: TyCon -> Bool
#

Returns True for data types that are definitely represented by heap-allocated constructors. These are scrutinised by Core-level case expressions, and they get info tables allocated for them.

Generally, the function will be true for all data types and false for newtypes, unboxed tuples, unboxed sums and type family TyCons. But it is not guaranteed to return True in all cases that it could.

NB: for a data type family, only the instance TyCons get an info table. The family declaration TyCon does not

valueisImplicitTyCon :: TyCon -> Bool
#

Identifies implicit tycons that, in particular, do not go into interface files (because they are implicitly reconstructed when the interface is read).

Note that:

  • Associated families are implicit, as they are re-constructed from the class declaration in which they reside, and

  • Family instances are not implicit as they represent the instance body (similar to a dfun does that for a class instance).

  • Tuples are implicit iff they have a wired-in name (namely: boxed and unboxed tuples are wired-in and implicit, but constraint tuples are not)

valueisKindName :: Name -> Bool
#

This is Name really meant for use at the kind level? That is, should it be permitted wihout DataKinds?

valueisKindTyCon :: TyCon -> Bool
#

Is this TyCon really meant for use at the kind level? That is, should it be permitted without DataKinds?

valueisTupleTyCon :: TyCon -> Bool
#

Does this TyCon represent a tuple?

NB: when compiling Data.Tuple, the tycons won't reply True to isTupleTyCon, because they are built as AlgTyCons. However they get spat into the interface file as tuple tycons, so I don't think it matters.

Check if the tycon actually refers to a proper data or newtype with user defined constructors rather than one from a class or other construction.

valueisValidDTT2TyCon :: TyCon -> Bool
#

Returns True if a boxed type headed by the given TyCon satisfies condition DTT2 of Note [DataToTag overview] in GHC.Tc.Instance.Class

valueisVanillaAlgTyCon :: TyCon -> Bool
#

Returns True for vanilla AlgTyCons -- that is, those created with a data or newtype declaration.

valuemkPrimTyCon
  1. :: Name
  2. -> [TyConBinder]
  3. -> Kind

    result kind Must answer True to isFixedRuntimeRepKind (i.e., no representation polymorphism). (If you need a representation-polymorphic PrimTyCon, change tcHasFixedRuntimeRep, marshalablePrimTyCon, reifyTyCon for PrimTyCons.)

  4. -> [Role]
  5. -> TyCon
#

Create an primitive TyCon, such as Int#, Type or RealWorld Primitive TyCons are marshalable iff not lifted. If you'd like to change this, modify marshalablePrimTyCon.

Extracts the newtype coercion from such a TyCon, which can be used to construct something with the newtypes type from its representation type (right hand side). If the supplied TyCon is not a newtype, returns Nothing

valuenewTyConEtadArity :: TyCon -> Int
#

The number of type parameters that need to be passed to a newtype to resolve it. May be less than in the definition if it can be eta-contracted.

Like primElemRepSizeB but assumes pointers/words are 8 words wide.

This can be useful to compute the size of a rep as if we were compiling for a 64bit platform.

valueprimRepSizeB :: Platform -> PrimRep -> Int
#

The size of a PrimRep in bytes.

This applies also when used in a constructor, where we allow packing the fields. For instance, in data Foo = Foo Float# Float# the two fields will take only 8 bytes, which for 64-bit arch will be equal to 1 word. See also mkVirtHeapOffsetsWithPadding for details of how data fields are laid out.

valueprimRepSizeW64_B :: PrimRep -> Int
#

Like primRepSizeB but assumes pointers/words are 8 words wide.

This can be useful to compute the size of a rep as if we were compiling for a 64bit platform.

If the given TyCon has a single data constructor, i.e. it is a data type with one alternative, a tuple type or a newtype then that constructor is returned. If the TyCon has more than one constructor, or represents a primitive or function type constructor then Nothing is returned.

valuetyConSkolem :: TyCon -> Bool
#

Returns whether or not this TyCon is definite, or a hole that may be filled in at some later point. See Note [Skolem abstract data]

valuetyConStupidTheta :: TyCon -> [PredType]
#

Find the "stupid theta" of the TyCon. A "stupid theta" is the context to the left of an algebraic type declaration, e.g. Eq a in the declaration data Eq a => T a .... See Note [The stupid context] in GHC.Core.DataCon.

Extract those DataCons that we are able to learn about. Note that visibility in this sense does not correspond to visibility in the context of any particular user program!

valuepprTyThingHdr :: TyThing -> SDoc
#

Pretty-prints the TyThing header. For functions and data constructors the function is equivalent to pprTyThing but for type constructors and classes it prints only the header part of the declaration.

Pretty-prints a TyThing in context: that is, if the entity is a data constructor, record selector, or class method, then the entity's parent declaration is pretty-printed with irrelevant parts omitted.

data familydata family HsRecUpdParent x
#

Information about the parent of a record update:

  • the parent type constructor or pattern synonym,

  • the relevant con-likes,

  • the field labels.

Instances6Data, HsRecUpdParent
typetype PostTcTable = [(Name, PostTcExpr)]
#

Post-Type checking Table

We use a PostTcTable where there are a bunch of pieces of evidence, more than is convenient to keep individually.

Report Redundant Constraints.

Constructors

  • NoRRC

    Don't report redundant constraints

  • WantRRC SrcSpan

    Report redundant constraints The SrcSpan is for the constraints E.g. f :: (Eq a, Ord b) => blah The span is for the (Eq a, Ord b) We need to record the span here because we have long since discarded the HsType in favour of a Type

Instances1Eq
datadata FRRArrowContext
#

While typechecking arrow notation, in which context did a representation polymorphism check arise?

See FixedRuntimeRepContext for more general origins of representation polymorphism checks.

Constructors

  • ArrowCmdResTy !(HsCmd GhcRn)

    The result of an arrow command does not have a fixed runtime representation.

    Test case: RepPolyArrowCmd.

  • ArrowCmdApp !(HsCmd GhcRn) !(HsExpr GhcRn)

    The argument to an arrow in an arrow command application does not have a fixed runtime representation.

    Test cases: none.

  • ArrowCmdArrApp !(HsExpr GhcRn) !(HsExpr GhcRn) !HsArrAppType

    A function in an arrow application does not have a fixed runtime representation.

    Test cases: none.

  • ArrowCmdCase

    The scrutinee type in an arrow command case statement does not have a fixed runtime representation.

    Test cases: none.

  • ArrowFun !(HsExpr GhcRn)

    The overall type of an arrow proc expression does not have a fixed runtime representation.

    Test case: RepPolyArrowFun.

Instances1Outputable
datadata ArgPos
#

The position of an argument (to be reported in an error message).

Constructors

  • ArgPosInvis

    Invisible argument: don't report its position to the user.

  • ArgPosVis !Int

    Visible argument in i-th position.

datadata ExpectedFunTyOrigin
#

In what context are we calling matchExpectedFunTys or matchActualFunTy?

Used for two things:

  1. Reporting error messages which explain that a function has been given an unexpected number of arguments. Uses pprExpectedFunTyHerald. See Note [Herald for matchExpectedFunTys] in GHC.Tc.Utils.Unify.

  2. Reporting representation-polymorphism errors when a function argument doesn't have a fixed RuntimeRep as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete. Uses pprExpectedFunTyOrigin. See FixedRuntimeRepContext for the situations in which representation-polymorphism checks are performed.

Constructors

datadata RepPolyId
#

The description of a representation-polymorphic Id.

Constructors

typetype SafeOverlapping = Bool
#

Indicates if Instance met the Safe Haskell overlapping instances safety check.

See Note [Safe Haskell Overlapping Instances] in GHC.Tc.Solver See Note [Safe Haskell Overlapping Instances Implementation] in GHC.Tc.Solver