<div dir="ltr"><div>Now that the landmines have hopefully been cleared from the AST via [1] I would like to propose changing the location information in the AST.<br><br></div><div>Right now the locations of syntactic markers such as do/let/where/in/of in the source are discarded from the AST, although they are retained in the rich token stream.<br>

<br></div><div>The haskell-src-exts package deals with this by means of using the SrcSpanInfo data type [2] which contains the SrcSpan as per the current GHC Located type but also has a list of SrcSpan s for the  syntactic markers, depending on the particular AST fragment being annotated.<br>

<br>In addition, the annotation type is provided as a parameter to the AST, so that it can be changed as required, see [3].<br><br>The motivation for this change is then<br><br></div><div>1. Simplify the roundtripping and modification of source by explicitly capturing the missing location information for the syntactic markers.<br>

<br></div><div>2. Allow the annotation to be a parameter so that it can be replaced with a different one in tools, for example HaRe would include the tokens for the AST fragment leaves.<br><br></div><div>3. Aim for some level compatibility with haskell-src-exts so that tools developed for it could be easily ported to GHC, for example exactprint [4].<br>

</div><div><br></div><div>I would like feedback as to whether this would be acceptable, or if the same goals should be achieved a different way.<br></div><div><br></div><div>Regards<br></div><div>  Alan<br></div><br><div>

<br>[1] <a href="https://phabricator.haskell.org/D157">https://phabricator.haskell.org/D157</a><br><br>[2] <a href="http://hackage.haskell.org/package/haskell-src-exts-1.15.0.1/docs/Language-Haskell-Exts-SrcLoc.html#t:SrcSpanInfo">http://hackage.haskell.org/package/haskell-src-exts-1.15.0.1/docs/Language-Haskell-Exts-SrcLoc.html#t:SrcSpanInfo</a><br>

<br>[3] <a href="http://hackage.haskell.org/package/haskell-src-exts-1.15.0.1/docs/Language-Haskell-Exts-Annotated-Syntax.html#t:Annotated">http://hackage.haskell.org/package/haskell-src-exts-1.15.0.1/docs/Language-Haskell-Exts-Annotated-Syntax.html#t:Annotated</a><br>

<br>[4] <a href="http://hackage.haskell.org/package/haskell-src-exts-1.15.0.1/docs/Language-Haskell-Exts-Annotated-ExactPrint.html#v:exactPrint">http://hackage.haskell.org/package/haskell-src-exts-1.15.0.1/docs/Language-Haskell-Exts-Annotated-ExactPrint.html#v:exactPrint</a><br>

<br></div></div>