Is there any way to pattern match on discriminated union functions, e.g.:-
type Test =
| A of string
| B of int
| C of char
let DefaultTest t =
match t with
| A(_) -> A(null)
| B(_) -> B(0)
| C(_) -> C('\u0000')
let a = A |> DefaultTest
Obviously this code isn't valid F# as DefaultTest accepts one parameter of type Test rather than 'a -> Test. Is there any way of achieving this without specifying a value for the discriminated union?
What I'm after, ultimately, is a function which inputs a function of type 'a -> Test and outputs Test(default value of 'a).