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

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

Moduleghc-boot-th-10.0.0.20260917Haskell2010

GHC.Boot.TH.Syntax

  • 78 types
  • 39 values
valuemkName :: String -> Name
#

Generate a capturable name. Occurrences of such names will be resolved according to the Haskell scoping rules at the occurrence site.

For example:

f = [| pi + $(varE (mkName "pi")) |]
...
g = let pi = 3 in $f

In this case, g is desugared to

g = Prelude.pi + 3

Note that mkName may be used with qualified names:

mkName "Prelude.pi"

See also Language.Haskell.TH.Lib.dyn for a useful combinator. The above example could be rewritten using Language.Haskell.TH.Lib.dyn as

f = [| pi + $(dyn "pi") |]
valuenameBase :: Name -> String
#

The name without its module prefix.

Examples
Example3 expressions
nameBase ''Data.Either.Either"Either"nameBase (mkName "foo")"foo"nameBase (mkName "Module.foo")"foo"
valuenameModule :: Name -> Maybe String
#

Module prefix of a name, if it exists.

Examples
Example3 expressions
nameModule ''Data.Either.EitherJust "Data.Either"nameModule (mkName "foo")NothingnameModule (mkName "Module.foo")Just "Module"
valuenamePackage :: Name -> Maybe String
#

A name's package, if it exists.

Examples
Example3 expressions
namePackage ''Data.Either.EitherJust "base"namePackage (mkName "foo")NothingnamePackage (mkName "Module.foo")Nothing
valuenameSpace :: Name -> Maybe NameSpace
#

Returns whether a name represents an occurrence of a top-level variable (VarName), data constructor (DataName), type constructor, or type class (TcClsName). If we can't be sure, it returns Nothing.

Examples
Example5 expressions
nameSpace 'Prelude.idJust VarNamenameSpace (mkName "id")Nothing -- only works for top-level variable namesnameSpace 'Data.Maybe.JustJust DataNamenameSpace ''Data.Maybe.MaybeJust TcClsNamenameSpace ''Data.Ord.OrdJust TcClsName
datadata ForeignSrcLang
#

Foreign formats supported by GHC via TH

Constructors

Instances5Eq, Show, Generic, Lift, Rep
datadata Extension
#

The language extensions known to GHC.

Note that there is an orphan Binary instance for this type supplied by the GHC.LanguageExtensions module provided by ghc-boot. We can't provide here as this would require adding transitive dependencies to the template-haskell package, which must have a minimal dependency set.

CppOverlappingInstancesUndecidableInstancesIncoherentInstancesUndecidableSuperClassesMonomorphismRestrictionMonoLocalBindsDeepSubsumptionRelaxedPolyRecExtendedDefaultRulesNamedDefaultsForeignFunctionInterfaceUnliftedFFITypesInterruptibleFFICApiFFIGHCForeignImportPrimJavaScriptFFIParallelArraysArrowsTemplateHaskellTemplateHaskellQuotesQualifiedDoQuasiQuotesImplicitParamsImplicitPreludeScopedTypeVariablesAllowAmbiguousTypesUnboxedTuplesUnboxedSumsUnliftedNewtypesUnliftedDatatypesBangPatternsTypeFamiliesTypeFamilyDependenciesTypeInTypeOverloadedStringsOverloadedListsNumDecimalsDisambiguateRecordFieldsRecordWildCardsNamedFieldPunsViewPatternsOrPatternsGADTsGADTSyntaxNPlusKPatternsDoAndIfThenElseBlockArgumentsRebindableSyntaxConstraintKindsPolyKindsDataKindsTypeDataInstanceSigsApplicativeDoLinearTypesModifiersRequiredTypeArgumentsStandaloneDerivingDeriveDataTypeableAutoDeriveTypeableDeriveFunctorDeriveTraversableDeriveFoldableDeriveGenericDefaultSignaturesDeriveAnyClassDeriveLiftDerivingStrategiesDerivingViaTypeSynonymInstancesFlexibleContextsFlexibleInstancesConstrainedClassMethodsMultiParamTypeClassesNullaryTypeClassesFunctionalDependenciesUnicodeSyntaxExistentialQuantificationMagicHashEmptyDataDeclsKindSignaturesRoleAnnotationsParallelListCompTransformListCompMonadComprehensionsGeneralizedNewtypeDerivingRecursiveDoPostfixOperatorsTupleSectionsPatternGuardsLiberalTypeSynonymsRankNTypesImpredicativeTypesTypeOperatorsExplicitNamespacesPackageImportsExplicitForAllAlternativeLayoutRuleAlternativeLayoutRuleTransitionalDatatypeContextsNondecreasingIndentationRelaxedLayoutTraditionalRecordSyntaxLambdaCaseMultiWayIfBinaryLiteralsNegativeLiteralsHexFloatLiteralsDuplicateRecordFieldsOverloadedLabelsEmptyCasePatternSynonymsPartialTypeSignaturesNamedWildCardsStaticPointersTypeApplicationsStrictStrictDataEmptyDataDerivingNumericUnderscoresQuantifiedConstraintsStarIsTypeImportQualifiedPostCUSKsStandaloneKindSignaturesLexicalNegationFieldSelectorsOverloadedRecordDotOverloadedRecordUpdateTypeAbstractionsExtendedLiteralsListTuplePunsMultilineStringsExplicitLevelImportsImplicitStagePersistenceQualifiedStrings
Instances8Bounded, Enum, Eq, Ord, Show, Generic, …
datadata AnnLookup
#

