reasonml / reasonml/reason

refmt: keep new line characters when using infix operators

Open
#2,465 1 comment 3 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

It is often more readable to have line breaks when using infix operators.

example 1

thing |> doFirstThing |> doSecondThing |> doThirdThing  |> doFourthThing;

// vs

thing
|> doFirstThing
|> doSecondThing
|> doThirdThing
|> doFourthThing;

example 2:

thing >>= doFirstThing >>= doSecondThing >>= doThirdThing >>= doFourthThing;

// vs

thing
>>= doFirstThing
>>= doSecondThing
>>= doThirdThing
>>= doFourthThing;

refmt currently forces you into the first example when there are less than 80 characters on the line. I'd like to allow both styles.

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's formatting logic for infix operators and locate the existing formatter tests. Compare the two styles shown in the issue, then verify that line breaks can be preserved while the current compact style remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.