If we are always going to generate a parse tree with annotations from the parser, let’s not generate two!

 

I’m fine with always generating the annotations, but we just need to check that it doesn’t have insupportable costs.

 

Simon

 

From: Alan & Kim Zimmerman <alan.zimm@gmail.com>
Sent: 18 May 2018 15:31
To: Simon Peyton Jones <simonpj@microsoft.com>
Cc: ghc-devs <ghc-devs@haskell.org>
Subject: Re: TTG hsSyn for Batch and Interactive Parsing

 

 

 

On 18 May 2018 at 16:13, Simon Peyton Jones <simonpj@microsoft.com> wrote:

 

We can’t make the result type depend on DynFlags! (Yet)(

    parser :: DynFlags -> String

  -> HsSyn (GhcPass (Parsed (if …

                            then WithApiAnnotations

                            else WihoutsApiAnnotations)

 

We could conceptually have

 

  parser :: DynFlags -> String -> Either (HsSyn (Parsed WithApiAnnotations)) (HsSyn (Parsed NoApiAnnotations))

 

The main point is that the next phase can make use of either of the variants.

 

And it may be simplest to just always use the annotations, the ParsedSource is normally discarded after renaming anyway.

 

Alan