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

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Moduletemplate-haskell-2.24.0.0Haskell2010

Language.Haskell.TH.Syntax

  • 81 types
  • 3 classes
  • 102 values
classclass Monad m => Quote (m :: Type -> Type) where
#

The Quote class implements the minimal interface which is necessary for desugaring quotations.

  • The Monad m superclass is needed to stitch together the different AST fragments.

  • newName is used when desugaring binding structures such as lambdas to generate fresh names.

Therefore the type of an untyped quotation in GHC is `Quote m => m Exp`

For many years the type of a quotation was fixed to be `Q Exp` but by more precisely specifying the minimal interface it enables the Exp to be extracted purely from the quotation without interacting with Q.

Methods

  • newName :: String -> m Name

    Generate a fresh name, which cannot be captured.

    For example, this:

    f = $(do
        nm1 <- newName "x"
        let nm2 = mkName "x"
        return (LamE [VarP nm1] (LamE [VarP nm2] (VarE nm1)))
       )

    will produce the splice

    f = \x0 -> \x -> x0

    In particular, the occurrence VarE nm1 refers to the binding VarP nm1, and is not captured by the binding VarP nm2.

    Although names generated by newName cannot be captured, they can capture other names. For example, this:

    g = $(do
      nm1 <- newName "x"
      let nm2 = mkName "x"
      return (LamE [VarP nm2] (LamE [VarP nm1] (VarE nm2)))
     )

    will produce the splice

    g = \x -> \x0 -> x0

    since the occurrence VarE nm2 is captured by the innermost binding of x, namely VarP nm1.

Instances2Quote
  • Quote QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • Quote IODefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
datadata Exp
#

A Haskell expression.

Constructors

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

A case-alternative

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
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, …
newtypenewtype Q a
#

In short, Q provides the Quasi operations in one neat monad for the user.

The longer story, is that Q wraps an arbitrary Quasi-able monad. The perceptive reader notices that Quasi has only two instances, Q itself and IO, neither of which have concrete implementations.Q plays the trick of dependency inversion, providing an abstract interface for the user which is later concretely fufilled by an concrete Quasi instance, internal to GHC.

Constructors

Instances10Monad, Functor, MonadFix, MonadFail, Applicative, Quote, …
  • Monad QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • Functor QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • MonadFix QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax

    If the function passed to mfix inspects its argument, the resulting action will throw a FixIOException.

  • MonadFail QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • Applicative QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • Quote QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • MonadIO QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • Quasi QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • Semigroup a => Semigroup (Q a)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • Monoid a => Monoid (Q a)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
datadata Pat
#

Pattern in Haskell given in {}

Constructors

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

A single statement, as in do-notation.

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, …
datadata Type
#

A Haskell type.

Constructors

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

A single declaration.

Constructors

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

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

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 FunDep
#

Functional dependency syntax, as in a class declaration.

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 RuleBndr
#

A binder found in the forall of a RULES pragma.

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 InjectivityAnn
#

Injectivity annotation as in an injective type family

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 Overlap
#

Varieties of allowed instance overlap.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
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, …
newtypenewtype Code (m :: Type -> Type) (a :: TYPE r)
#

Represents an expression which has type a, built in monadic context m. Built on top of TExp, typed expressions allow for type-safe splicing via:

  • typed quotes, written as [|| ... ||] where ... is an expression; if that expression has type a, then the quotation has type Quote m => Code m a

  • typed splices inside of typed quotes, written as $$(...) where ... is an arbitrary expression of type Quote m => Code m a

Traditional expression quotes and splices let us construct ill-typed expressions:

Example2 expressions
fmap ppr $ runQ (unTypeCode [| True == $( [| "foo" |] ) |])GHC.Internal.Types.True GHC.Internal.Classes.== "foo"GHC.Internal.Types.True GHC.Internal.Classes.== "foo"<interactive> error:    • Couldn't match expected type ‘Bool’ with actual type ‘[Char]’    • In the second argument of ‘(==)’, namely ‘"foo"’      In the expression: True == "foo"      In an equation for ‘it’: it = True == "foo"

With typed expressions, the type error occurs when constructing the Template Haskell expression:

Example1 expression
fmap ppr $ runQ (unTypeCode [|| True == $$( [|| "foo" ||] ) ||])<interactive> error:    • Couldn't match type ‘[Char]’ with ‘Bool’      Expected type: Code Q Bool        Actual type: Code Q [Char]    • In the Template Haskell quotation [|| "foo" ||]      In the expression: [|| "foo" ||]      In the Template Haskell splice $$([|| "foo" ||])

