是否可以为F#中的递归类定义不同的属性

Ber*_*tte 5 f# attributes

我想声明两个相关联的类,因此我将它们一起声明为"和".每个都有不同的属性,但这段代码不起作用(关键字'和'中的"意外关键字"和"定义中"错误.我应该如何声明第二类的属性?

[<AbstractClass>]
type foo() =
  abstract member fun1 : foo -> foo2
[<Serializable>]
and foo2() = class
  member x.bar y = y
end
Run Code Online (Sandbox Code Playgroud)

Str*_*ger 8

这个对我有用.你做了open System吗?

open System

[<AbstractClass>]
type foo() =
  abstract member fun1 : foo -> foo2
and [<Serializable>] foo2() = class
  member x.bar y = y
end
Run Code Online (Sandbox Code Playgroud)

编辑:啊,似乎第二个属性应该在之后and.