Annotation target for reifyAnnotations

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata AnnTarget
#

The target of an ANN pragma

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Bang
#

Strictness information in a data constructor's argument.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
typetype BangType = (Bang, Type)
#

A type with a strictness annotation, as in data constructors. See Con.

datadata BndrVis
#

Visibility of a type variable. See Inferred vs. specified type variables.

Constructors

Instances8Eq, Data, Ord, Show, Generic, PprFlag, …
datadata Body
#

A potentially guarded expression, as in function definitions or case alternatives.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Bytes
#

Raw bytes embedded into the binary.

Avoid using Bytes constructor directly as it is likely to change in the future. Use helpers such as mkBytes in Language.Haskell.TH.Lib instead.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Callconv
#

A calling convention identifier, as in a Foreign declaration.

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Clause
#

A clause consists of patterns, guards, a body expression, and a list of declarations under a where. Clauses are seen in equations for function definitions, case-experssions, explicitly-bidirectional pattern synonyms, etc.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata Con
#

A data constructor.

The constructors for Con can roughly be divided up into two categories: those for constructors with "vanilla" syntax (NormalC, RecC, and InfixC), and those for constructors with GADT syntax (GadtC and RecGadtC). The ForallC constructor, which quantifies additional type variables and class contexts, can surround either variety of constructor. However, the type variables that it quantifies are different depending on what constructor syntax is used:

  • If a ForallC surrounds a constructor with vanilla syntax, then the ForallC will only quantify existential type variables. For example:

  data Foo a = forall b. MkFoo a b
  

In MkFoo, ForallC will quantify b, but not a.

  • If a ForallC surrounds a constructor with GADT syntax, then the ForallC will quantify all type variables used in the constructor. For example:

  data Bar a b where
    MkBar :: (a ~ b) => c -> MkBar a b
  

In MkBar, ForallC will quantify a, b, and c.

Multiplicity annotations for data types are currently not supported in Template Haskell (i.e. all fields represented by Template Haskell will be linear).

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
typetype Cxt = [Pred]
#

A context, as found on the left side of a => in a type.

datadata Dec
#

A single declaration.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata DecidedStrictness
#

Unlike SourceStrictness and SourceUnpackedness, DecidedStrictness refers to the strictness annotations that the compiler chooses for a data constructor field, which may be different from what is written in source code.

Note that non-unpacked strict fields are assigned DecidedLazy when a bang would be inappropriate, such as the field of a newtype constructor and fields that have an unlifted type.

See reifyConStrictness for more information.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata DerivClause
#

A single deriving clause at the end of a datatype declaration.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata DerivStrategy
#

What the user explicitly requests when deriving an instance with -XDerivingStrategies.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata DocLoc
#

A location at which to attach Haddock documentation. Note that adding documentation to a Name defined oustide of the current module will cause an error.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Exp
#

A Haskell expression.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata FamilyResultSig
#

Type family result signature

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata Fixity
#

Fixity, as specified in a infix[lr] n declaration.

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata FixityDirection
#

The associativity of an operator, as in an infix declaration.

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Foreign
#

A foreign declaration.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata FunDep
#

Functional dependency syntax, as in a class declaration.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata Guard
#

A single guard.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Info
#

Obtained from reify in the Q Monad.

