Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 496 Bytes

README.md

File metadata and controls

19 lines (14 loc) · 496 Bytes

Alternative

Define a function with type:

( <|> ) : 'a option -> 'a option -> 'a option

That returns the first value available within the Some tag or None if both arguments are None.

Here are some unit tests:

assert (None <|> Some false = Some false);;
assert (Some true <|> None <|> Some false = Some true);;
assert (Some 3 <|> None = Some 3);;
assert (Some "cat" <|> Some "dog" = Some "cat");;
assert (None <|> None <|> Some "dog" <|> None = Some "dog");;