Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect conversion of custom fat arrow operator #2416

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

Incorrect conversion of custom fat arrow operator #2416

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.

A larger issue may exist around whether a automatic syntactic conversion even exists for this case. A potential workaround is not evident from the Reason docs.

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.

I attempted a naive swap of custom => (OCaml) for custom -> (Reason), but the thin-arrow definition simply produced a syntax error in the Reason code.

@anmonteiro
Copy link
Member

#1944 is open to address this

@anmonteiro
Copy link
Member

duplicate of #1941

@anmonteiro anmonteiro closed this as not planned Won't fix, can't repro, duplicate, stale Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants