If a class has a list of parameters immediately after its name (including () ), it has a primary constructor. Using it, any inherit are placed only in this primary constructor, which comes immediately after the class declaration and before any member declarations.
It is not clear what you are trying to achieve. The Foo class has a constructor that takes a string argument, only to remove it. A (technically) valid similar pair of classes would be this:
type Foo(name:string) = member f.NameLength = name.Length type Bar(initialName) = // WARNING: this will not end well inherit Foo(initialName) member val Name:string = initialName with get, set
But this is not reasonable code. Foo will keep the initial name, even if the name in Bar is changed. Bar.Name.Length returns the current length of the name, and Bar.NameLength returns the initial length of the name.
To keep the default constructor, you can add new () = Bar(null) (or the equivalent in Foo ), but note that null is considered a function for interaction only . It is not used in F # code; if possible, use the appropriate parameter type or empty string, respectively (depending on whether the string is empty or does not exist at all).
In addition, class inheritance is not recommended in F # component design directives - for good reason. There are few use cases, but usually they include a tiny base class and a derived class, which is a great addition to it. More often, types have to be constructed using one class as a member of another.
I donβt know how relevant this is, but here is an example of a class with a standard constructor and an additional constructor that uses it:
type Text500(text : string) = do if text.Length > 500 then invalidArg "text" "Text of this type cannot have a length above 500." member t.Text = text new () = Text500("")
This uses the primary constructor to validate input and has an optional parameterless constructor that uses an empty string. (I'm not sure if the extra constructor will be useful in real applications.)