Style suggestion: punning syntax for label arguments with casting coercion
This is a style suggestion to support the label punning when the labeled argument is casted with the :> syntax.
Current formatting Please copy-paste your code and the formatting that is currently applied to it.
let f ~x = x
let coerce_punning x = f ~(x : int)
let cast_coerce_punning x = f ~x:(x :> int)
The coerce_punning works already. The request is about the second item.
Describe the formatting you'd like A clear and concise description of what you want to happen.
let cast_coerce_punning x = f ~(x :> int)
Additional context
This is quite minor. This is motivated for more consistency. I don't know off-hand from which ocaml-version this punning syntax was supported. Thank you!
This seems to work with the to-be-released version. Do you confirm ?
I can't get it to work no. I tried the rev 5efba0c5db78fa00e11924829ae4ad38ad555176 and tried different combinations of:
ocaml-version = {5.4, 5.3}
profile = {janestreet, conventional}
Is there a particular setting to enable?
I'm looking at a function argument that looks like this:
~path:(path :> Fpath.t)
If I modify it to:
~(path :> Fpath.t)
ocamlformat re-add the original form, without the punning.
You are right! Changing ocaml-version doesn't make the new formatting stick. OCamlformat is not aware of this new syntax yet
Would you like to implement this new formatting ? I think this could be done by modifying fmt_label_arg at https://github.com/ocaml-ppx/ocamlformat/blob/main/lib/Fmt_ast.ml#L1717
We don't have a central place that defines the versions the various syntaxes were added in, but this could be added too.