Function unpacker_map

  • Parameters

    • unpacker: any

    Returns any

    Stability

    1 - experimental

    Takes in an unpacker function and produces a map that destructures the various scenarios that the input might take on (whether the input be a uoe-map, a uoe-enum, or undefined).

    Recall that "undefined" is the leaf case, specifying the desire to obtain the final return value of the map.

    Otherwise, the input may be an enum or a map. Be careful not to inadvertently pass in a map that resolves to an enum leaf, when it is desired that the enum be passed in instead. Take care to await this if necessary.

    TODO: should notion of uoe-api be incorporated directly into this notation?

    Example

    const my_map = unpacker_map(($) => {
    $.symbol_name(($) => {
    // ...
    });

    $.symbol_name.$ret_lazy(() => "example");
    $.symbol_name.$ret("example"); // shorthand
    $.symbol_name.$call((map) => {});
    $.symbol_name.$fall((inp) => {});
    $.$ret(() => "example")
    $.$("example"); // shorthand
    $.$call((map) => {});
    $.$fall((inp) => {});
    });

    const person = unpacker_map(($) => {
    $.name.$ret("John Doe");
    $.age.$ret(27);
    $.friends.$ret(["mary", "jane", "joseph"]);
    $.address(($) => {
    $.street.$ret("123 Main St");
    $.city.$ret("Monopoly Town");
    $.state.$ret("CA");
    });
    });

Generated using TypeDoc