Annotations

ghc-7.0.4: The GHC API

Annotations

Contents

- Main Annotation data types
- AnnEnv for collecting and querying Annotations

Synopsis

- data Annotation = Annotation {
  - ann_target :: CoreAnnTarget
  - ann_value :: Serialized
  }
- data AnnTarget name
  - = NamedTarget name
  - | ModuleTarget Module
- type CoreAnnTarget = AnnTarget Name
- getAnnTargetName_maybe :: AnnTarget name -> Maybe name
- data AnnEnv
- mkAnnEnv :: [Annotation] -> AnnEnv
- extendAnnEnvList :: AnnEnv -> [Annotation] -> AnnEnv
- plusAnnEnv :: AnnEnv -> AnnEnv -> AnnEnv
- emptyAnnEnv :: AnnEnv
- findAnns :: Typeable a => ([Word8] -> a) -> AnnEnv -> CoreAnnTarget -> [a]
- deserializeAnns :: Typeable a => ([Word8] -> a) -> AnnEnv -> UniqFM [a]

# Main Annotation data types

data Annotation

Represents an annotation after it has been sufficiently desugared from it's initial form of `HsDecls.AnnDecl`

Constructors

Annotation |
Fields ann_target :: CoreAnnTarget The target of the annotation ann_value :: Serialized `Serialized` version of the annotation that allows recovery of its value or can be persisted to an interface file

Instances

Outputable Annotation |

data AnnTarget name

An annotation target

Constructors

NamedTarget name | We are annotating something with a name: a type or identifier
ModuleTarget Module | We are annotating a particular module

Instances

Functor AnnTarget |
Outputable name => Outputable (AnnTarget name) |
Uniquable name => Uniquable (AnnTarget name) |
Binary name => Binary (AnnTarget name) |

type CoreAnnTarget = AnnTarget Name

The kind of annotation target found in the middle end of the compiler

getAnnTargetName_maybe :: AnnTarget name -> Maybe name

# AnnEnv for collecting and querying Annotations

data AnnEnv

A collection of annotations

mkAnnEnv :: [Annotation] -> AnnEnv

extendAnnEnvList :: AnnEnv -> [Annotation] -> AnnEnv

plusAnnEnv :: AnnEnv -> AnnEnv -> AnnEnv

emptyAnnEnv :: AnnEnv

findAnns :: Typeable a => ([Word8] -> a) -> AnnEnv -> CoreAnnTarget -> [a]

Find the annotations attached to the given target as `Typeable` values of your choice. If no deserializer is specified, only transient annotations will be returned.

deserializeAnns :: Typeable a => ([Word8] -> a) -> AnnEnv -> UniqFM [a]

Deserialize all annotations of a given type. This happens lazily, that is no deserialization will take place until the [a] is actually demanded and the [a] can also be empty (the UniqFM is not filtered).