Code Snippet:

1
2
3
4
5
6
7
8
type FooBar = { foo : string; bar : int option }

[1 .. 10]
|> List.map(
  fun x -> x % 2 = 0 |> function
  | true ->  { foo = "some"; bar = Some x }
  | false -> { foo = "none"; bar = None   } )
|> List.choose(fun x -> id x.bar)

Code output:

> type FooBar = { foo: string; bar: int option; }
> val it : int list = [2; 4; 6; 8; 10]

References: