Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Incorrect conversion of custom fat arrow operator #98

Closed
jwhitley opened this issue Jun 1, 2019 · 2 comments
Closed

Incorrect conversion of custom fat arrow operator #98

jwhitley opened this issue Jun 1, 2019 · 2 comments

Comments

@jwhitley
Copy link

jwhitley commented Jun 1, 2019

Summary

refmt doesn't convert uses of an OCaml custom fat arrow operator let (=>) ... to Reason sensibly.

Details and Example

The opal parser combinator defines the infix operator =>: see opal.ml line 81.

refmt (and reason-tools) fail to convert this sanely, e.g.:

OCaml

let (=>) x f = x >>= fun r -> return (f r)

Reason

let (=>) = (x, f) => x >>= ((r) => return(f(r)));

The generated Reason code is invalid. Opal's custom fat-arrow operator is silently left unchanged, which collides with Reason's choice to switch arrow function definition from thin arrow to fat arrow. This causes obscure syntax errors later in the code at opal's point-of-use of its custom => operator. (See use in chainr1)

Suggestions

At minimum, refmt shouldn't let this invalid conversion pass silently – a warning or error should result. As crazy-making as it seems, a policy of swapping custom => (OCaml) for custom -> (Reason) would at least allow a consistent automatic conversion and be guaranteed to not collide with some other user-defined OCaml operator.

@andreypopp
Copy link
Collaborator

The correct repo for this issue is https://github.com/facebook/reason

@jwhitley
Copy link
Author

jwhitley commented Jun 1, 2019

Acknowledged and thanks. Closing this and reopening as reasonml/reason#2416.

@jwhitley jwhitley closed this as completed Jun 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants