An absent Maybe.

Hierarchy

Properties

kind: NOTHING = Kind.NOTHING

The property that discriminates Maybe.

singleton: Nothing = ...

The singleton instance of Nothing.

Remarks

The nothing constant is a more accessible alias for this object.

Methods

  • If this and that Maybe are Just, combine their values; otherwise, return the first Maybe that is not Nothing.

    Type Parameters

    Parameters

    Returns Maybe<T>

  • Compare this and that Maybe to determine their ordering.

    Type Parameters

    • T extends Ord<T>

    Parameters

    Returns Ordering

    Remarks

    When ordered, Nothing always compares as less than Just. If both are Just, their values are compared to determine the ordering.

  • Compare this and that Maybe to determine their equality.

    Type Parameters

    • T extends Eq<T>

    Parameters

    Returns boolean

    Remarks

    Two Maybe are equal if they are both Nothing, or they are both both Just and their values are equal.

  • Returns Generator<Maybe<never>, never, unknown>

  • If this Maybe is Just, ignore its value and return that Maybe.

    Type Parameters

    • T1

    Parameters

    Returns Maybe<T1>

  • If this Maybe is Just, apply a function to its value to return another Maybe.

    Type Parameters

    • T

    • T1

    Parameters

    Returns Maybe<T1>

  • If this Maybe is Just, apply a generator function to its value to its value to return another Maybe.

    Type Parameters

    • T

    • T1

    Parameters

    Returns Maybe<T1>

  • If this Maybe is Just, apply a predicate to filter its value.

    Type Parameters

    • T

    • T1

    Parameters

    • this: Maybe<T>
    • f: ((val) => val is T1)
        • (val): val is T1
        • Parameters

          • val: T

          Returns val is T1

    Returns Maybe<T1>

    Remarks

    If the predicate returns false, return Nothing.

  • Type Parameters

    • T

    Parameters

    • this: Maybe<T>
    • f: ((val) => boolean)
        • (val): boolean
        • Parameters

          • val: T

          Returns boolean

    Returns Maybe<T>

  • If this Maybe is Just, extract its value; otherwise, return a fallback value.

    Type Parameters

    • T

    • T1

    Parameters

    • this: Maybe<T>
    • fallback: T1

    Returns T | T1

  • If this Maybe is Just, extract its value; otherwise, invoke a function to return a fallback value.

    Type Parameters

    • T

    • T1

    Parameters

    • this: Maybe<T>
    • f: (() => T1)
        • (): T1
        • Returns T1

    Returns T | T1

  • Test whether this Maybe is Just.

    Type Parameters

    • T

    Parameters

    Returns this is Just<T>

  • If this Maybe is Just, apply a function to map its value.

    Type Parameters

    • T

    • T1

    Parameters

    • this: Maybe<T>
    • f: ((val) => T1)
        • (val): T1
        • Parameters

          • val: T

          Returns T1

    Returns Maybe<T1>

  • If this Maybe is Just, apply a partial function to map its value.

    Type Parameters

    • T

    • T1

    Parameters

    • this: Maybe<T>
    • f: ((val) => undefined | null | T1)
        • (val): undefined | null | T1
        • Parameters

          • val: T

          Returns undefined | null | T1

    Returns Maybe<T1>

    Remarks

    If the function returns null or undefined, return Nothing.

  • If this Maybe is Nothing, return that Maybe.

    Type Parameters

    • T

    • T1

    Parameters

    Returns Maybe<T | T1>

  • If this Maybe is Nothing, invoke a function to return a fallback Maybe.

    Type Parameters

    • T

    • T1

    Parameters

    Returns Maybe<T | T1>

  • If this Maybe is Just, extract its value; otherwise, return undefined.

    Type Parameters

    • T

    Parameters

    Returns undefined | T

  • If this Maybe is Just, apply a function to extract its value; otherwise, invoke a function to return a fallback value.

    Type Parameters

    • T

    • T1

    • T2

    Parameters

    • this: Maybe<T>
    • ifNothing: (() => T1)
        • (): T1
        • Returns T1

    • unwrapJust: ((val) => T2)
        • (val): T2
        • Parameters

          • val: T

          Returns T2

    Returns T1 | T2

  • If this and that Maybe are Just, apply a function to combine their values.

    Type Parameters

    • T

    • T1

    • T2

    Parameters

    • this: Maybe<T>
    • that: Maybe<T1>
    • f: ((lhs, rhs) => T2)
        • (lhs, rhs): T2
        • Parameters

          • lhs: T
          • rhs: T1

          Returns T2

    Returns Maybe<T2>

Generated using TypeDoc