Changes between Version 13 and Version 14 of TemplateHaskell/Annotations


Ignore:
Timestamp:
Oct 22, 2013 3:58:58 PM (22 months ago)
Author:
errge
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TemplateHaskell/Annotations

    v13 v14  
    8989{{{
    9090class Quasi where
    91   ...please fill in...
    92 }}}
     91  qReifyAnnotations :: Data a => AnnLookup -> m [a]
     92  qReifyModule      :: Module -> m ModuleInfo
     93
     94data AnnLookup = AnnLookupModule Module
     95               | AnnLookupName Name
     96               deriving( Show, Eq, Data, Typeable )
     97
     98data ModuleInfo =
     99  -- | Contains the import list of the module.
     100  ModuleInfo [Module]
     101  deriving( Show, Data, Typeable )
     102
     103data Module = Module PkgName ModName -- package qualified module name
     104 deriving (Show,Eq,Ord,Typeable,Data)
     105}}}
     106
     107We also propose to add the new `AnnP` data constructor to `data Pragma`:
     108{{{
     109data Pragma = InlineP         Name Inline RuleMatch Phases
     110            | SpecialiseP     Name Type (Maybe Inline) Phases
     111            | SpecialiseInstP Type
     112            | RuleP           String [RuleBndr] Exp Exp Phases
     113            | AnnP            AnnTarget Exp
     114
     115data AnnTarget = ModuleAnnotation
     116               | TypeAnnotation Name
     117               | ValueAnnotation Name
     118              deriving (Show, Eq, Data, Typeable)
     119}}}
     120
    93121These functions behave as follows:
    94122
    95 ... Fill in...
     123  - `AnnP` is very similar to the already existing pragma descriptors in `data Pragma`: it contains the target of the annotation and the payload as an `Exp`,
     124  - `qReifyAnnotation` is the dual of `AnnP`, it can be used to reify an annotation to get back the payload,
     125  - `qReifyModule` gives back the list of imports for the named module (in the future, it should reify more: maybe everything that is useful from the interface file).
    96126
    97127== Example ==