Supported Types: Each field in the record must be one of the supported
atomic types (String, Int, Integer, Float, Double, Bool, an
enumeration, a tuple of atomic types) or a list ([]) or Maybe wrapping
at atomic type.

Missing Fields: If a field is shared by multiple modes, it may be omitted
in subsequent modes, and will default to the previous value.

Purity: Values created with annotations are not pure - the first
time they are computed they will include the annotations, but subsequently
they will not. If you wish to run the above example in a more robust way:

Even using this scheme, sometimes GHC's optimisations may share values who
have the same annotation. To disable sharing you may need to specify
{-# OPTIONS_GHC -fno-cse #-} in the module you define the flags.

Pure annotations: Alternatively, you may use pure annotations, which are
referentially transparent, but less type safe and more verbose. The initial
example may be written as:

The Data class comprehends a fundamental primitive gfoldl for
folding over constructor applications, say terms. This primitive can
be instantiated in several ways to map over the immediate subterms
of a term; see the gmap combinators later in this class. Indeed, a
generic programmer does not necessarily need to use the ingenious gfoldl
primitive but rather the intuitive gmap combinators. The gfoldl
primitive is completed by means to query top-level constructors, to
turn constructor representations into proper terms, and to list all
possible datatype constructors. This completion allows us to serve
generic programming scenarios like read, show, equality, term generation.

The combinators gmapT, gmapQ, gmapM, etc are all provided with
default definitions in terms of gfoldl, leaving open the opportunity
to provide datatype-specific definitions.
(The inclusion of the gmap combinators as members of class Data
allows the programmer or the compiler to derive specialised, and maybe
more efficient code per datatype. Note: gfoldl is more higher-order
than the gmap combinators. This is subject to ongoing benchmarking
experiments. It might turn out that the gmap combinators will be
moved out of the class Data.)

Conceptually, the definition of the gmap combinators in terms of the
primitive gfoldl requires the identification of the gfoldl function
arguments. Technically, we also need to identify the type constructor
c for the construction of the result type from the folded term type.

In the definition of gmapQx combinators, we use phantom type
constructors for the c in the type of gfoldl because the result type
of a query does not involve the (polymorphic) type of the term argument.
In the definition of gmapQl we simply use the plain constant type
constructor because gfoldl is left-associative anyway and so it is
readily suited to fold a left-associative binary operation over the
immediate subterms. In the definition of gmapQr, extra effort is
needed. We use a higher-order accumulation trick to mediate between
left-associative constructor application vs. right-associative binary
operation (e.g., (:)). When the query is meant to compute a value
of type r, then the result type withing generic folding is r -> r.
So the result of folding is a function to which we finally pass the
right unit.

With the -XDeriveDataTypeable option, GHC can generate instances of the
Data class automatically. For example, given the declaration

Although the NameFlavour type is abstract, the Data instance is not. The reason for this
is that currently we use Data to serialize values in annotations, and in order for that to
work for Template Haskell names introduced via the 'x syntax we need gunfold on NameFlavour
to work. Bleh!

The long term solution to this is to use the binary package for annotation serialization and
then remove this instance. However, to do _that_ we need to wait on binary to become stable, since
boot libraries cannot be upgraded seperately from GHC itself.