8000 How to modify Anns / How to use `addAnnotationsForPretty` properly? · Issue #72 · alanz/ghc-exactprint · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
How to modify Anns / How to use addAnnotationsForPretty properly?  #72
@kahlil29

Description

@kahlil29

I'm using ghc-exactprint to modify some source code.
I parse a haskell module using parseModuleFromString and obtain (Anns, ParsedSource)

Then I modify that ParsedSource and obtain a new ParsedSource.
I tried using addAnnotationsForPretty in the following manner:

Right (oldAnns, parsedSrc) -> do
      let newSrc = someModificationFunction parsedSrc
      let newAnns = addAnnotationsForPretty [] newSrc oldAnns
      pure $ exactPrint newSrc newAnns

When I do this, the file is printed without language extensions and formatting is lost (I'm guessing that since the modified annotations don't match with the new ParsedSource, the annotations are being discarded/not being modified as expected by addAnnotationsForPretty.

What is the best way to modify the existing annotations in order for them to match up/make sense/accomodate for the changes in the ParsedSource ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0