I'm developing a plugin-loading system for my F# .NET 5 app, following this Microsoft guide. I wanted to provide an interface ICore that would have some internal, opaque state type that I would provide an interface for manipulating.
In Scala, I might do this like
trait ICore {
type State
def reset: State
}
and then call this method like
def resetCoreState(c: Core): c.State = c.reset
and implement a core like
object StringCore extends ICore {
override type State = String
override def reset: String = ""
}
however F# doesn't have this feature.
How should I design my interface,
type ICore() =
interface
// abstract type State
abstract method reset : State
end
let resetCoreState : ???
type StringCore() = ???
so that plugins can manage their own state?