<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I don't remember the details precisely, but I do know that the BufSpan was added to allow for reliable comparisons of SrcSpans in the presence of #line pragams. I've included Vlad, who is the resident expert on this aspect of locations.<div class=""><br class=""></div><div class="">My instinct is to lean against repurposing the existing slot just because it happens to fit, unless there is a semantic argument for why the Maybe BufSpan and the Anchor represent the same underlying concept.<br class=""><div class=""><br class=""></div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 28, 2021, at 5:18 PM, Alan & Kim Zimmerman <<a href="mailto:alan.zimm@gmail.com" class="">alan.zimm@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">I have been updating the ghc-exactprint library for real world use cases on the about to be released GHC 9.2.1, and realised I need to be able to put an Anchor into every SrcSpan in the ParsedSource AST.</div><div class=""><br class=""></div><div class="">I prepared !6854 to sort it out in master and turned to the problem of GHC 9.2.1, where I had missed the boat.</div><div class=""><br class=""></div><div class="">And then I discovered that we have SrcSpan defined as</div><div class=""><br class=""></div><div class="">    data SrcSpan =<br class="">        RealSrcSpan !RealSrcSpan !(Maybe BufSpan)<br class="">      | UnhelpfulSpan !UnhelpfulSpanReason</div><div class=""><br class=""></div><div class="">and the (Maybe BufSpan) is only used for attaching haddock comments after parsing.</div><div class=""><br class=""></div><div class="">This means there is an isomorphism between the RealSrcSpan variant and an Anchor, which I take advantage of with the code in [1], by using the Maybe to encode the AnchorOperation and the BufSpan to encode the DeltaPos.</div><div class=""><br class=""></div><div class="">And it struck me that perhaps we should make this a more official approach.  The only problem is the detail of the BufSpan, to be able to play both roles cleanly.<br class=""></div><div class=""><br class=""></div><div class="">Alan<br class=""></div><div class=""><br class=""></div><div class="">[1] <a href="https://gist.github.com/alanz/5e262599ab79138606cdfcf3792ef635" class="">https://gist.github.com/alanz/5e262599ab79138606cdfcf3792ef635</a></div><div class=""><br class=""></div><div class=""><br class=""></div></div>
_______________________________________________<br class="">ghc-devs mailing list<br class=""><a href="mailto:ghc-devs@haskell.org" class="">ghc-devs@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs<br class=""></div></blockquote></div><br class=""></div></div></body></html>