Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Maybe<A>

Type parameters

  • A

Hierarchy

Implements

Index

Properties

Methods

Properties

Static pure

pure: of = Maybe.of

A common alias of Maybe.of

param

Methods

Abstract alt

Abstract ap

  • Similar to map, but apply a function wrapped in Maybe.

    If either the function Maybe or this Maybe is "Nothing", then this will return "Nothing". Otherwise, the function will be applied to the value and return a Maybe.

    Type parameters

    • B

    Parameters

    • fab: Maybe<function>

      Maybe wrapping a function

    Returns Maybe<B>

Abstract chain

  • chain<B>(f: function): Maybe<B>
  • Monadic binding. Apply a function which returns a Maybe without adding structure.

    Returns "Nothing" when the Maybe is "Nothing, or when the function applied to the value returns "Nothing". Otherwise, returns "Just" the result of the function: a Maybe of the value.

    Type parameters

    • B

    Parameters

    • f: function

      A unary function which returns a Maybe

        • Parameters

          • a: A

          Returns Maybe<B>

    Returns Maybe<B>

Abstract map

  • map<B>(f: function): Maybe<B>
  • Apply a function to the value contained in Maybe

    If Maybe is "Nothing" then it will always return "Nothing". If Maybe is "Just" some value, the function will be applied to that value and returned as a Maybe.

    Type parameters

    • B

    Parameters

    • f: function

      A unary function

        • (a: A): B
        • Parameters

          • a: A

          Returns B

    Returns Maybe<B>

Abstract toString

  • toString(): string

Abstract zero

Static of

  • Wrap a value with Maybe.

    If the value is undefined or null, it will return "Nothing". Otherwise, it will return a "Just" containing the value.

    Type parameters

    • A

    Parameters

    • a: A

    Returns Maybe<A>

Generated using TypeDoc