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.

reifyInstances nm tys returns a list of visible instances 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.

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:

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.

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 reccomended to use #line pragmas when
emitting C files, e.g.

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 ([| ... |]) but not
at the top level. As an example:

add1 :: Int -> Q Exp
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.

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

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.

dataToExpQ converts a value to a 'Q 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.

dataToPatQ converts a value to a 'Q 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.

Names can be constructed in several ways, which come with different
name-capture guarantees (see Language.Haskell.TH.Syntax 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.

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 because of
lack of interest.

When implementing antiquotation for quasiquoters, one often wants
to parse strings into expressions:

parse :: String -> Maybe Exp

But how should we parse a + b * c? If we don't know the fixities of
+ and *, we don't know whether to parse it as a + (b * c) or (a
+ b) * c.

In cases like this, use UInfixE, UInfixP, or UInfixT, which stand for
"unresolved infix expressionpatterntype", respectively. When the compiler
is given a splice containing a tree of UInfixE applications such as

UInfixE
(UInfixE e1 op1 e2)
op2
(UInfixE e3 op3 e4)

it will look up and the fixities of the relevant operators and
reassociate the tree as necessary.

trees will not be reassociated across ParensE, ParensP, or ParensT,
which are of use for parsing expressions like

The UInfixE constructor doesn't support sections. Sections
such as (a *) have no ambiguity, so InfixE suffices. For longer
sections such as (a + b * c -), use an InfixE constructor for the
outer-most section, and use UInfixE constructors for all
other operators:

InfixE
Just (UInfixE ...a + b * c...)
op
Nothing

Sections such as (a + b +) and ((a + b) +) should be rendered
into Exps differently:

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

(b) 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.

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

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.