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

Refactor how computation expressions are formatted #840

Merged
merged 7 commits into from
May 21, 2020

Conversation

nojaf
Copy link
Contributor

@nojaf nojaf commented May 17, 2020

The problem with the current implementation was that the SynExpr.LetOrUseBang could be part of a nested SynExpr.LetOrUse expression and that would mean that the first let bindings inside a computation expression are formatted somewhere else.

That made it hard to determine whether the first let! needed a newline before it.
In my proposed solution, I check whether the expression (inside the CompExpr) contains something related to a bang keyword let!, return!, and!, etc., if that is the case collect all expressions (and especially the let bindings).

Once all expressions are collected, merged them together using the colWithNlnWhenItemIsMultiline helper function.

This fixes #838 and should make Computation Expressions, in general, adhere to the rules when we add newlines between expressions.

@nojaf nojaf requested a review from jindraivanek May 17, 2020 10:55
@nojaf nojaf merged commit 02f3157 into fsprojects:master May 21, 2020
@nojaf nojaf deleted the fix-838 branch May 21, 2020 12:03
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

Successfully merging this pull request may close these issues.

Multiline let bang should have newline before
2 participants