Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to modify Anns / How to use addAnnotationsForPretty properly? #72

Open
kahlil29 opened this issue Jan 13, 2019 · 1 comment
Open

Comments

@kahlil29
Copy link

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 ?

@ocharles
Copy link

If you have parsed source code you don't need to use addAnnotationsForPretty - the annotations you have are already sufficient. You should just modify the annotations you got from parsing. If you share some source code, we can help more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants