(++) can't be used as an operator since it turns into (^)
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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