match value with | :? list<#SomeType> as l -> l //Is it possible to match any list of a type derived from SomeType? | _ -> failwith "doesn't match"
解决方法
不,遗憾的是不可能做这样的事情 – CLR没有提供任何有效的方式来进行这种类型的测试.有些(相当难看的)解决方案请参见
How to cast an object to a list of generic type in F#和
F# and pattern matching on generics in a non-generic method implementing an interface.