reasonml / reasonml/reason

[refmt] Refmt favors multiple lines for short tuples and lists

Open
#2,339 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Printer
Dominant language
OCaml
Stars
10.3k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

In general, I find this:

[123, 456789, 0]

easier to read than this:

[
  123,
  456789,
  0
]

In the case where this list is defined after a very long pattern match, for example, refmt prefers the multi-line approach, instead of having the full list definition on a single new line:

/* ideal, in my opinion */
| Some(VeryVeryVery(Loooooong(PatternMatch(_)))) =>
  [123, 456789, 0]

/* what refmt currently does */
| Some(VeryVeryVery(Loooooong(PatternMatch(_)))) => [
    123,
    456789,
    0
  ]

The same also applies to tuples (and probably arrays).

Here's a more complete playground example.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with refmt and reproduce the playground example using the short list and tuple cases after a long pattern match. Compare the current formatting with the requested single-line output, including the analogous array behavior if applicable; done means refmt consistently produces the preferred layout without regressing other formatting cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.