Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Option.InfixOperators for code that works extensively with Options.
This module is intended to be opened at the top of a block of code (or module) that uses its operators extensively.
let nameToAge = Map.String.ofArray [|
("Ant", 1);
("Bat", 5);
|] in
Option.Infix.(
Map.get nameToAge "Ant" >>= (fun antAge ->
Map.get nameToAge "Bat" >>| (fun batAge ->
Int.absolute(batAge - antAge)
)
)
)
(* Some (4) *)The operator version of map
Examples
Option.Infix.(Some "desserts" >>| String.reverse) = Some "stressed"Option.Infix.(None >>| String.reverse) = NoneThe operator version of flatMap
Examples
Option.Infix.(Some [1, 2, 3] >>= List.head) = Some 1Option.Infix.(Some [] >>= List.head) = None