Wonderland v0.1.0 Wonderland.Data.Maybe View Source

Classic sum type which represents optional value

  • Functor
  • Monad
  • Applicative

Link to this section Summary

Functions

  • Accepts any term
  • Returns true if term is value of Wonderland.Data.Maybe λ-type, otherwise returns false

If argument is just(a) then returns true If argument is nothing() then returns false Otherwise raise exception

If argument is nothing() then returns true If argument is just(a) then returns false Otherwise raise exception

First constructor

Second constructor

Link to this section Types

Link to this section Functions

  • Accepts any term
  • Returns true if term is value of Wonderland.Data.Maybe λ-type, otherwise returns false
Link to this function

is_just?(x)

View Source
is_just?(t(a())) :: boolean()

If argument is just(a) then returns true If argument is nothing() then returns false Otherwise raise exception

Examples

iex> j = Maybe.just(1)
iex> n = Maybe.nothing()
iex> Maybe.is_just?(j)
true
iex> Maybe.is_just?(n)
false
Link to this function

is_nothing?(x)

View Source
is_nothing?(t(a())) :: boolean()

If argument is nothing() then returns true If argument is just(a) then returns false Otherwise raise exception

Examples

iex> j = Maybe.just(1)
iex> n = Maybe.nothing()
iex> Maybe.is_nothing?(n)
true
iex> Maybe.is_nothing?(j)
false
Link to this function

just(x)

View Source
just(a()) :: t(a())

First constructor

Examples

iex> x = Maybe.just(1)
iex> Maybe.is_just?(x)
true
Link to this function

nothing()

View Source
nothing() :: t(a())

Second constructor

Examples

iex> x = Maybe.nothing()
iex> Maybe.is_nothing?(x)
true