Is there a way in F# to type-test against a generic type without specifying the instance type?

前端 未结 4 1864
春和景丽
春和景丽 2021-01-01 02:45

I\'m trying to pattern match against a few types that I care about for SQL generation. Ideally I\'d like to do this:

let rec getSafeValue record (prop: Prope         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 03:34

    This can't work in F# without covariance. Assuming that you're happy for v to be of type obj, you want to be able to treat Option as if it was Option. Without covariance, Option and Option are independent types.

提交回复
热议问题