为什么无法为 F# 结构体元组声明类型别名?

cit*_*kid 1 f# valuetuple

在 F# 中不可能为结构体元组定义类型别名。只有通过解决方法,它才有效。

let x = struct (1, 2)
> val x : struct (int * int) = struct (1, 2)

let y : struct (int * int) = struct (4, 5) // explicit type
> val y : struct (int * int) = struct (4, 5)

type S = struct (int * int) // straight definition
> error FS0010: Unexpected symbol '(' in member definition

type S = ValueTuple<int, int> // workaround
> [<Struct>]
  type S = struct (int * int)
Run Code Online (Sandbox Code Playgroud)

“type S = struct (int * int)”的错误是编译器错误吗?

cit*_*kid 5

尝试提交错误并在这里找到答案:https ://github.com/dotnet/fsharp/issues/7014

类型周围需要括号:

type Alias = (struct(int * int))
Run Code Online (Sandbox Code Playgroud)