Skip to content

Do not use rewrite to add new imports #1520

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

Closed
berberman opened this issue Mar 8, 2021 · 1 comment · Fixed by #1554
Closed

Do not use rewrite to add new imports #1520

berberman opened this issue Mar 8, 2021 · 1 comment · Fixed by #1554

Comments

@berberman
Copy link
Collaborator

hideImplicitPreludeSymbol, or newImport which I factored out in #1428, is really weird in my opinion. The goal is simple: to insert an import declaration, but it's a little bit tedious to express this in Rewrite -- we concatenate strings manually, parse it, adjust its annotations, and finally print it with exactPrint, which is kinda going round. Moreover, I don't think it accords with the semantic of rewriting ASTs: it rewrites nothing, but returns a new AST. The true rewriting in this case should be appending the new import declaration into the end of hsmodDecls, a part of HsModule, but it seems less resonable as well, so TextEdit could be the solution. I plan to remove newImport in my next PR.

Originally posted in #1512

@Ailrun
Copy link
Member

Ailrun commented Mar 8, 2021

CC: @alanz, as you are one of the main authors of ghc-exactprint library

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

Successfully merging a pull request may close this issue.

2 participants