Skip to contents

Evaluate a maybe returning function on a maybe value

Usage

and_then(.m, .f, ...)

bind(.m, .f, ...)

Arguments

.m

A maybe value

.f

A maybe returning function to apply to the maybe value

...

Named arguments for the function .f

Value

A maybe value

Examples

safe_sqrt <- maybe(sqrt, ensure = not_infinite)

just(9) %>% and_then(safe_sqrt)
#> Just
#> [1] 3
just(-1) %>% and_then(safe_sqrt)
#> Nothing
nothing() %>% and_then(safe_sqrt)
#> Nothing