Assuming I have these types (forgive the C# syntax, I'm new to F#):
interface I { }
class A { }
class B : A, I { }
In C# I can do this:
A a = …
bool isI = a is I;
However, in F#, having this:
let a : A = ...
I know that a may contain an instance of B and implement I. However, this results in a compile error saying A is not compatible with I:
let isI = a :? I
However, this works:
let isI = a :> obj :? I
How come? a :? I is neither an upcast nor a downcast, sure. But how does it work with obj? Do interfaces somehow count as object subclasses?