I've got a class in my application - for simplicity let's assume it's defined like this:
type baseType() =
member this.A = 5.
Also, I've got a lot of functions that take objects of this type as an argument. Moreover, some of them take an array of this type:
let myFun (xArr : baseType[]) =
// ... do something inspirig ;)
Now I realized, that it would be nice to have another class which derives from "baseType". e.g.:
type inhType() =
inherit baseType()
member this.B = 8.
However, I can't use the arrays of inherited type with the functions like "myFun"
let baseArr = [| baseType() |]
let inhArr = [| inhType() |]
myFun baseArr
myFun inhArr // won't work
which would be "nice to have". Is there a simple way to re-use my functions without applying so many changes ?
I guess one of the solution is to map my array using e.g. the function (fun (d : inhType) -> d :> baseType), but I'm wondering if there's anything else could be done.