reasonml / reasonml/reason

Ternary formatting

Open
#1,987 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Assuming #1700 isn't implemented (I'm not against that change btw) can the formatting of ternaries be improved. For the common if/else formatting, it would preferable to follow facebook standard which is:

booleanCheck
  ? trueResult
  : falseResult;

which is far more readable vs. the current formatting:

booleanCheck ?
  trueResult : falseResult;

For the nested ternaries, I'd love to see a JS style pattern match layout used, though I'm sure this is more contentious. For instance:

booleanCheck1 
  ? trueResult1 :
booleanCheck2
  ? trueResult2 :
booleanCheck3
  ? trueResult3 :
fallbackResult;

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

The issue names no files, tests, or entry points. Start by locating the ternary-formatting implementation in the Reason codebase and compare its output with the two examples. Done means the common ternary layout matches the requested form; nested ternaries should be evaluated separately because the issue describes that pattern as contentious.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, 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.