Skip to content

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

Description

@leostera

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 ??? (++)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions