[GHC] #9628: Add Annotations to the AST to simplify source to source conversions

GHC ghc-devs at haskell.org
Tue Sep 23 20:22:19 UTC 2014


#9628: Add Annotations to the AST to simplify source to source conversions
-------------------------------------+-------------------------------------
              Reporter:  alanz       |            Owner:  alanz
                  Type:  feature     |           Status:  new
  request                            |        Milestone:
              Priority:  normal      |          Version:  7.8.3
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Alan writes (in email): I have decided to first tackle adding a type
 parameter to the entire AST, so that tool writers can add custom
 information as required.  My first stab at this is to do is as follows
 {{{
 data HsModule r name
   = HsModule {
       ann :: r, -- ^ Annotation for external tool writers
       hsmodName :: Maybe (Located ModuleName),
         -- ^ @Nothing@: \"module X where\" is omitted (in which case the
 next
         --     field is Nothing too)
       hsmodExports :: Maybe [LIE name],
      ....
 }}}
 Salient points
  1. It comes as the first type parameter, and is called r
  2. It gets added as the first field of the syntax element
  3. It is always called ann
 Before undertaking this particular change, I would appreciate some
 feedback.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9628#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list