如何解决为什么不能为 F# 结构元组声明类型别名?
在 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)
“type S = struct (int * int)”的错误是编译器错误吗?
解决方法
尝试提交错误并在此处找到答案:https://github.com/dotnet/fsharp/issues/7014
类型周围需要括号:
type Alias = (struct(int * int))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。