Description Usage Arguments Format Value See Also Examples
A “bind” function or method can be thought of as feeding an input value to a function. This is known as “binding” a value to the parameter of the function. When you need to use a function that does not already take a Maybe type argument, use maybe_bind to "lift" a new function that *does* take a Maybe type argument.
1 | maybe_bind(f)
|
f |
A function taking a non-optional (one-track) argument and returning an optional (two-track) value. |
maybe_bind :: (a -> b) -> (Maybe a -> Maybe b)
A function taking an optional (two-track) argument and returning an optional (two-track) value.
Other Maybe functions: as_maybe
,
is_nothing
, maybe_apply
,
maybe_default
, maybe_map_2
,
maybe_map_3
, maybe_map_4
,
maybe_map_5
, maybe_map
,
maybe_then
, maybes_collapse
,
maybes_partition
1 2 3 4 5 | library(assertthat)
is_maybe_numeric <- maybe_bind(is.numeric)
is_maybe_numeric(Just(1)) # Just(TRUE)
is_maybe_numeric(Just("cat")) # Just(FALSE)
is_maybe_numeric(Nothing()) # Nothing()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.