I want to make an interface with default implementation for equality and comparison functions.
If I remove everything from the type IKeyable<'A>
except the Key
member, it is a valid interface, as long as I don't add a default implementation. Removing the other interface implementations from IKeyable<'A>
, and leaving just default members ends in the same result.
type IKeyable<'A when 'A: equality and 'A :> IComparable> =
abstract member Key : 'A
default this.Equals obj = // hidden for clarity
default this.GetHashCode () = // hidden for clarity
interface IEquatable<'A> with
member this.Equals otherKey = // hidden for clarity
interface IComparable<'A> with
member this.CompareTo otherKey = // hidden for clarity
interface IComparable with
member this.CompareTo obj = // hidden for clarity
type Operation =
{ Id: Guid }
interface IKeyable<Guid> with // Error: The type 'IKeyable<Guid>' is not an interface type
member this.Key = this.Id
I would like to make use of IKeyable<'A>
as an interface in order to "gain" the default implementations for equality and comparison.
The error message comes up on the interface ... with
under the type Operation
: The type 'IKeyable<Guid>' is not an interface type