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

Functions

Alias for maybe/1

Put no value into the Maybe context (ie: make it a Nothing)

Put a value into the Maybe context (ie: make it a Just)

Alias for maybe/0

Types

Functions

just(value)

Specs

just(any) :: Algae.Maybe.Just.t

Alias for maybe/1

Examples

iex> Algae.Maybe.Just.new(9)
%Algae.Maybe.Just{just: 9}
maybe()

Specs

Put no value into the Maybe context (ie: make it a Nothing)

Examples

iex> maybe()
%Algae.Maybe.Nothing{}
maybe(value)

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}
nothing()

Specs

Alias for maybe/0

Examples

iex> Algae.Maybe.nothing()
%Algae.Maybe.Nothing{}