Constructors

newtypenewtype ModName
#

The name of a module.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Lift, …
valueaddCorePlugin :: String -> Q ()
#

Adds a core plugin to the compilation pipeline.

addCorePlugin m has almost the same effect as passing -fplugin=m to ghc in the command line. The major difference is that the plugin module m must not belong to the current package. When TH executes, it is too late to tell the compiler that we needed to compile first a plugin module in the current package.

valueaddDependentFile :: FilePath -> Q ()
#

Record external files that runIO is using (dependent upon). The compiler can then recognize that it should re-compile the Haskell file when an external file changes.

Expects an absolute file path.

Notes:

  • ghc -M does not know about these dependencies - it does not execute TH.

  • The dependency is based on file content, not a modification time

Emit a foreign file which will be compiled and linked to the object for the current module. Currently only languages that can be compiled with the C compiler are supported, and the flags passed as part of -optc will be also applied to the C compiler invocation that will compile them.

Note that for non-C languages (for example C++) extern C directives must be used to get symbols that we can access from Haskell.

To get better errors, it is recommended to use #line pragmas when emitting C files, e.g.

{-# LANGUAGE CPP #-}
...
addForeignSource LangC $ unlines
  [ "#line " ++ show (865 + 1) ++ " " ++ show "libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs"
  , ...
  ]
valueaddModFinalizer :: Q () -> Q ()
#

Add a finalizer that will run in the Q monad after the current module has been type checked. This only makes sense when run within a top-level splice.

The finalizer is given the local type environment at the splice point. Thus reify is able to find the local definitions when executed inside the finalizer.

valueaddTempFile :: String -> Q FilePath
#

Obtain a temporary file path with the given suffix. The compiler will delete this file after compilation.

valueaddTopDecls :: [Dec] -> Q ()
#

Add additional top-level declarations. The added declarations will be type checked along with the current declaration group.

valuebindCode :: Monad m => m a -> (a -> Code m b) -> Code m b
#

Variant of (>>=) which allows effectful computations to be injected into code generation.

valuebindCode_ :: Monad m => m a -> Code m b -> Code m b
#

Variant of (>>) which allows effectful computations to be injected into code generation.

valuegetDoc :: DocLoc -> Q (Maybe String)
#

Retrieves the Haddock documentation at the specified location, if one exists. It can be used to read documentation on things defined outside of the current module, provided that those modules were compiled with the -haddock flag.

Get the package root for the current package which is being compiled. This can be set explicitly with the -package-root flag but is normally just the current working directory.

The motivation for this flag is to provide a principled means to remove the assumption from splices that they will be executed in the directory where the cabal file resides. Projects such as haskell-language-server can't and don't change directory when compiling files but instead set the -package-root flag appropriately.

valuegetQ :: Typeable a => Q (Maybe a)
#

Get state from the Q monad. Note that the state is local to the Haskell module in which the Template Haskell expression is executed.

valuehoistCode :: Monad m => (forall x. m x -> n x) -> Code m a -> Code n a
#

Modify the ambient monad used during code generation. For example, you can use hoistCode to handle a state effect: handleState :: Code (StateT Int Q) a -> Code Q a handleState = hoistCode (flip runState 0)

valueisInstance :: Name -> [Type] -> Q Bool
#

Is the list of instances returned by reifyInstances nonempty?

If you're confused by an instance not being visible despite being defined in the same module and above the splice in question, see the docs for newDeclarationGroup for a possible explanation.

valuejoinCode :: Monad m => m (Code m a) -> Code m a
#

A useful combinator for embedding monadic actions into Code myCode :: ... => Code m a myCode = joinCode $ do x <- someSideEffect return (makeCodeWith x)

valueliftCode :: m (TExp a) -> Code m a
#

Lift a monadic action producing code into the typed Code representation

valuelocation :: Q Loc
#

The location at which this computation is spliced.

valuelookupTypeName :: String -> Q (Maybe Name)
#

Look up the given name in the (type namespace of the) current splice's scope. See Language.Haskell.TH.Syntax#namelookup for more details.

valuelookupValueName :: String -> Q (Maybe Name)
#

Look up the given name in the (value namespace of the) current splice's scope. See Language.Haskell.TH.Syntax#namelookup for more details.

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 dyn for a useful combinator. The above example could be rewritten using dyn as

f = [| pi + $(dyn "pi") |]
valueunTypeCode :: Quote m => Code m a -> m Exp
#

Extract the untyped representation from the typed representation

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
valuenewDeclarationGroup :: Q [Dec]
#

Template Haskell is capable of reifying information about types and terms defined in previous declaration groups. Top-level declaration splices break up declaration groups.

For an example, consider this code block. We define a datatype X and then try to call reify on the datatype.

module Check where

data X = X
    deriving Eq

$(do
    info <- reify ''X
    runIO $ print info
 )

This code fails to compile, noting that X is not available for reification at the site of reify. We can fix this by creating a new declaration group using an empty top-level splice:

data X = X
    deriving Eq

$(pure [])

$(do
    info <- reify ''X
    runIO $ print info
 )

We provide newDeclarationGroup as a means of documenting this behavior and providing a name for the pattern.

Since top level splices infer the presence of the $( ... ) brackets, we can also write:

data X = X
    deriving Eq

newDeclarationGroup

$(do
    info <- reify ''X
    runIO $ print info
 )
valueputDoc :: DocLoc -> String -> Q ()
#

Add Haddock documentation to the specified location. This will overwrite any documentation at the location if it already exists. This will reify the specified name, so it must be in scope when you call it. If you want to add documentation to something that you are currently splicing, you can use addModFinalizer e.g.

do
  let nm = mkName "x"
  addModFinalizer $ putDoc (DeclDoc nm) "Hello"
  [d| $(varP nm) = 42 |]

The helper functions withDecDoc and withDecsDoc will do this for you, as will the funD_doc and other _doc combinators. You most likely want to have the -haddock flag turned on when using this. Adding documentation to anything outside of the current module will cause an error.

valueputQ :: Typeable a => a -> Q ()
#

Replace the state in the Q monad. Note that the state is local to the Haskell module in which the Template Haskell expression is executed.

valuerecover
  1. :: Q a

    handler to invoke on failure

  2. -> Q a

    computation to run

  3. -> Q a
#

Recover from errors raised by reportError or fail.

valuereify :: Name -> Q Info
#

reify looks up information about the Name. It will fail with a compile error if the Name is not visible. A Name is visible if it is imported or defined in a prior top-level declaration group. See the documentation for newDeclarationGroup for more details.

It is sometimes useful to construct the argument name using lookupTypeName or lookupValueName to ensure that we are reifying from the right namespace. For instance, in this context:

data D = D

which D does reify (mkName "D") return information about? (Answer: D-the-type, but don't rely on it.) To ensure we get information about D-the-value, use lookupValueName:

do
  Just nm <- lookupValueName "D"
  reify nm

and to get information about D-the-type, use lookupTypeName.

valuereifyAnnotations :: Data a => AnnLookup -> Q [a]
#

reifyAnnotations target returns the list of annotations associated with target. Only the annotations that are appropriately typed is returned. So if you have Int and String annotations for the same target, you have to call this function twice.

reifyConStrictness nm looks up the strictness information for the fields of the constructor with the name nm. Note that the strictness information that reifyConStrictness returns may not correspond to what is written in the source code. For example, in the following data declaration:

data Pair a = Pair a a

reifyConStrictness would return [DecidedLazy, DecidedLazy] under most circumstances, but it would return [DecidedStrict, DecidedStrict] if the -XStrictData language extension was enabled.

valuereifyFixity :: Name -> Q (Maybe Fixity)
#

reifyFixity nm attempts to find a fixity declaration for nm. For example, if the function foo has the fixity declaration infixr 7 foo, then reifyFixity 'foo would return Just (Fixity 7 InfixR). If the function bar does not have a fixity declaration, then reifyFixity 'bar returns Nothing, so you may assume bar has defaultFixity.

valuereifyInstances :: Name -> [Type] -> Q [InstanceDec]
#

reifyInstances nm tys returns a list of all visible instances (see below for "visible") of nm tys. That is, if nm is the name of a type class, then all instances of this class at the types tys are returned. Alternatively, if nm is the name of a data family or type family, all instances of this family at the types tys are returned.

Note that this is a "shallow" test; the declarations returned merely have instance heads which unify with nm tys, they need not actually be satisfiable.

  • reifyInstances ''Eq [ TupleT 2 `AppT` ConT ''A `AppT` ConT ''B ] contains the instance (Eq a, Eq b) => Eq (a, b) regardless of whether A and B themselves implement Eq

  • reifyInstances ''Show [ VarT (mkName "a") ] produces every available instance of Show

There is one edge case: reifyInstances ''Typeable tys currently always produces an empty list (no matter what tys are given).

In principle, the *visible* instances are * all instances defined in a prior top-level declaration group (see docs on newDeclarationGroup), or * all instances defined in any module transitively imported by the module being compiled

However, actually searching all modules transitively below the one being compiled is unreasonably expensive, so reifyInstances will report only the instance for modules that GHC has had some cause to visit during this compilation. This is a shortcoming: reifyInstances might fail to report instances for a type that is otherwise unusued, or instances defined in a different component. You can work around this shortcoming by explicitly importing the modules whose instances you want to be visible. GHC issue #20529 has some discussion around this.

valuereifyRoles :: Name -> Q [Role]
#

reifyRoles nm returns the list of roles associated with the parameters (both visible and invisible) of the tycon nm. Fails if nm cannot be found or is not a tycon. The returned list should never contain InferR.

An invisible parameter to a tycon is often a kind parameter. For example, if we have

type Proxy :: forall k. k -> Type
data Proxy a = MkProxy

and reifyRoles Proxy, we will get [NominalR, PhantomR]. The NominalR is the role of the invisible k parameter. Kind parameters are always nominal.

valuereifyType :: Name -> Q Type
#

reifyType nm attempts to find the type or kind of nm. For example, reifyType 'not returns Bool -> Bool, and reifyType ''Bool returns Type. This works even if there's no explicit signature and the type or kind is inferred.

valuereport :: Bool -> String -> Q ()
#

Deprecated. Use reportError or reportWarning instead

Report an error (True) or warning (False), but carry on; use fail to stop.

valuereportError :: String -> Q ()
#

Report an error to the user, but allow the current splice's computation to carry on. To abort the computation, use fail.

valuerunIO :: IO a -> Q a
#

The runIO function lets you run an I/O computation in the Q monad. Take care: you are guaranteed the ordering of calls to runIO within a single Q computation, but not about the order in which splices are run.

Note: for various murky reasons, stdout and stderr handles are not necessarily flushed when the compiler finishes running, so you should flush them yourself.

valuesequenceQ :: Monad m => forall a. [m a] -> m [a]
#

This function is only used in GHC.HsToCore.Quote when desugaring brackets. This is not necessary for the user, who can use the ordinary return and (>>=) operations.

valuerunQ :: Quasi m => Q a -> m a
#

"Runs" the Q monad. Normal users of Template Haskell should not need this function, as the splice brackets $( ... ) are the usual way of running a Q computation.

This function is primarily used in GHC internals, and for debugging splices by running them in IO.

Note that many functions in Q, such as reify and other compiler queries, are not supported when running Q in IO; these operations simply fail at runtime. Indeed, the only operations guaranteed to succeed are newName, runIO, reportError and reportWarning.

valueunTypeQ :: Quote m => m (TExp a) -> m Exp
#

Discard the type annotation and produce a plain Template Haskell expression

Representation-polymorphic since template-haskell-2.16.0.0.

valueunsafeTExpCoerce :: Quote m => m Exp -> m (TExp a)
#

Annotate the Template Haskell expression with a type

This is unsafe because GHC cannot check for you that the expression really does have the type you claim it has.

Representation-polymorphic since template-haskell-2.16.0.0.

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.

CppOverlappingInstancesUndecidableInstancesIncoherentInstancesUndecidableSuperClassesMonomorphismRestrictionMonoLocalBindsDeepSubsumptionRelaxedPolyRecExtendedDefaultRulesNamedDefaultsForeignFunctionInterfaceUnliftedFFITypesInterruptibleFFICApiFFIGHCForeignImportPrimJavaScriptFFIParallelArraysArrowsTemplateHaskellTemplateHaskellQuotesQualifiedDoQuasiQuotesImplicitParamsImplicitPreludeScopedTypeVariablesAllowAmbiguousTypesUnboxedTuplesUnboxedSumsUnliftedNewtypesUnliftedDatatypesBangPatternsTypeFamiliesTypeFamilyDependenciesTypeInTypeOverloadedStringsOverloadedListsNumDecimalsDisambiguateRecordFieldsRecordWildCardsNamedFieldPunsViewPatternsOrPatternsGADTsGADTSyntaxNPlusKPatternsDoAndIfThenElseBlockArgumentsRebindableSyntaxConstraintKindsPolyKindsDataKindsTypeDataInstanceSigsApplicativeDoLinearTypesRequiredTypeArgumentsStandaloneDerivingDeriveDataTypeableAutoDeriveTypeableDeriveFunctorDeriveTraversableDeriveFoldableDeriveGenericDefaultSignaturesDeriveAnyClassDeriveLiftDerivingStrategiesDerivingViaTypeSynonymInstancesFlexibleContextsFlexibleInstancesConstrainedClassMethodsMultiParamTypeClassesNullaryTypeClassesFunctionalDependenciesUnicodeSyntaxExistentialQuantificationMagicHashEmptyDataDeclsKindSignaturesRoleAnnotationsParallelListCompTransformListCompMonadComprehensionsGeneralizedNewtypeDerivingRecursiveDoPostfixOperatorsTupleSectionsPatternGuardsLiberalTypeSynonymsRankNTypesImpredicativeTypesTypeOperatorsExplicitNamespacesPackageImportsExplicitForAllAlternativeLayoutRuleAlternativeLayoutRuleTransitionalDatatypeContextsNondecreasingIndentationRelaxedLayoutTraditionalRecordSyntaxLambdaCaseMultiWayIfBinaryLiteralsNegativeLiteralsHexFloatLiteralsDuplicateRecordFieldsOverloadedLabelsEmptyCasePatternSynonymsPartialTypeSignaturesNamedWildCardsStaticPointersTypeApplicationsStrictStrictDataEmptyDataDerivingNumericUnderscoresQuantifiedConstraintsStarIsTypeImportQualifiedPostCUSKsStandaloneKindSignaturesLexicalNegationFieldSelectorsOverloadedRecordDotOverloadedRecordUpdateTypeAbstractionsExtendedLiteralsListTuplePunsMultilineStringsExplicitLevelImportsImplicitStagePersistence
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, …
datadata BndrVis
#

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

Constructors

Instances9Eq, 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, …
typetype Cxt = [Pred]
#

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

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 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 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 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 Inline
#

An inline pragma.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
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 Module
#

Obtained from reifyModule and 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 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 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 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, …
classclass (MonadIO m, MonadFail m) => Quasi (m :: Type -> Type) where
#

Methods

Instances2Quasi
  • Quasi QDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
  • Quasi IODefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Syntax
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 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 ....

Instances9Eq, Data, Ord, Show, Generic, PprFlag, …
newtypenewtype TExp (a :: TYPE r)
#

Typed wrapper around an Exp.

This is the typed representation of terms produced by typed quotes.

Representation-polymorphic since template-haskell-2.16.0.0.

Constructors

Instances1Lift
  • Lift (TExp a)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
datadata TyLit
#

Type-level literals.

Constructors

Instances8Eq, Data, Ord, Show, Generic, Ppr, …
datadata TyVarBndr flag
#

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

Constructors

Instances11Functor, Foldable, Traversable, Lift, Eq, Data, …
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.

classclass Lift (t :: TYPE r) where
#

A Lift instance can have any of its values turned into a Template Haskell expression. This is needed when a value used within a Template Haskell quotation is bound outside the Oxford brackets ([| ... |] or [|| ... ||]) but not at the top level. As an example:

add1 :: Int -> Code Q Int
add1 x = [|| x + 1 ||]

Template Haskell has no way of knowing what value x will take on at splice-time, so it requires the type of x to be an instance of Lift.

A Lift instance must satisfy $(lift x) ≡ x and $$(liftTyped x) ≡ x for all x, where $(...) and $$(...) are Template Haskell splices. It is additionally expected that lift x ≡ unTypeCode (liftTyped x).

Lift instances can be derived automatically by use of the -XDeriveLift GHC language extension:

{-# LANGUAGE DeriveLift #-}
module Foo where

import Language.Haskell.TH.Syntax

data Bar a = Bar1 a (Bar a) | Bar2 String
  deriving Lift

Representation-polymorphic since template-haskell-2.16.0.0.

This is exposed both from the template-haskell-lift and template-haskell packages. Consider importing it from the more stable template-haskell-lift if you don't need the full breadth of the template-haskell interface.

Methods

  • lift :: Quote m => t -> m Exp

    Turn a value into a Template Haskell expression, suitable for use in a splice.

  • liftTyped :: Quote m => t -> Code m t

    Turn a value into a Template Haskell typed expression, suitable for use in a typed splice.

Instances110Lift, …
  • Lift ByteArrayDefined in base-4.22.0.0 · Data.Array.Byte
  • Lift VoidDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift IntegerDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift ForeignSrcLangDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Int16Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Int32Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Int64Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Int8Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift ExtensionDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Addr#Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift

    Produces an Addr# literal from the NUL-terminated C-string starting at the given memory address.

  • Lift Char#Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Double#Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Float#Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Int#Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Word#Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift AnnLookupDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift AnnTargetDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift BangDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift BndrVisDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift BodyDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift BytesDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift CallconvDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift ClauseDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift ConDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift DecDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift DecidedStrictnessDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift DerivClauseDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift DerivStrategyDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift DocLocDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift ExpDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift FamilyResultSigDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift FixityDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift FixityDirectionDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift ForeignDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift FunDepDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift GuardDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift InfoDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift InjectivityAnnDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift InlineDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift LitDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift LocDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift MatchDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift ModNameDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift ModuleDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift NameDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift NameFlavourDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift NameIsDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift NameSpaceDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift NamespaceSpecifierDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift OccNameDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift OverlapDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift PatDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift PatSynArgsDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift PatSynDirDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift PhasesDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift PkgNameDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift PragmaDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift RangeDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift RoleDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift RuleBndrDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift RuleMatchDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift SafetyDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift SourceStrictnessDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift SourceUnpackednessDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift SpecificityDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift StmtDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift TyLitDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift TySynEqnDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift TypeDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift TypeFamilyHeadDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift BoolDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift CharDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift DoubleDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift FloatDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift IntDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift WordDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Word16Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Word32Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Word64Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift Word8Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift ()Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift (# #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Integral a => Lift (Ratio a)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift a => Lift (NonEmpty a)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift a => Lift (Maybe a)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift a => Lift (TyVarBndr a)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift a => Lift [a]Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift (Fixed a)Defined in base-4.22.0.0 · Data.Fixed
  • Lift (TExp a)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b) => Lift (Either a b)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b) => Lift (a, b)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c) => Lift (a, b, c)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d) => Lift (a, b, c, d)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d, Lift e) => Lift (a, b, c, d, e)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) => Lift (a, b, c, d, e, f)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) => Lift (a, b, c, d, e, f, g)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • Lift a => Lift (# a #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b) => Lift (# a, b #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b) => Lift (# a | b #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c) => Lift (# a, b, c #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c) => Lift (# a | b | c #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d) => Lift (# a, b, c, d #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d) => Lift (# a | b | c | d #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d, Lift e) => Lift (# a, b, c, d, e #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d, Lift e) => Lift (# a | b | c | d | e #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) => Lift (# a, b, c, d, e, f #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) => Lift (# a | b | c | d | e | f #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) => Lift (# a, b, c, d, e, f, g #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) => Lift (# a | b | c | d | e | f | g #)Defined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
valuedataToExpQ
  1. :: (Quote m, Data a)
  2. => forall b. Data b => b -> Maybe (m Exp)
  3. -> a
  4. -> m Exp
#

dataToExpQ converts a value to a Exp representation of the same value, in the SYB style. It is generalized to take a function override type-specific cases; see liftData for a more commonly used variant.

valuedataToPatQ
  1. :: (Quote m, Data a)
  2. => forall b. Data b => b -> Maybe (m Pat)
  3. -> a
  4. -> m Pat
#

dataToPatQ converts a value to a Pat representation of the same value, in the SYB style. It takes a function to handle type-specific cases, alternatively, pass const Nothing to get default behavior.

valuedataToQa
  1. :: (Quote m, Data a)
  2. => Name -> k
  3. -> Lit -> m q
  4. -> k -> [m q] -> m q
  5. -> forall b. Data b => b -> Maybe (m q)
  6. -> a
  7. -> m q
#

dataToQa is an internal utility function for constructing generic conversion functions from types with Data instances to various quasi-quoting representations. See the source of dataToExpQ and dataToPatQ for two example usages: mkCon, mkLit and appQ are overloadable to account for different syntax for expressions and patterns; antiQ allows you to override type-specific cases, a common usage is just const Nothing, which results in no overloading.