maybe

Classes

Nothing

Methods

static isJust(x) → {boolean}

Checks for Just.

Parameters:
Name Type Description
x *
Returns:
boolean

static isMaybe(x) → {boolean}

Checks for maybe.

Parameters:
Name Type Description
x *

.

Returns:
boolean

static just(x) → {Just}

Functional constructor (function that returns an instance) for Just - Same as new Just(...) (just shorter and can be used as a function).

Parameters:
Name Type Description
x Just | *
Returns:
Just

static maybe(replacement, fn, maybeInst) → {*}

The maybe function takes a replacement value, a function (unary operation), and a Maybe value. If the Maybe value is Nothing, the function returns the replacement value. Otherwise, it applies the function to the value contained by the Just and returns the result.

Parameters:
Name Type Description
replacement *
fn function

Unary operation.

maybeInst Nothing | Just | *

Maybe instance or non-maybe value.

Returns:
*

static maybeEqual(a, b) → {boolean}

Equality operator for maybes.

Parameters:
Name Type Description
a *

Maybe 1.

b *

Maybe 2.

Returns:
boolean

static nothing() → {Nothing}

Returns Nothing.

Returns:
Nothing

static toJust(x) → {Just}

Ensures Just

Parameters:
Name Type Description
x Just | *
Returns:
Just

static toMaybe(x) → {Maybe}

Creates maybe from value.

Parameters:
Name Type Description
x *
Returns:
Maybe -
  • Just or Nothing based on value.

static unWrapJust(x) → {*}

Unwraps just (recursively).

Parameters:
Name Type Description
x *

Expected Just.

Returns:
*

static unWrapMaybe(x) → {*}

Unwraps maybe (recursively).

Parameters:
Name Type Description
x *

Expected Maybe.

Returns:
*