type U =
| A of int
| B of float
| C of string
let UFormat =
(
UnionCase A IntFormat <<
UnionCase B FloatFormat <<
UnionCase C StringFormat
)
|> Union (fun a b c x ->
match x with
| A x -> a x
| B x -> b x
| C x -> c x)
type R =
{
A : int
B : float
C : string
}
let RFormat : Format<R> =
(
RecordField (fun r -> r.A) IntFormat <<
RecordField (fun r -> r.B) FloatFormat <<
RecordField (fun r -> r.C) StringFormat
)
|> Record (fun a b c -> { A = a; B = b; C = c })
With some simplifications, here is the code:
No comments:
Post a Comment