Using the new-ish letops syntax, I'm trying to destructure a record type, assign a name to it, and provide a type annotation, all at the same time. I think doing so requires parentheses, like this (which is valid syntax that compiles correctly):
let* ({foo, bar}: Foo.t) as foobar = ...;
However, when the code is formatted, it reprints it as:
let* {foo, bar}: Foo.t as foobar = ...;
By removing the parentheses, the code no longer compiles and instead produces a syntax error.
Complete example:
module Foo = {
type t = {
foo: string,
bar: int,
};
let makeOpt = num => Some({foo: "a", bar: num});
};
let myFn = () => {
let ( let* ) = Belt.Option.flatMap;
let* a = Some(3);
let* ({foo, bar}: Foo.t) as foobar = Foo.makeOpt(a);
Some((foo, bar, foobar, a));
};
Using the new-ish letops syntax, I'm trying to destructure a record type, assign a name to it, and provide a type annotation, all at the same time. I think doing so requires parentheses, like this (which is valid syntax that compiles correctly):
However, when the code is formatted, it reprints it as:
By removing the parentheses, the code no longer compiles and instead produces a syntax error.
Complete example:
Melange playground link