, , IU.Int , case Int IU.
let x = IU.Int(3)
x IU, IU.Int. obj UI.Int :?.
, F # a-la Javascript, . , , , , obj, , , .
F # DU, , , , IU (IU.Int IU.Unit)
let showI (v : IU) =
match v with
| IU.Int(x) -> sprintf "a IU.Int(%i) value" x
| _ -> "a IU.Unit"
, showI , IU, , .
: , match, , when guard, , :
open Microsoft.FSharp.Reflection
let showI (v) =
match box v with
| :? IU as x when (fst(FSharpValue.GetUnionFields(x, typeof<IU>))).Name.Equals("Int")
-> "an IU.Int"
| _ -> "not an IU.Int"