Category v0.1.0 Category.Data.Maybe View Source
Classic sum type Maybe
Implements Monad, Functor and Applicative behaviours
Link to this section Summary
Functions
If argument is just(a)
then returns a
, otherwise returns nil
If argument is just(a)
then returns a
, otherwise raise exception
- Accepts any term
- Returns
true
if term is value ofCategory.Data.Maybe
λ-type, otherwise returnsfalse
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
If argument is just(a)
then returns a
, otherwise returns nil
Examples
iex> j = Maybe.just(1)
iex> n = Maybe.nothing()
iex> Maybe.get(j)
1
iex> Maybe.get(n)
nil
If argument is just(a)
then returns a
, otherwise raise exception
Examples
iex> j = Maybe.just(1)
iex> n = Maybe.nothing()
iex> Maybe.get!(j)
1
iex> Maybe.get!(n)
** (RuntimeError) Can't get! from Category.Data.Maybe.nothing
- Accepts any term
- Returns
true
if term is value ofCategory.Data.Maybe
λ-type, otherwise returnsfalse
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
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
First constructor
Examples
iex> x = Maybe.just(1)
iex> Maybe.is_just?(x)
true
Second constructor
Examples
iex> x = Maybe.nothing()
iex> Maybe.is_nothing?(x)
true