monex v0.1.8 MonEx.Option
Option module provides Option type with utility functions.
Summary
Functions
Returns content of option if argument is some(), raises otherwise
some(5) |> get == 5
Returns content of option if argument is some(), second argument otherwise.
some(5) |> get_or_else(2) == 5
none() |> get_or_else(2) == 2
none() |> get_or_else(fn -> 1) == 1
Returns true if argument is none()
false if some()
is_none(none()) == true
Returns true if argument is some()
false if none()
is_some(some(5)) == true
Returns option if argument is some()
, second argument wrapped in some otherwise.
Executes function, if it’s supplied.
some(5) |> or_else(2) == some(5)
none() |> or_else(2) == some(2)
none() |> or_else(fn -> some(1)) == some(1)
Converts arbitrary term into option, some(term)
if not nil, none()
otherwise
to_option(5) == some(5)
to_option(nil) == none()
Types
Functions
Returns content of option if argument is some(), raises otherwise
some(5) |> get == 5
Returns content of option if argument is some(), second argument otherwise.
some(5) |> get_or_else(2) == 5
none() |> get_or_else(2) == 2
none() |> get_or_else(fn -> 1) == 1
Returns true if argument is none()
false if some()
is_none(none()) == true
Returns true if argument is some()
false if none()
is_some(some(5)) == true
Returns option if argument is some()
, second argument wrapped in some otherwise.
Executes function, if it’s supplied.
some(5) |> or_else(2) == some(5)
none() |> or_else(2) == some(2)
none() |> or_else(fn -> some(1)) == some(1)
Converts arbitrary term into option, some(term)
if not nil, none()
otherwise
to_option(5) == some(5)
to_option(nil) == none()