Algae v0.12.1 Algae.Either

Represent branching conditions. These could be different return types, error vs nominal value, and so on.

Examples

iex> require Integer
...> value = 11
...> if Integer.is_even(value) do
...>   right(value)
...> else
...>   left(value)
...> end
%Algae.Either.Left{left: 11}

iex> require Integer
...> value = 10
...> if Integer.is_even(value) do
...>   right(value)
...> else
...>   left(value)
...> end
%Algae.Either.Right{right: 10}

Summary

Functions

Wrap a value in the Left branch

Wrap a value in the Right branch

Types

Functions

left(value)

Specs

left(any) :: Algae.Either.Left.t

Wrap a value in the Left branch

Examples

iex> left(13)
%Algae.Either.Left{left: 13}
right(value)

Specs

right(any) :: Algae.Either.Right.t

Wrap a value in the Right branch

Examples

iex> right(7)
%Algae.Either.Right{right: 7}