【发布时间】:2020-05-27 12:01:33
【问题描述】:
我正在阅读 Friendly F#,书中有这段代码
[<Measure>]
type Vector2<[<Measure>]'a> =
{
X: float<'a>
Y: float<'a>
}
因此,此代码旨在与 F# 和 VS 2010 一起使用。我目前正在使用 VS2012。
VS2012 显示错误。这是 F# 版本的问题吗?如果是这样,正确的方法是什么?
它显示的错误是:
Error 4 A type definition requires one or more members or other declarations. If you intend to define an empty class, struct or interface, then use 'type ... = class end', 'interface end' or 'struct end'.
【问题讨论】:
-
有什么问题?
-
2012年,代码显示错误。我应该把它放在 OP 中。
-
如果您正在运行书中的小示例,我建议您尝试 VSCode + Ionide。它对 F# 脚本具有出色的支持,这意味着您可以通过将代码直接发送到 REPL 来执行代码,绕过任何编译步骤。 ionide.io
标签: types f# units-of-measurement