reasonml / reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems
http://reasonml.github.io
MIT License
10.12k stars 428 forks source link

Feature request for `refmt`: Return types on anonymous functions #2589

Closed adamsmd closed 1 month ago

adamsmd commented 4 years ago

refmt moves the return types of anonymous functions after the body of the function, but I want it to put the type after the arguments of the function

Here is what I want:

(x: int): int => some_large_computation;

Here is what refmt produces:

(x: int) => (some_large_computation: int);

You can test this with:

echo '(x: int): int => some_large_computation' | refmt

I'd like refmt produce the first and not the second.

Note that ocamlformat recently made a similar change (see https://github.com/ocaml-ppx/ocamlformat/issues/1368). I don't know how much refmt piggybacks on ocamlformat so that change might already implement what I am requesting.