FsToolkit.ErrorHandling icon indicating copy to clipboard operation
FsToolkit.ErrorHandling copied to clipboard

Add Option.maybe

Open AlexeyRaga opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe.

Result module contains

either : ('a -> 'c) -> ('b -> 'c) -> Result<'a, 'b> -> 'c

Having its counterpart Option.maybe would be great:

maybe :  (() -> 'b) -> ('a -> 'b) -> Option<'a> -> 'b

Describe alternatives you've considered

An obvious alternative is to use Option.fold or Option.map f >> Option.defaultWith g but it is the same level of inconvenience that Result.either solves for Result.fold.

AlexeyRaga avatar Sep 27 '22 11:09 AlexeyRaga