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

GHC ghc-devs at haskell.org
Sat Oct 11 18:22:32 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.9
             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:  D297        |
-------------------------------------+-------------------------------------

Comment (by NeilMitchell):

 I had a slightly different design in mind.

 {{{
 data Ann = AnnModule
          | AnnWhere
          | AnnSemi
          | AnnOpen
          | AnnClose
 }}}

 Then you can basically have a function:

 {{{
 getAnnotation :: ASTNode -> Ann -> Maybe SrcSpan
 }}}

 You'd be down to only a single annotation. Things like Pragma could use
 AnnOpen for the {-# and AnnClose for the #-} bit. As long as you have a
 separate annotation constructor for each part of a pair, then everything
 is associated with a Maybe SrcSpan, and you don't have to pack the SrcSpan
 inside the Ann field.

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


More information about the ghc-tickets mailing list