4
votes

I have an interface, in IAnimal.fs,

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

and another interface that successfully inherits it, in IMammal.fs.

namespace Kingdom
type IMammal =
    inherit IAnimal

But, when I try to inherit it again I get an exception (IBird.fs)

namespace Kingdom
type IBird =
    inherit IAnimal

The exceptions are

The type 'obj' is not an interface type

and

The type 'IAnimal' is not defined

and IAnimal har a red line under it in IBird.fs.

I've tried copy/paste the definition of IMammal and change IMammal to IBird but I still get the same error. Also tried restarting Visual Studio.

What could be wrong?

1
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
@TheQuickBrownFox that's the answer. Thought the order of the files was a bit too strange to be a-z... - Mikael Dúi Bolinder

1 Answers

1
votes

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