Reputation: 1317
I am having trouble with what seems to be a trivial use of inheritance in an f# project.
File 1:
namespace MercurySchool.Models
[<AbstractClass>]
type Resource() =
abstract member Href: string with get, set
abstract member Method: string with get, set
abstract member Relations: string[] with get, set
abstract member Id: int with get, set
abstract member Name: string with get, set
abstract member Description: string with get, set
File 2:
namespace MercurySchool.Models
type School() =
inherit Resource()
In File 2 I am getting the following errors:
No constructors are available for the type 'Resource'
The type 'Resource' is not defined.
Feels like there's a simple resolution, but so far it escapes me.
Some background:
Upvotes: 1
Views: 83
Reputation: 1317
The problem indeed appears to be the order of compilation, as Fydor suggested.
I changed the fsdprog
file from this:
<ItemGroup>
<Compile Include="Models\*.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
to a more explicit declaration:
<ItemGroup>
<Compile Include="Models\Resource.fs" />
<Compile Include="Models\school.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
After a few other changes unrelated to this question, the project builds.
Upvotes: 1