Algae v0.12.2 Algae.Maybe View Source
The sum of Algae.Maybe.Just
and Algae.Maybe.Nothing
.
May represents the presence or absence of something.
Please note that nil
is actually a value, as it can be passed to functions!
nil
is not bottom!
Examples
iex> [1,2,3]
...> |> List.first()
...> |> case do
...> nil -> nothing()
...> head -> just(head)
...> end
%Algae.Maybe.Just{just: 1}
iex> []
...> |> List.first()
...> |> case do
...> nil -> nothing()
...> head -> just(head)
...> end
%Algae.Maybe.Nothing{}
Link to this section Summary
Link to this section Types
Link to this section Functions
Alias for maybe/1
Examples
iex> Algae.Maybe.Just.new(9)
%Algae.Maybe.Just{just: 9}
Put no value into the Maybe
context (ie: make it a Nothing
)
Examples
iex> maybe()
%Algae.Maybe.Nothing{}
Put a value into the Maybe
context (ie: make it a Just
)
Examples
iex> maybe(9)
%Algae.Maybe.Just{just: 9}
Alias for maybe/0
Examples
iex> Algae.Maybe.nothing()
%Algae.Maybe.Nothing{}