Constructors

  • ClassI Dec [InstanceDec]

    A class, with a list of its visible instances

  • ClassOpI Name Type ParentName

    A class method

  • TyConI Dec

    A "plain" type constructor. "Fancier" type constructors are returned using PrimTyConI or FamilyI as appropriate. At present, this reified declaration will never have derived instances attached to it (if you wish to check for an instance, see reifyInstances).

  • FamilyI Dec [InstanceDec]

    A type or data family, with a list of its visible instances. A closed type family is returned with 0 instances.

  • PrimTyConI Name Arity Unlifted

    A "primitive" type constructor, which can't be expressed with a Dec. Examples: (->), Int#.

  • DataConI Name Type ParentName

    A data constructor

  • PatSynI Name PatSynType

    A pattern synonym

  • VarI Name Type (Maybe Dec)

    A "value" variable (as opposed to a type variable, see TyVarI).

    The Maybe Dec field contains Just the declaration which defined the variable - including the RHS of the declaration - or else Nothing, in the case where the RHS is unavailable to the compiler.

    At present, this value is always Nothing: returning the RHS has not yet been implemented and is tracked by GHC #14474.

  • TyVarI Name Type

    A type variable.

    The Type field contains the type which underlies the variable. At present, this is always VarT theName, but future changes may permit refinement of this.

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata InjectivityAnn
#

Injectivity annotation as in an injective type family

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata Inline
#

An inline pragma.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
typetype Kind = Type
#

To avoid duplication between kinds and types, they are defined to be the same. Naturally, you would never have a type be StarT and you would never have a kind be SigT, but many of the other constructors are shared. Note that the kind Bool is denoted with ConT, not PromotedT. Similarly, tuple kinds are made with TupleT, not PromotedTupleT.

datadata Lit
#

A Haskell literal. Note that the numeric types are all in terms of either Integer or Rational, regardless of the type they represent. The extra precision reflects the textual representation in source code.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata Loc
#

A location within a source file.

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata Match
#

A case-alternative

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
newtypenewtype ModName
#

The name of a module.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Module
#

Obtained from reifyModule and Language.Haskell.TH.Lib.thisModule.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata ModuleInfo
#

Obtained from reifyModule in the Q Monad.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Ppr, …
datadata Name
#

An abstract type representing names in the syntax tree.

