TTG hsSyn for Batch and Interactive Parsing

Simon Peyton Jones simonpj at
Fri May 18 14:57:35 UTC 2018

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.


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

On 18 May 2018 at 16:13, Simon Peyton Jones <simonpj at<mailto:simonpj at>> 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list