reasonml / reasonml/reason

(++) can't be used as an operator since it turns into (^)

Open
#2,309 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Problem:

The following OCaml input to refmt does not translate back to the same OCaml.

OCaml Input:

let (++) a b = a + b

Reason Output / Input:

let (++) = (a, b) => a + b;

OCaml Output:

let (^) a b = a + b

This means that libraries like notty can not be used, because they only define a (++) operator and no alternative function with a name.

Proposed solution:

Perhaps preserving all operators is impossible at this stage, but it'd be great if I didn't have to redefine operators because the OCaml output is different than what I'm expecting.

Alternatively, providing a cheatsheet of what operators will be replaced by what (and a way to circumvent it) would be a very nice gesture.

E.g,

Desc. Reason OCaml
String concatenation. (++) (^)
Value dereferencing. (^) (!)
Negation (!) not
Some custom operator ??? (++)

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 by running refmt on the provided (++) example and trace how the Reason output maps it back to OCaml. Determine whether custom operator names can round-trip without changing meaning, or whether the accepted mapping and a documented workaround must be defined. Done means the example no longer silently becomes (^), or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.