Names can be constructed in several ways, which come with different name-capture guarantees (see Language.Haskell.TH.Syntax#namecapture for an explanation of name capture):

  • the built-in syntax 'f and ''T can be used to construct names, The expression 'f gives a Name which refers to the value f currently in scope, and ''T gives a Name which refers to the type T currently in scope. These names can never be captured.

  • lookupValueName and lookupTypeName are similar to 'f and ''T respectively, but the Names are looked up at the point where the current splice is being run. These names can never be captured.

  • newName monadically generates a new name, which can never be captured.

  • mkName generates a capturable name.

Names constructed using newName and mkName may be used in bindings (such as let x = ... or x -> ...), but names constructed using lookupValueName, lookupTypeName, 'f, ''T may not.

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata NameFlavour
#

Constructors

  • NameS

    An unqualified name; dynamically bound

  • NameQ ModName

    A qualified name; dynamically bound

  • NameU !Uniq

    A unique local name

  • NameL !Uniq

    Local name bound outside of the TH AST

  • NameG NameSpace PkgName ModName

    Global name bound outside of the TH AST: An original name (occurrences only, not binders) Need the namespace too to be sure which thing we are naming

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata NameSpace
#

Constructors

  • VarName

    Variables

  • DataName

    Data constructors

  • TcClsName

    Type constructors and classes; Haskell has them in the same name space for now.

  • FldName
    • fldParent :: !String

      The textual name of the parent of the field.

      • For a field of a datatype, this is the name of the first constructor of the datatype (regardless of whether this constructor has this field).

      • For a field of a pattern synonym, this is the name of the pattern synonym.

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata NamespaceSpecifier
#

A way to specify a namespace to look in when GHC needs to find a name's source

Constructors

  • NoNamespaceSpecifier

    Name may be everything; If there are two names in different namespaces, then consider both

  • TypeNamespaceSpecifier

    Name should be a type-level entity, such as a data type, type alias, type family, type class, or type variable

  • DataNamespaceSpecifier

    Name should be a term-level entity, such as a function, data constructor, or pattern synonym

Instances7Eq, Data, Ord, Show, Generic, Lift, …
newtypenewtype OccName
#

An "Occurence Name".

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Overlap
#

Varieties of allowed instance overlap.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Pat
#

Pattern in Haskell given in {}

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata PatSynArgs
#

A pattern synonym's argument type.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata PatSynDir
#

A pattern synonym's directionality.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
typetype PatSynType = Type
#

A pattern synonym's type. Note that a pattern synonym's fully specified type has a peculiar shape coming with two forall quantifiers and two constraint contexts. For example, consider the pattern synonym

pattern P x1 x2 ... xn = <some-pattern>

P's complete type is of the following form

pattern P :: forall universals.   required constraints
          => forall existentials. provided constraints
          => t1 -> t2 -> ... -> tn -> t

consisting of four parts:

  1. the (possibly empty lists of) universally quantified type variables and required constraints on them.

  2. the (possibly empty lists of) existentially quantified type variables and the provided constraints on them.

  3. the types t1, t2, .., tn of x1, x2, .., xn, respectively

  4. the type t of <some-pattern>, mentioning only universals.

Pattern synonym types interact with TH when (a) reifying a pattern synonym, (b) pretty printing, or (c) specifying a pattern synonym's type signature explicitly:

  • Reification always returns a pattern synonym's fully specified type in abstract syntax.

  • Pretty printing via Language.Haskell.TH.Ppr.pprPatSynType abbreviates a pattern synonym's type unambiguously in concrete syntax: The rule of thumb is to print initial empty universals and the required context as () =>, if existentials and a provided context follow. If only universals and their required context, but no existentials are specified, only the universals and their required context are printed. If both or none are specified, so both (or none) are printed.

  • When specifying a pattern synonym's type explicitly with PatSynSigD either one of the universals, the existentials, or their contexts may be left empty.

See the GHC user's guide for more information on pattern synonyms and their types: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pattern-synonyms.

datadata Phases
#

Phase control syntax.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
newtypenewtype PkgName
#

The name of a package.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata Pragma
#

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
typetype Pred = Type
#

Since the advent of ConstraintKinds, constraints are really just types. Equality constraints use the EqualityT constructor. Constraints may also be tuples of other constraints.

datadata Range
#

A list/enum range expression.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata Role
#

Role annotations

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata RuleBndr
#

A binder found in the forall of a RULES pragma.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata RuleMatch
#

A CONLIKE modifier, as in one of the various inline pragmas, or lack thereof (FunLike).

Constructors

  • ConLike
    { {-# CONLIKE [inline] ... #-} }
  • FunLike
    { {-# [inline] ... #-} }
Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata Safety
#

A safety level, as in a Foreign declaration.

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata SourceStrictness
#

SourceStrictness corresponds to strictness annotations found in the source code.

This may not agree with the annotations returned by reifyConStrictness. See reifyConStrictness for more information.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata SourceUnpackedness
#

SourceUnpackedness corresponds to unpack annotations found in the source code.

This may not agree with the annotations returned by reifyConStrictness. See reifyConStrictness for more information.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata Specificity
#

The specificity of a type variable in a forall ....

Instances8Eq, Data, Ord, Show, Generic, PprFlag, …
datadata Stmt
#

A single statement, as in do-notation.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata TyLit
#

Type-level literals.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata TySynEqn
#

One equation of a type family instance or closed type family. The arguments are the left-hand-side type and the right-hand-side result.

For instance, if you had the following type family:

type family Foo (a :: k) :: k where
  forall k (a :: k). Foo @k a = a

The Foo @k a = a equation would be represented as follows:

TySynEqn (Just [PlainTV k, KindedTV a (VarT k)])
           (AppT (AppKindT (ConT ''Foo) (VarT k)) (VarT a))
           (VarT a)

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
datadata TyVarBndr flag
#

The flag type parameter is instantiated to one of the following types:

Constructors

Instances11Functor, Foldable, Traversable, Lift, Eq, Data, …
datadata Type
#

A Haskell type.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata TypeFamilyHead
#

Common elements of OpenTypeFamilyD and ClosedTypeFamilyD. By analogy with "head" for type classes and type class instances as defined in Type classes: an exploration of the design space, the TypeFamilyHead is defined to be the elements of the declaration between type family and where.

Instances7Eq, Data, Ord, Show, Generic, Lift, …
typetype Uniq = Integer
#

Uniq is used by GHC to distinguish names from each other.