Skip to content

Add a single-context-parens option (#288)#304

Merged
brandonchinn178 merged 1 commit intofourmolu:mainfrom
sgillespie:main
Mar 25, 2023
Merged

Add a single-context-parens option (#288)#304
brandonchinn178 merged 1 commit intofourmolu:mainfrom
sgillespie:main

Conversation

@sgillespie
Copy link
Copy Markdown
Contributor

This option controls parenthesis around constraints in type signatures when there is only one:

function1 :: C a => a
function2 :: (C a) => a

becomes

-- Always (default)
function1 :: (C a) => a
function1 :: (C a) => a

-- Never
function1 :: C a => a
function2 :: C a => a

-- Auto
function1 :: C a => a
function2 :: (C a) => a

This addresses #288. Note that always is the default, even though the issue suggests auto (ignore) be the default. I did this because Ormolu always adds parenthesis, and it would break some other tests.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2023

👋 @sgillespie
Thank you for raising your pull request.
Please make sure you have followed our contributing guidelines in DEVELOPER.md. We will review it as soon as possible!

Reviewer: Please verify the following things have been done, if applicable.

  • A file has been added to changelog.d/
  • "Configuration > Available options" section in README.md has been updated
  • "Configuration > Specifying configuration" section in README.md has been updated
  • Tests have been added

@sgillespie
Copy link
Copy Markdown
Contributor Author

OK, I just realized I didn't add the documentation above. Working on that now.

Copy link
Copy Markdown
Collaborator

@brandonchinn178 brandonchinn178 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Some minor comments, but should be good to go!

@@ -0,0 +1,3 @@
* Add a `single-constraint-parens` for controlling parenthesis around constraints in type
signatures. See [issue 288](https://github.com/fourmolu/fourmolu/pull/304)
* https://github.com/fourmolu/fourmolu/pull/304
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This is already linked in the first bullet, no need to add a second

README.md Outdated
| `unicode` | `always`, `detect`, **`never`** | Output Unicode syntax. With `detect` we output Unicode syntax exactly when the extension is seen to be enabled. When using `always`, make sure to have the `UnicodeSyntax` extension enabled, or Fourmolu will throw errors.
| `respectful` | **`true`**, `false` | Be less aggressive in reformatting input, e.g. keep empty lines in import list
| `fixities` | list of strings (**`[]`**) | See the "Language extensions, dependencies, and fixities" section below
| `single-constraint-parens`|**`always`**, `never`, `auto` | How to style optional parentheses around single constraints (`auto`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an unclosed parenthesis here. Also, can you add spaces around this pipe 🙃

Suggested change
| `single-constraint-parens`|**`always`**, `never`, `auto` | How to style optional parentheses around single constraints (`auto`
| `single-constraint-parens` | **`always`**, `never`, `auto` | How to style optional parentheses around single constraints (`auto`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback!

I've updated the changelog.d/ file and updated the formatting in the README. I did not add an explanation of all the options as I felt they were fairly straightforward, but please let me know if you disagree.

I'm not sure how you guys like to structure commits, so let me know if you want me to squash them into one.

Copy link
Copy Markdown
Collaborator

@brandonchinn178 brandonchinn178 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super small nit. If you don't get to it, I'll just merge and can fix at release.

Feel free to squash, or I can just squash when merging the PR. Thanks!

README.md Outdated
| `unicode` | `always`, `detect`, **`never`** | Output Unicode syntax. With `detect` we output Unicode syntax exactly when the extension is seen to be enabled. When using `always`, make sure to have the `UnicodeSyntax` extension enabled, or Fourmolu will throw errors.
| `respectful` | **`true`**, `false` | Be less aggressive in reformatting input, e.g. keep empty lines in import list
| `fixities` | list of strings (**`[]`**) | See the "Language extensions, dependencies, and fixities" section below
| `single-constraint-parens` | **`always`**, `never`, `auto` | How to style optional parentheses around single constraints
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think this would sound much better as "Whether to style optional parentheses ..."? "How" is a bit ambiguous

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, updated, and squashed

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.

2 participants