Algae v0.12.1 Algae.Maybe
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{}
Summary
Types
Functions
Specs
just(any) :: Algae.Maybe.Just.t
Alias for maybe/1
Examples
iex> Algae.Maybe.Just.new(9)
%Algae.Maybe.Just{just: 9}
Specs
maybe :: Algae.Maybe.Nothing.t
Put no value into the Maybe
context (ie: make it a Nothing
)
Examples
iex> maybe()
%Algae.Maybe.Nothing{}
Specs
maybe(any) :: Algae.Maybe.Just.t
Put a value into the Maybe
context (ie: make it a Just
)
Examples
iex> maybe(9)
%Algae.Maybe.Just{just: 9}
Specs
nothing :: Algae.Maybe.Nothing.t
Alias for maybe/0
Examples
iex> Algae.Maybe.nothing()
%Algae.Maybe.Nothing{}