Wonderland v0.1.1 Wonderland.Data.Either View Source

Classic sum type which represents 2 alternatives

  • Bifunctor
  • Functor (as right)
  • Monad (as right)
  • Applicative (as right)

Link to this section Summary

Functions

If argument is left(x) then returns true If argument is right(x) then returns false Otherwise raise exception

If argument is right(x) then returns true If argument is left(x) then returns false Otherwise raise exception

First constructor

Second constructor

Link to this section Types

Link to this type

t(a, b)

View Source
t(a, b) :: t(a, b)

Link to this section Functions

Link to this function

is_left?(x)

View Source
is_left?(t(a(), b())) :: boolean()

If argument is left(x) then returns true If argument is right(x) then returns false Otherwise raise exception

Examples

iex> x = Either.left(1)
iex> y = Either.right(1)
iex> Either.is_left?(x)
true
iex> Either.is_left?(y)
false
Link to this function

is_right?(x)

View Source
is_right?(t(a(), b())) :: boolean()

If argument is right(x) then returns true If argument is left(x) then returns false Otherwise raise exception

Examples

iex> x = Either.left(1)
iex> y = Either.right(1)
iex> Either.is_right?(x)
false
iex> Either.is_right?(y)
true
Link to this function

left(x)

View Source
left(a()) :: t(a(), b())

First constructor

Examples

iex> x = Either.left(1)
iex> Either.is_left?(x)
true
Link to this function

right(x)

View Source
right(b()) :: t(a(), b())

Second constructor

Examples

iex> x = Either.right(1)
iex> Either.is_right?(x)
true