f# - 类型 'obj' 不是接口(interface)类型

标签 f#

我有一个界面,在IAnimal.fs中,

namespace Kingdom
type IAnimal =
    abstract member Eat : Food -> unit

以及另一个成功继承它的接口(interface),位于IMammal.fs中。

namespace Kingdom
type IMammal =
    inherit IAnimal

但是,当我尝试再次继承它时,出现异常 (IBird.fs)

namespace Kingdom
type IBird =
    inherit IAnimal

异常(exception)情况是

The type 'obj' is not an interface type

The type 'IAnimal' is not defined

IAnimalIBird.fs 中在其下方有一条红线。

我尝试复制/粘贴 IMammal 的定义并将 IMammal 更改为 IBird 但仍然遇到相同的错误。还尝试重新启动 Visual Studio。

可能出了什么问题?

最佳答案

Make sure your files are in the correct order in your project. A file can only reference types and values defined in earlier fields. So in this case IMammal.fs and IBird.fs must come after IAnimal.fs.

- TheQuickBrownFox

关于f# - 类型 'obj' 不是接口(interface)类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49253533/

相关文章:

f# - 将 C# 异步方法转换为 F# 函数

f# - 为 F# 中的可区分联合自动生成谓词和访问器

c# - 在 C# 中模拟 F# `with` 关键字

haskell - F#有多路if吗?

syntax - F# 区分联合语法说明

F# 类型推断

f# - 将用户名和密码参数传递给类型提供程序

F# 类型约束和反射

f# - 如何在 F# 中中止 seq?