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

Wingman inserts layout-breaking spaces when case-splitting in do block #1486

Closed
isovector opened this issue Mar 3, 2021 · 2 comments · Fixed by #1489
Closed

Wingman inserts layout-breaking spaces when case-splitting in do block #1486

isovector opened this issue Mar 3, 2021 · 2 comments · Fixed by #1489
Labels
component: wingman type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@isovector
Copy link
Collaborator

as reported by @jhrcek:

data Thing = A | B | C

getThing :: IO Thing
getThing = pure A

f :: Int -> IO ()
f i = do
    thing <- getThing
    _

this case splits to

f :: Int -> IO ()
f i = do
    thing <- getThing
     (case thing of
       A -> _
       B -> _
       C -> _
    )

but notice the leading space. In expressions it doesn't matter, but here YIKES.

Seems related to alanz/ghc-exactprint#91, except that we aren't calling addAnnotationsForPretty anymore. Maybe generated splices just need a setPrecedingLine (-1) 0 to get rid of this leading column?

@isovector isovector added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. component: wingman labels Mar 3, 2021
@isovector
Copy link
Collaborator Author

Also this makes it clear I need a better notion than "is top hole" to determine if parentheses are necessary.

@isovector
Copy link
Collaborator Author

Aha! This is the culprit!

let anns' = setPrecedingLines expr' 0 1 anns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wingman type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant