Ok, C# has Explictit Interface Implementation
I’l like to do similar in F#.
I have some Interfaces (and classes)
type IState = interface
abstract member Update : IAction-> IState
...
end
type IEnviroment = interface
abstract member Update : IAction-> IEnviroment
...
end
type IBoard =
inherit IState
inherit IEnviroment
abstract member Update : Move -> IBoard
...
[<AbstractClass>]
and Move ()=
abstract member Apply : IBoard -> IBoard
interface IAction with
override this.Cost = 1M
So the problem I have is that Update is defined 3 times differently.
So I need the equivelent of C#’s Explictit Interface Implementation,
I’me thinking I’ld implement it in the interface (since that is legit in F#) – it would just consist of some typecasts.
My understanding is that all interface implementation in F# is explcit, in classes,
But once an interface inherits from another inferface, then you only (explicitly) implement that one.
(so my Board class only implments I Board)
I tried the syntax
member this.IState.Updatein the implementation ofIBoard, but the compiler rejected it.I don’t see a way in the spec to do what you want.
Here is a work-around in for such name clashes, using an abstract class to forward calls to each interface.