The use of type typedef<typename>
as a literal target within a match expression or when supported by an active expression as shown here shows syntax error on the typeof<>
portion of the expression. Am I doing something wrong?
(Note that the match is against an instance of Type
and not an actual value of that type.)
let (|IsType|_|) (et:Type) t = if et.Equals(t) then Some() else None
let someFunc someType =
match someType with
| IsType (typeof<string>) _ -> "Yes"
| _ -> "No"
Interestingly, within an if..then
expression it does work.
let someFunc someType =
if typeof<string> = someType then "Yes"
else "No"
)
This circumstance would appear to be an oversight in the language.