Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

f# type provider inheritance

Tags:

I have designed a simple type provider which provide types depending on my parameter. I would like to know if it is possible to define ProvidedTypeDefinitions that would inherit another ProvidedTypeDefinition?

I know that statically I can do the following :

type People() = class end

type Student() =
    inherit People() 

type Teacher() =
    inherit People()

and then I can pattern match like this using Type Test Pattern:

let f (x:People) =
    match x with
        | :? Student -> "Student"
        | :? Teacher -> "Teacher"
        | _ -> "Nothing !!"

What I would like to do in my Type provider is to create ProvidedTypeDefinitions that inherit another ProvidedTypeDefinition. Such that when I use the type provider to generate those types I can pattern match on them (for instance, I know that at runtime one of this types will be instanciated but I don't know which one except that it is one of the ProvidedTypeDefinitions).

Thank you for your time!


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!