"""Pattern matching on algebraic data: `match` and `rewrite`.

A match takes a value and one to sixteen clauses. A clause is a plain function or
a lambda without captures; its parameter type selects the constructor it handles
and says, field by field, whether a recursive field arrives as it is or already
matched. The library checks the clauses when the program compiles and runs the
match as one loop over an explicit stack, so a match is exhaustive, terminates
on any value, and is not limited by the native stack.

`match` also takes a context shared by every clause, or a tuple of two or three
subjects. `rewrite` transforms a value bottom-up with clauses for the
constructors that change.
"""
from std.os import abort
from std.builtin.rebind import downcast
from fp.adt.data import Value, Data, Node, _NodeType
from fp.matching._engine import _ClauseSet, _Cons, _Nil, _Absent, _Sig1, _Sig2, _Sig3, _Pick, _NoResult, _admit, _run
from fp.matching._inline import _Context, _admit_inline, _run_inline
from fp._internal.errors import _NativeError, _CommonError


# A clause set is a list of clauses, built from the last clause to the first.
# Each arity has its own name: nested calls to an overloaded function are
# resolved by backtracking, which takes time exponential in the clause count.

def _push1[A: AnyType, O: Value, E: AnyType, Rest: _ClauseSet](
    clause: def(A) raises E thin -> O, var rest: Rest
) -> _Cons[_Sig1[A, O, _NativeError[E]], Rest]:
    comptime S = _Sig1[A, O, _NativeError[E]]
    return _Cons[S, Rest](rebind[S.Fn](clause), rest^)


def _push2[A: AnyType, B: AnyType, O: Value, E: AnyType, Rest: _ClauseSet](
    clause: def(A, B) raises E thin -> O, var rest: Rest
) -> _Cons[_Sig2[A, B, O, _NativeError[E]], Rest]:
    comptime S = _Sig2[A, B, O, _NativeError[E]]
    return _Cons[S, Rest](rebind[S.Fn](clause), rest^)


def _push3[A: AnyType, B: AnyType, C: AnyType, O: Value, E: AnyType, Rest: _ClauseSet](
    clause: def(A, B, C) raises E thin -> O, var rest: Rest
) -> _Cons[_Sig3[A, B, C, O, _NativeError[E]], Rest]:
    comptime S = _Sig3[A, B, C, O, _NativeError[E]]
    return _Cons[S, Rest](rebind[S.Fn](clause), rest^)


# Each entry checks the clauses first and compiles the run only when they are
# admitted, so a rejected match reports the admission message alone. The result
# and error types come from the generated signature, which spells them over the
# clause types directly: deriving them from the clause set instead takes the
# compiler time exponential in the clause count.

def _match[S: AnyType, C: _ClauseSet, X: AnyType, //, R: Value, E: Value](
    subject: S, clauses: C, context: X
) raises E -> R:
    """A `Node` is matched by the recursive engine; any other subject by the inline one."""
    comptime if conforms_to(S, _NodeType):
        comptime F = downcast[S, _NodeType].Of
        comptime admitted = _admit[F, C, R, E, X, False]()
        comptime if admitted:
            return _run[F, C, R, E, X, False](rebind[Node[F]](subject), clauses, context)
        else:
            abort("fp.match: the clauses were not admitted")
    elif X == _Absent:
        return _match_all[R, E](subject, _Absent(), _Absent(), clauses)
    else:
        return _match_all[R, E](subject, _Context[X](context), _Absent(), clauses)


def _rewrite[F: Data, C: _ClauseSet, //, E: Value](subject: Node[F], clauses: C) raises E -> Node[F]:
    comptime admitted = _admit[F, C, Node[F], E, _Absent, True]()
    comptime if admitted:
        return _run[F, C, Node[F], E, _Absent, True](subject, clauses, _Absent())
    else:
        abort("fp.rewrite: the clauses were not admitted")


def _match_all[C: _ClauseSet, S0: AnyType, S1: AnyType, S2: AnyType, //, R: Value, E: Value](
    a: S0, b: S1, c: S2, clauses: C
) raises E -> R:
    comptime admitted = _admit_inline[C, R, E, S0, S1, S2]()
    comptime if admitted:
        return _run_inline[C, R, E, S0, S1, S2](a, b, c, clauses)
    else:
        abort("fp.match: the clauses were not admitted")


# --- match overloads (generated) ---
# Generated by scripts/generate_plain_overloads.py; edit the generator, not this
# block. A clause's signature is known only at a parameter of its function type,
# so each clause count spells one thin signature per clause. A clause's error is
# inferred as AnyType: under a value bound a pure function's error is not Never
# (see _NativeError). _Result<n> and _Error<n> spell the match's types over the
# clause types (see _match). The one-clause overload of each form carries the
# documentation.

comptime _Result1[O0: Value]: Value = _Pick[O0, _NoResult]
comptime _Error1[E0: AnyType]: Value = _CommonError[_NativeError[E0], Never]
comptime _Result2[O0: Value, O1: Value]: Value = _Pick[O0, _Pick[O1, _NoResult]]
comptime _Error2[E0: AnyType, E1: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], Never]]
comptime _Result3[O0: Value, O1: Value, O2: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _NoResult]]]
comptime _Error3[E0: AnyType, E1: AnyType, E2: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], Never]]]
comptime _Result4[O0: Value, O1: Value, O2: Value, O3: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _NoResult]]]]
comptime _Error4[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], Never]]]]
comptime _Result5[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _NoResult]]]]]
comptime _Error5[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], Never]]]]]
comptime _Result6[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _NoResult]]]]]]
comptime _Error6[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], Never]]]]]]
comptime _Result7[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _NoResult]]]]]]]
comptime _Error7[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], Never]]]]]]]
comptime _Result8[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value, O7: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _Pick[O7, _NoResult]]]]]]]]
comptime _Error8[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType, E7: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], _CommonError[_NativeError[E7], Never]]]]]]]]
comptime _Result9[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value, O7: Value, O8: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _Pick[O7, _Pick[O8, _NoResult]]]]]]]]]
comptime _Error9[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType, E7: AnyType, E8: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], _CommonError[_NativeError[E7], _CommonError[_NativeError[E8], Never]]]]]]]]]
comptime _Result10[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value, O7: Value, O8: Value, O9: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _Pick[O7, _Pick[O8, _Pick[O9, _NoResult]]]]]]]]]]
comptime _Error10[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType, E7: AnyType, E8: AnyType, E9: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], _CommonError[_NativeError[E7], _CommonError[_NativeError[E8], _CommonError[_NativeError[E9], Never]]]]]]]]]]
comptime _Result11[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value, O7: Value, O8: Value, O9: Value, O10: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _Pick[O7, _Pick[O8, _Pick[O9, _Pick[O10, _NoResult]]]]]]]]]]]
comptime _Error11[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType, E7: AnyType, E8: AnyType, E9: AnyType, E10: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], _CommonError[_NativeError[E7], _CommonError[_NativeError[E8], _CommonError[_NativeError[E9], _CommonError[_NativeError[E10], Never]]]]]]]]]]]
comptime _Result12[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value, O7: Value, O8: Value, O9: Value, O10: Value, O11: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _Pick[O7, _Pick[O8, _Pick[O9, _Pick[O10, _Pick[O11, _NoResult]]]]]]]]]]]]
comptime _Error12[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType, E7: AnyType, E8: AnyType, E9: AnyType, E10: AnyType, E11: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], _CommonError[_NativeError[E7], _CommonError[_NativeError[E8], _CommonError[_NativeError[E9], _CommonError[_NativeError[E10], _CommonError[_NativeError[E11], Never]]]]]]]]]]]]
comptime _Result13[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value, O7: Value, O8: Value, O9: Value, O10: Value, O11: Value, O12: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _Pick[O7, _Pick[O8, _Pick[O9, _Pick[O10, _Pick[O11, _Pick[O12, _NoResult]]]]]]]]]]]]]
comptime _Error13[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType, E7: AnyType, E8: AnyType, E9: AnyType, E10: AnyType, E11: AnyType, E12: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], _CommonError[_NativeError[E7], _CommonError[_NativeError[E8], _CommonError[_NativeError[E9], _CommonError[_NativeError[E10], _CommonError[_NativeError[E11], _CommonError[_NativeError[E12], Never]]]]]]]]]]]]]
comptime _Result14[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value, O7: Value, O8: Value, O9: Value, O10: Value, O11: Value, O12: Value, O13: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _Pick[O7, _Pick[O8, _Pick[O9, _Pick[O10, _Pick[O11, _Pick[O12, _Pick[O13, _NoResult]]]]]]]]]]]]]]
comptime _Error14[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType, E7: AnyType, E8: AnyType, E9: AnyType, E10: AnyType, E11: AnyType, E12: AnyType, E13: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], _CommonError[_NativeError[E7], _CommonError[_NativeError[E8], _CommonError[_NativeError[E9], _CommonError[_NativeError[E10], _CommonError[_NativeError[E11], _CommonError[_NativeError[E12], _CommonError[_NativeError[E13], Never]]]]]]]]]]]]]]
comptime _Result15[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value, O7: Value, O8: Value, O9: Value, O10: Value, O11: Value, O12: Value, O13: Value, O14: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _Pick[O7, _Pick[O8, _Pick[O9, _Pick[O10, _Pick[O11, _Pick[O12, _Pick[O13, _Pick[O14, _NoResult]]]]]]]]]]]]]]]
comptime _Error15[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType, E7: AnyType, E8: AnyType, E9: AnyType, E10: AnyType, E11: AnyType, E12: AnyType, E13: AnyType, E14: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], _CommonError[_NativeError[E7], _CommonError[_NativeError[E8], _CommonError[_NativeError[E9], _CommonError[_NativeError[E10], _CommonError[_NativeError[E11], _CommonError[_NativeError[E12], _CommonError[_NativeError[E13], _CommonError[_NativeError[E14], Never]]]]]]]]]]]]]]]
comptime _Result16[O0: Value, O1: Value, O2: Value, O3: Value, O4: Value, O5: Value, O6: Value, O7: Value, O8: Value, O9: Value, O10: Value, O11: Value, O12: Value, O13: Value, O14: Value, O15: Value]: Value = _Pick[O0, _Pick[O1, _Pick[O2, _Pick[O3, _Pick[O4, _Pick[O5, _Pick[O6, _Pick[O7, _Pick[O8, _Pick[O9, _Pick[O10, _Pick[O11, _Pick[O12, _Pick[O13, _Pick[O14, _Pick[O15, _NoResult]]]]]]]]]]]]]]]]
comptime _Error16[E0: AnyType, E1: AnyType, E2: AnyType, E3: AnyType, E4: AnyType, E5: AnyType, E6: AnyType, E7: AnyType, E8: AnyType, E9: AnyType, E10: AnyType, E11: AnyType, E12: AnyType, E13: AnyType, E14: AnyType, E15: AnyType]: Value = _CommonError[_NativeError[E0], _CommonError[_NativeError[E1], _CommonError[_NativeError[E2], _CommonError[_NativeError[E3], _CommonError[_NativeError[E4], _CommonError[_NativeError[E5], _CommonError[_NativeError[E6], _CommonError[_NativeError[E7], _CommonError[_NativeError[E8], _CommonError[_NativeError[E9], _CommonError[_NativeError[E10], _CommonError[_NativeError[E11], _CommonError[_NativeError[E12], _CommonError[_NativeError[E13], _CommonError[_NativeError[E14], _CommonError[_NativeError[E15], Never]]]]]]]]]]]]]]]]


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0
) raises _Error1[E0] -> _Result1[O0]:
    """Match `subject` with clauses: the first that applies to it gives the result.

    Takes one to sixteen clauses. A clause is a plain function or a lambda without
    captures; its parameter type says which values it applies to, and a `when`
    clause may decline. The clauses are checked when the program compiles. The
    subject is one of:

    - a `Node[F]`: a clause takes a constructor of `F`, whose recursive fields are
      declared either as stored, `Node[F]`, or as the result type, in which case
      they arrive already matched; or it takes `Node[F]`, which accepts any
      constructor. A clause returns the result or `Next(node)`, to continue with a
      smaller value.
    - a value stored in place, such as `Choice[F]` or `Result[T, E]`: a clause
      takes a constructor, or the whole type.
    - an `Optional[T]`: a clause takes `T` for a present value, `NoneType` for an
      absent one, or `Optional[T]`.

    Parameters:
        S: The subject's type.
        A0: The clause's parameter type.
        O0: The clause's result type: the result, `Next[Node[F]]`, or a guarded result.
        E0: The clause's error type, `Never` for a pure clause.

    Args:
        subject: The value to match, borrowed.
        f0: The first clause; further clauses follow in order.

    Returns:
        The result of the first clause that applies.

    Raises:
        The clauses' common error; a match of pure clauses does not raise.
    """
    return _match[_Result1[O0], _Error1[E0]](subject, _push1(f0, _Nil()), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1
) raises _Error2[E0, E1] -> _Result2[O0, O1]:
    """Match `subject` with 2 clauses."""
    return _match[_Result2[O0, O1], _Error2[E0, E1]](subject, _push1(f0, _push1(f1, _Nil())), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2
) raises _Error3[E0, E1, E2] -> _Result3[O0, O1, O2]:
    """Match `subject` with 3 clauses."""
    return _match[_Result3[O0, O1, O2], _Error3[E0, E1, E2]](subject, _push1(f0, _push1(f1, _push1(f2, _Nil()))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3
) raises _Error4[E0, E1, E2, E3] -> _Result4[O0, O1, O2, O3]:
    """Match `subject` with 4 clauses."""
    return _match[_Result4[O0, O1, O2, O3], _Error4[E0, E1, E2, E3]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _Nil())))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4
) raises _Error5[E0, E1, E2, E3, E4] -> _Result5[O0, O1, O2, O3, O4]:
    """Match `subject` with 5 clauses."""
    return _match[_Result5[O0, O1, O2, O3, O4], _Error5[E0, E1, E2, E3, E4]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _Nil()))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5
) raises _Error6[E0, E1, E2, E3, E4, E5] -> _Result6[O0, O1, O2, O3, O4, O5]:
    """Match `subject` with 6 clauses."""
    return _match[_Result6[O0, O1, O2, O3, O4, O5], _Error6[E0, E1, E2, E3, E4, E5]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _Nil())))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6
) raises _Error7[E0, E1, E2, E3, E4, E5, E6] -> _Result7[O0, O1, O2, O3, O4, O5, O6]:
    """Match `subject` with 7 clauses."""
    return _match[_Result7[O0, O1, O2, O3, O4, O5, O6], _Error7[E0, E1, E2, E3, E4, E5, E6]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _Nil()))))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7
) raises _Error8[E0, E1, E2, E3, E4, E5, E6, E7] -> _Result8[O0, O1, O2, O3, O4, O5, O6, O7]:
    """Match `subject` with 8 clauses."""
    return _match[_Result8[O0, O1, O2, O3, O4, O5, O6, O7], _Error8[E0, E1, E2, E3, E4, E5, E6, E7]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _Nil())))))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8
) raises _Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8] -> _Result9[O0, O1, O2, O3, O4, O5, O6, O7, O8]:
    """Match `subject` with 9 clauses."""
    return _match[_Result9[O0, O1, O2, O3, O4, O5, O6, O7, O8], _Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _Nil()))))))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9
) raises _Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9] -> _Result10[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9]:
    """Match `subject` with 10 clauses."""
    return _match[_Result10[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9], _Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _Nil())))))))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10
) raises _Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10] -> _Result11[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10]:
    """Match `subject` with 11 clauses."""
    return _match[_Result11[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10], _Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _Nil()))))))))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11
) raises _Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11] -> _Result12[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11]:
    """Match `subject` with 12 clauses."""
    return _match[_Result12[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11], _Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _Nil())))))))))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, O12: Value, E12: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11,
    f12: def(A12) raises E12 thin -> O12
) raises _Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12] -> _Result13[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12]:
    """Match `subject` with 13 clauses."""
    return _match[_Result13[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12], _Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _push1(f12, _Nil()))))))))))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, O13: Value, E13: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11,
    f12: def(A12) raises E12 thin -> O12,
    f13: def(A13) raises E13 thin -> O13
) raises _Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13] -> _Result14[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13]:
    """Match `subject` with 14 clauses."""
    return _match[_Result14[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13], _Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _push1(f12, _push1(f13, _Nil())))))))))))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, O14: Value, E14: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11,
    f12: def(A12) raises E12 thin -> O12,
    f13: def(A13) raises E13 thin -> O13,
    f14: def(A14) raises E14 thin -> O14
) raises _Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14] -> _Result15[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14]:
    """Match `subject` with 15 clauses."""
    return _match[_Result15[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14], _Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _push1(f12, _push1(f13, _push1(f14, _Nil()))))))))))))))), _Absent())


def `match`[
    S: AnyType,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, O14: Value, E14: AnyType,
    A15: AnyType, O15: Value, E15: AnyType,
    //
](
    subject: S,
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11,
    f12: def(A12) raises E12 thin -> O12,
    f13: def(A13) raises E13 thin -> O13,
    f14: def(A14) raises E14 thin -> O14,
    f15: def(A15) raises E15 thin -> O15
) raises _Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15] -> _Result16[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15]:
    """Match `subject` with 16 clauses."""
    return _match[_Result16[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15], _Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _push1(f12, _push1(f13, _push1(f14, _push1(f15, _Nil())))))))))))))))), _Absent())


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    *,
    context: X
) raises _Error1[E0] -> _Result1[O0]:
    """Match `subject` with clauses that also take `context` as their second parameter.

    The context is borrowed and passed to every clause, for data the clauses need
    but the subject does not hold. Otherwise as the match without a context.

    Parameters:
        S: The subject's type.
        X: The context type.
        A0: The clause's parameter type.
        B0: The clause's second parameter type, which must be the context type.
        O0: The clause's result type: the result, `Next[Node[F]]`, or a guarded result.
        E0: The clause's error type, `Never` for a pure clause.

    Args:
        subject: The value to match.
        f0: The first clause; further clauses follow in order.
        context: The value passed to every clause.

    Returns:
        The result of the first clause that applies.

    Raises:
        The clauses' common error; a match of pure clauses does not raise.
    """
    return _match[_Result1[O0], _Error1[E0]](subject, _push2(f0, _Nil()), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    *,
    context: X
) raises _Error2[E0, E1] -> _Result2[O0, O1]:
    """Match `subject` with 2 clauses that also take `context`."""
    return _match[_Result2[O0, O1], _Error2[E0, E1]](subject, _push2(f0, _push2(f1, _Nil())), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    *,
    context: X
) raises _Error3[E0, E1, E2] -> _Result3[O0, O1, O2]:
    """Match `subject` with 3 clauses that also take `context`."""
    return _match[_Result3[O0, O1, O2], _Error3[E0, E1, E2]](subject, _push2(f0, _push2(f1, _push2(f2, _Nil()))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    *,
    context: X
) raises _Error4[E0, E1, E2, E3] -> _Result4[O0, O1, O2, O3]:
    """Match `subject` with 4 clauses that also take `context`."""
    return _match[_Result4[O0, O1, O2, O3], _Error4[E0, E1, E2, E3]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _Nil())))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    *,
    context: X
) raises _Error5[E0, E1, E2, E3, E4] -> _Result5[O0, O1, O2, O3, O4]:
    """Match `subject` with 5 clauses that also take `context`."""
    return _match[_Result5[O0, O1, O2, O3, O4], _Error5[E0, E1, E2, E3, E4]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _Nil()))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    *,
    context: X
) raises _Error6[E0, E1, E2, E3, E4, E5] -> _Result6[O0, O1, O2, O3, O4, O5]:
    """Match `subject` with 6 clauses that also take `context`."""
    return _match[_Result6[O0, O1, O2, O3, O4, O5], _Error6[E0, E1, E2, E3, E4, E5]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _Nil())))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    *,
    context: X
) raises _Error7[E0, E1, E2, E3, E4, E5, E6] -> _Result7[O0, O1, O2, O3, O4, O5, O6]:
    """Match `subject` with 7 clauses that also take `context`."""
    return _match[_Result7[O0, O1, O2, O3, O4, O5, O6], _Error7[E0, E1, E2, E3, E4, E5, E6]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _Nil()))))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    *,
    context: X
) raises _Error8[E0, E1, E2, E3, E4, E5, E6, E7] -> _Result8[O0, O1, O2, O3, O4, O5, O6, O7]:
    """Match `subject` with 8 clauses that also take `context`."""
    return _match[_Result8[O0, O1, O2, O3, O4, O5, O6, O7], _Error8[E0, E1, E2, E3, E4, E5, E6, E7]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _Nil())))))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    *,
    context: X
) raises _Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8] -> _Result9[O0, O1, O2, O3, O4, O5, O6, O7, O8]:
    """Match `subject` with 9 clauses that also take `context`."""
    return _match[_Result9[O0, O1, O2, O3, O4, O5, O6, O7, O8], _Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _Nil()))))))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    *,
    context: X
) raises _Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9] -> _Result10[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9]:
    """Match `subject` with 10 clauses that also take `context`."""
    return _match[_Result10[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9], _Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _Nil())))))))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    *,
    context: X
) raises _Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10] -> _Result11[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10]:
    """Match `subject` with 11 clauses that also take `context`."""
    return _match[_Result11[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10], _Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _Nil()))))))))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11,
    *,
    context: X
) raises _Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11] -> _Result12[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11]:
    """Match `subject` with 12 clauses that also take `context`."""
    return _match[_Result12[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11], _Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _Nil())))))))))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, O12: Value, E12: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11,
    f12: def(A12, B12) raises E12 thin -> O12,
    *,
    context: X
) raises _Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12] -> _Result13[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12]:
    """Match `subject` with 13 clauses that also take `context`."""
    return _match[_Result13[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12], _Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _push2(f12, _Nil()))))))))))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, B13: AnyType, O13: Value, E13: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11,
    f12: def(A12, B12) raises E12 thin -> O12,
    f13: def(A13, B13) raises E13 thin -> O13,
    *,
    context: X
) raises _Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13] -> _Result14[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13]:
    """Match `subject` with 14 clauses that also take `context`."""
    return _match[_Result14[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13], _Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _push2(f12, _push2(f13, _Nil())))))))))))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, B13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, B14: AnyType, O14: Value, E14: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11,
    f12: def(A12, B12) raises E12 thin -> O12,
    f13: def(A13, B13) raises E13 thin -> O13,
    f14: def(A14, B14) raises E14 thin -> O14,
    *,
    context: X
) raises _Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14] -> _Result15[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14]:
    """Match `subject` with 15 clauses that also take `context`."""
    return _match[_Result15[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14], _Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _push2(f12, _push2(f13, _push2(f14, _Nil()))))))))))))))), context)


def `match`[
    S: AnyType, X: AnyType,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, B13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, B14: AnyType, O14: Value, E14: AnyType,
    A15: AnyType, B15: AnyType, O15: Value, E15: AnyType,
    //
](
    subject: S,
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11,
    f12: def(A12, B12) raises E12 thin -> O12,
    f13: def(A13, B13) raises E13 thin -> O13,
    f14: def(A14, B14) raises E14 thin -> O14,
    f15: def(A15, B15) raises E15 thin -> O15,
    *,
    context: X
) raises _Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15] -> _Result16[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15]:
    """Match `subject` with 16 clauses that also take `context`."""
    return _match[_Result16[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15], _Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15]](subject, _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _push2(f12, _push2(f13, _push2(f14, _push2(f15, _Nil())))))))))))))))), context)


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0
) raises _Error1[E0] -> _Result1[O0]:
    """Match two subjects together: the first clause that applies to both gives the result.

    A clause takes one parameter per subject, as for a single subject: a
    constructor (for a `Node`, as stored) or the whole type, the type of a
    present `Optional` value or `NoneType`, or for any other subject its type.
    Every combination of cases must be covered. Nothing is evaluated recursively
    and `Next` is not available.

    Parameters:
        S0: The first subject's type.
        S1: The second subject's type.
        A0: The clause's first parameter type.
        B0: The clause's second parameter type.
        O0: The clause's result type, or a guarded result.
        E0: The clause's error type, `Never` for a pure clause.

    Args:
        subjects: The values to match.
        f0: The first clause; further clauses follow in order.

    Returns:
        The result of the first clause that applies.

    Raises:
        The clauses' common error; a match of pure clauses does not raise.
    """
    return _match_all[_Result1[O0], _Error1[E0]](subjects[0], subjects[1], _Absent(), _push2(f0, _Nil()))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1
) raises _Error2[E0, E1] -> _Result2[O0, O1]:
    """Match two subjects with 2 clauses."""
    return _match_all[_Result2[O0, O1], _Error2[E0, E1]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _Nil())))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2
) raises _Error3[E0, E1, E2] -> _Result3[O0, O1, O2]:
    """Match two subjects with 3 clauses."""
    return _match_all[_Result3[O0, O1, O2], _Error3[E0, E1, E2]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _Nil()))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3
) raises _Error4[E0, E1, E2, E3] -> _Result4[O0, O1, O2, O3]:
    """Match two subjects with 4 clauses."""
    return _match_all[_Result4[O0, O1, O2, O3], _Error4[E0, E1, E2, E3]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _Nil())))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4
) raises _Error5[E0, E1, E2, E3, E4] -> _Result5[O0, O1, O2, O3, O4]:
    """Match two subjects with 5 clauses."""
    return _match_all[_Result5[O0, O1, O2, O3, O4], _Error5[E0, E1, E2, E3, E4]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _Nil()))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5
) raises _Error6[E0, E1, E2, E3, E4, E5] -> _Result6[O0, O1, O2, O3, O4, O5]:
    """Match two subjects with 6 clauses."""
    return _match_all[_Result6[O0, O1, O2, O3, O4, O5], _Error6[E0, E1, E2, E3, E4, E5]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _Nil())))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6
) raises _Error7[E0, E1, E2, E3, E4, E5, E6] -> _Result7[O0, O1, O2, O3, O4, O5, O6]:
    """Match two subjects with 7 clauses."""
    return _match_all[_Result7[O0, O1, O2, O3, O4, O5, O6], _Error7[E0, E1, E2, E3, E4, E5, E6]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _Nil()))))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7
) raises _Error8[E0, E1, E2, E3, E4, E5, E6, E7] -> _Result8[O0, O1, O2, O3, O4, O5, O6, O7]:
    """Match two subjects with 8 clauses."""
    return _match_all[_Result8[O0, O1, O2, O3, O4, O5, O6, O7], _Error8[E0, E1, E2, E3, E4, E5, E6, E7]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _Nil())))))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8
) raises _Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8] -> _Result9[O0, O1, O2, O3, O4, O5, O6, O7, O8]:
    """Match two subjects with 9 clauses."""
    return _match_all[_Result9[O0, O1, O2, O3, O4, O5, O6, O7, O8], _Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _Nil()))))))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9
) raises _Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9] -> _Result10[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9]:
    """Match two subjects with 10 clauses."""
    return _match_all[_Result10[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9], _Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _Nil())))))))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10
) raises _Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10] -> _Result11[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10]:
    """Match two subjects with 11 clauses."""
    return _match_all[_Result11[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10], _Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _Nil()))))))))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11
) raises _Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11] -> _Result12[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11]:
    """Match two subjects with 12 clauses."""
    return _match_all[_Result12[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11], _Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _Nil())))))))))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, O12: Value, E12: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11,
    f12: def(A12, B12) raises E12 thin -> O12
) raises _Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12] -> _Result13[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12]:
    """Match two subjects with 13 clauses."""
    return _match_all[_Result13[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12], _Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _push2(f12, _Nil()))))))))))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, B13: AnyType, O13: Value, E13: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11,
    f12: def(A12, B12) raises E12 thin -> O12,
    f13: def(A13, B13) raises E13 thin -> O13
) raises _Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13] -> _Result14[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13]:
    """Match two subjects with 14 clauses."""
    return _match_all[_Result14[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13], _Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _push2(f12, _push2(f13, _Nil())))))))))))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, B13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, B14: AnyType, O14: Value, E14: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11,
    f12: def(A12, B12) raises E12 thin -> O12,
    f13: def(A13, B13) raises E13 thin -> O13,
    f14: def(A14, B14) raises E14 thin -> O14
) raises _Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14] -> _Result15[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14]:
    """Match two subjects with 15 clauses."""
    return _match_all[_Result15[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14], _Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _push2(f12, _push2(f13, _push2(f14, _Nil()))))))))))))))))


def `match`[
    S0: Movable, S1: Movable,
    A0: AnyType, B0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, B13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, B14: AnyType, O14: Value, E14: AnyType,
    A15: AnyType, B15: AnyType, O15: Value, E15: AnyType,
    //
](
    subjects: Tuple[S0, S1],
    f0: def(A0, B0) raises E0 thin -> O0,
    f1: def(A1, B1) raises E1 thin -> O1,
    f2: def(A2, B2) raises E2 thin -> O2,
    f3: def(A3, B3) raises E3 thin -> O3,
    f4: def(A4, B4) raises E4 thin -> O4,
    f5: def(A5, B5) raises E5 thin -> O5,
    f6: def(A6, B6) raises E6 thin -> O6,
    f7: def(A7, B7) raises E7 thin -> O7,
    f8: def(A8, B8) raises E8 thin -> O8,
    f9: def(A9, B9) raises E9 thin -> O9,
    f10: def(A10, B10) raises E10 thin -> O10,
    f11: def(A11, B11) raises E11 thin -> O11,
    f12: def(A12, B12) raises E12 thin -> O12,
    f13: def(A13, B13) raises E13 thin -> O13,
    f14: def(A14, B14) raises E14 thin -> O14,
    f15: def(A15, B15) raises E15 thin -> O15
) raises _Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15] -> _Result16[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15]:
    """Match two subjects with 16 clauses."""
    return _match_all[_Result16[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15], _Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15]](subjects[0], subjects[1], _Absent(), _push2(f0, _push2(f1, _push2(f2, _push2(f3, _push2(f4, _push2(f5, _push2(f6, _push2(f7, _push2(f8, _push2(f9, _push2(f10, _push2(f11, _push2(f12, _push2(f13, _push2(f14, _push2(f15, _Nil())))))))))))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0
) raises _Error1[E0] -> _Result1[O0]:
    """Match three subjects together: the first clause that applies to all of them gives the result.

    As the match of two subjects, with one more parameter per clause.

    Parameters:
        S0: The first subject's type.
        S1: The second subject's type.
        S2: The third subject's type.
        A0: The clause's first parameter type.
        B0: The clause's second parameter type.
        C0: The clause's third parameter type.
        O0: The clause's result type, or a guarded result.
        E0: The clause's error type, `Never` for a pure clause.

    Args:
        subjects: The values to match.
        f0: The first clause; further clauses follow in order.

    Returns:
        The result of the first clause that applies.

    Raises:
        The clauses' common error; a match of pure clauses does not raise.
    """
    return _match_all[_Result1[O0], _Error1[E0]](subjects[0], subjects[1], subjects[2], _push3(f0, _Nil()))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1
) raises _Error2[E0, E1] -> _Result2[O0, O1]:
    """Match three subjects with 2 clauses."""
    return _match_all[_Result2[O0, O1], _Error2[E0, E1]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _Nil())))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2
) raises _Error3[E0, E1, E2] -> _Result3[O0, O1, O2]:
    """Match three subjects with 3 clauses."""
    return _match_all[_Result3[O0, O1, O2], _Error3[E0, E1, E2]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _Nil()))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3
) raises _Error4[E0, E1, E2, E3] -> _Result4[O0, O1, O2, O3]:
    """Match three subjects with 4 clauses."""
    return _match_all[_Result4[O0, O1, O2, O3], _Error4[E0, E1, E2, E3]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _Nil())))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4
) raises _Error5[E0, E1, E2, E3, E4] -> _Result5[O0, O1, O2, O3, O4]:
    """Match three subjects with 5 clauses."""
    return _match_all[_Result5[O0, O1, O2, O3, O4], _Error5[E0, E1, E2, E3, E4]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _Nil()))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5
) raises _Error6[E0, E1, E2, E3, E4, E5] -> _Result6[O0, O1, O2, O3, O4, O5]:
    """Match three subjects with 6 clauses."""
    return _match_all[_Result6[O0, O1, O2, O3, O4, O5], _Error6[E0, E1, E2, E3, E4, E5]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _Nil())))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6
) raises _Error7[E0, E1, E2, E3, E4, E5, E6] -> _Result7[O0, O1, O2, O3, O4, O5, O6]:
    """Match three subjects with 7 clauses."""
    return _match_all[_Result7[O0, O1, O2, O3, O4, O5, O6], _Error7[E0, E1, E2, E3, E4, E5, E6]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _Nil()))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, C7: AnyType, O7: Value, E7: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6,
    f7: def(A7, B7, C7) raises E7 thin -> O7
) raises _Error8[E0, E1, E2, E3, E4, E5, E6, E7] -> _Result8[O0, O1, O2, O3, O4, O5, O6, O7]:
    """Match three subjects with 8 clauses."""
    return _match_all[_Result8[O0, O1, O2, O3, O4, O5, O6, O7], _Error8[E0, E1, E2, E3, E4, E5, E6, E7]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _push3(f7, _Nil())))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, C7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, C8: AnyType, O8: Value, E8: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6,
    f7: def(A7, B7, C7) raises E7 thin -> O7,
    f8: def(A8, B8, C8) raises E8 thin -> O8
) raises _Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8] -> _Result9[O0, O1, O2, O3, O4, O5, O6, O7, O8]:
    """Match three subjects with 9 clauses."""
    return _match_all[_Result9[O0, O1, O2, O3, O4, O5, O6, O7, O8], _Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _push3(f7, _push3(f8, _Nil()))))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, C7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, C8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, C9: AnyType, O9: Value, E9: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6,
    f7: def(A7, B7, C7) raises E7 thin -> O7,
    f8: def(A8, B8, C8) raises E8 thin -> O8,
    f9: def(A9, B9, C9) raises E9 thin -> O9
) raises _Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9] -> _Result10[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9]:
    """Match three subjects with 10 clauses."""
    return _match_all[_Result10[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9], _Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _push3(f7, _push3(f8, _push3(f9, _Nil())))))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, C7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, C8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, C9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, C10: AnyType, O10: Value, E10: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6,
    f7: def(A7, B7, C7) raises E7 thin -> O7,
    f8: def(A8, B8, C8) raises E8 thin -> O8,
    f9: def(A9, B9, C9) raises E9 thin -> O9,
    f10: def(A10, B10, C10) raises E10 thin -> O10
) raises _Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10] -> _Result11[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10]:
    """Match three subjects with 11 clauses."""
    return _match_all[_Result11[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10], _Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _push3(f7, _push3(f8, _push3(f9, _push3(f10, _Nil()))))))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, C7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, C8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, C9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, C10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, C11: AnyType, O11: Value, E11: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6,
    f7: def(A7, B7, C7) raises E7 thin -> O7,
    f8: def(A8, B8, C8) raises E8 thin -> O8,
    f9: def(A9, B9, C9) raises E9 thin -> O9,
    f10: def(A10, B10, C10) raises E10 thin -> O10,
    f11: def(A11, B11, C11) raises E11 thin -> O11
) raises _Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11] -> _Result12[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11]:
    """Match three subjects with 12 clauses."""
    return _match_all[_Result12[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11], _Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _push3(f7, _push3(f8, _push3(f9, _push3(f10, _push3(f11, _Nil())))))))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, C7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, C8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, C9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, C10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, C11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, C12: AnyType, O12: Value, E12: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6,
    f7: def(A7, B7, C7) raises E7 thin -> O7,
    f8: def(A8, B8, C8) raises E8 thin -> O8,
    f9: def(A9, B9, C9) raises E9 thin -> O9,
    f10: def(A10, B10, C10) raises E10 thin -> O10,
    f11: def(A11, B11, C11) raises E11 thin -> O11,
    f12: def(A12, B12, C12) raises E12 thin -> O12
) raises _Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12] -> _Result13[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12]:
    """Match three subjects with 13 clauses."""
    return _match_all[_Result13[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12], _Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _push3(f7, _push3(f8, _push3(f9, _push3(f10, _push3(f11, _push3(f12, _Nil()))))))))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, C7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, C8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, C9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, C10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, C11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, C12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, B13: AnyType, C13: AnyType, O13: Value, E13: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6,
    f7: def(A7, B7, C7) raises E7 thin -> O7,
    f8: def(A8, B8, C8) raises E8 thin -> O8,
    f9: def(A9, B9, C9) raises E9 thin -> O9,
    f10: def(A10, B10, C10) raises E10 thin -> O10,
    f11: def(A11, B11, C11) raises E11 thin -> O11,
    f12: def(A12, B12, C12) raises E12 thin -> O12,
    f13: def(A13, B13, C13) raises E13 thin -> O13
) raises _Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13] -> _Result14[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13]:
    """Match three subjects with 14 clauses."""
    return _match_all[_Result14[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13], _Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _push3(f7, _push3(f8, _push3(f9, _push3(f10, _push3(f11, _push3(f12, _push3(f13, _Nil())))))))))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, C7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, C8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, C9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, C10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, C11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, C12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, B13: AnyType, C13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, B14: AnyType, C14: AnyType, O14: Value, E14: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6,
    f7: def(A7, B7, C7) raises E7 thin -> O7,
    f8: def(A8, B8, C8) raises E8 thin -> O8,
    f9: def(A9, B9, C9) raises E9 thin -> O9,
    f10: def(A10, B10, C10) raises E10 thin -> O10,
    f11: def(A11, B11, C11) raises E11 thin -> O11,
    f12: def(A12, B12, C12) raises E12 thin -> O12,
    f13: def(A13, B13, C13) raises E13 thin -> O13,
    f14: def(A14, B14, C14) raises E14 thin -> O14
) raises _Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14] -> _Result15[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14]:
    """Match three subjects with 15 clauses."""
    return _match_all[_Result15[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14], _Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _push3(f7, _push3(f8, _push3(f9, _push3(f10, _push3(f11, _push3(f12, _push3(f13, _push3(f14, _Nil()))))))))))))))))


def `match`[
    S0: Movable, S1: Movable, S2: Movable,
    A0: AnyType, B0: AnyType, C0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, B1: AnyType, C1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, B2: AnyType, C2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, B3: AnyType, C3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, B4: AnyType, C4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, B5: AnyType, C5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, B6: AnyType, C6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, B7: AnyType, C7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, B8: AnyType, C8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, B9: AnyType, C9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, B10: AnyType, C10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, B11: AnyType, C11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, B12: AnyType, C12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, B13: AnyType, C13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, B14: AnyType, C14: AnyType, O14: Value, E14: AnyType,
    A15: AnyType, B15: AnyType, C15: AnyType, O15: Value, E15: AnyType,
    //
](
    subjects: Tuple[S0, S1, S2],
    f0: def(A0, B0, C0) raises E0 thin -> O0,
    f1: def(A1, B1, C1) raises E1 thin -> O1,
    f2: def(A2, B2, C2) raises E2 thin -> O2,
    f3: def(A3, B3, C3) raises E3 thin -> O3,
    f4: def(A4, B4, C4) raises E4 thin -> O4,
    f5: def(A5, B5, C5) raises E5 thin -> O5,
    f6: def(A6, B6, C6) raises E6 thin -> O6,
    f7: def(A7, B7, C7) raises E7 thin -> O7,
    f8: def(A8, B8, C8) raises E8 thin -> O8,
    f9: def(A9, B9, C9) raises E9 thin -> O9,
    f10: def(A10, B10, C10) raises E10 thin -> O10,
    f11: def(A11, B11, C11) raises E11 thin -> O11,
    f12: def(A12, B12, C12) raises E12 thin -> O12,
    f13: def(A13, B13, C13) raises E13 thin -> O13,
    f14: def(A14, B14, C14) raises E14 thin -> O14,
    f15: def(A15, B15, C15) raises E15 thin -> O15
) raises _Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15] -> _Result16[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15]:
    """Match three subjects with 16 clauses."""
    return _match_all[_Result16[O0, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15], _Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15]](subjects[0], subjects[1], subjects[2], _push3(f0, _push3(f1, _push3(f2, _push3(f3, _push3(f4, _push3(f5, _push3(f6, _push3(f7, _push3(f8, _push3(f9, _push3(f10, _push3(f11, _push3(f12, _push3(f13, _push3(f14, _push3(f15, _Nil())))))))))))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0
) raises _Error1[E0] -> Node[F]:
    """Rewrite `subject` bottom-up with clauses for the constructors that change.

    A clause takes a constructor of `F` and returns the new `Node[F]`; its
    recursive fields declared as `Node[F]` arrive already rewritten. Every other
    node is rebuilt from its rewritten children, and a node whose children did not
    change is reused, so sharing is preserved. A `when` clause may decline. The
    rewrite is a single pass.

    Parameters:
        F: The data type.
        A0: The clause's parameter type.
        O0: The clause's result type: `Node[F]`, or a guarded `Node[F]`.
        E0: The clause's error type, `Never` for a pure clause.

    Args:
        subject: The value to rewrite.
        f0: The first clause; further clauses follow in order.

    Returns:
        The rewritten value.

    Raises:
        The clauses' common error; a rewrite of pure clauses does not raise.
    """
    return _rewrite[_Error1[E0]](subject, _push1(f0, _Nil()))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1
) raises _Error2[E0, E1] -> Node[F]:
    """Rewrite `subject` bottom-up with 2 clauses."""
    return _rewrite[_Error2[E0, E1]](subject, _push1(f0, _push1(f1, _Nil())))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2
) raises _Error3[E0, E1, E2] -> Node[F]:
    """Rewrite `subject` bottom-up with 3 clauses."""
    return _rewrite[_Error3[E0, E1, E2]](subject, _push1(f0, _push1(f1, _push1(f2, _Nil()))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3
) raises _Error4[E0, E1, E2, E3] -> Node[F]:
    """Rewrite `subject` bottom-up with 4 clauses."""
    return _rewrite[_Error4[E0, E1, E2, E3]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _Nil())))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4
) raises _Error5[E0, E1, E2, E3, E4] -> Node[F]:
    """Rewrite `subject` bottom-up with 5 clauses."""
    return _rewrite[_Error5[E0, E1, E2, E3, E4]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _Nil()))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5
) raises _Error6[E0, E1, E2, E3, E4, E5] -> Node[F]:
    """Rewrite `subject` bottom-up with 6 clauses."""
    return _rewrite[_Error6[E0, E1, E2, E3, E4, E5]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _Nil())))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6
) raises _Error7[E0, E1, E2, E3, E4, E5, E6] -> Node[F]:
    """Rewrite `subject` bottom-up with 7 clauses."""
    return _rewrite[_Error7[E0, E1, E2, E3, E4, E5, E6]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _Nil()))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7
) raises _Error8[E0, E1, E2, E3, E4, E5, E6, E7] -> Node[F]:
    """Rewrite `subject` bottom-up with 8 clauses."""
    return _rewrite[_Error8[E0, E1, E2, E3, E4, E5, E6, E7]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _Nil())))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8
) raises _Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8] -> Node[F]:
    """Rewrite `subject` bottom-up with 9 clauses."""
    return _rewrite[_Error9[E0, E1, E2, E3, E4, E5, E6, E7, E8]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _Nil()))))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9
) raises _Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9] -> Node[F]:
    """Rewrite `subject` bottom-up with 10 clauses."""
    return _rewrite[_Error10[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _Nil())))))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10
) raises _Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10] -> Node[F]:
    """Rewrite `subject` bottom-up with 11 clauses."""
    return _rewrite[_Error11[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _Nil()))))))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11
) raises _Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11] -> Node[F]:
    """Rewrite `subject` bottom-up with 12 clauses."""
    return _rewrite[_Error12[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _Nil())))))))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, O12: Value, E12: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11,
    f12: def(A12) raises E12 thin -> O12
) raises _Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12] -> Node[F]:
    """Rewrite `subject` bottom-up with 13 clauses."""
    return _rewrite[_Error13[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _push1(f12, _Nil()))))))))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, O13: Value, E13: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11,
    f12: def(A12) raises E12 thin -> O12,
    f13: def(A13) raises E13 thin -> O13
) raises _Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13] -> Node[F]:
    """Rewrite `subject` bottom-up with 14 clauses."""
    return _rewrite[_Error14[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _push1(f12, _push1(f13, _Nil())))))))))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, O14: Value, E14: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11,
    f12: def(A12) raises E12 thin -> O12,
    f13: def(A13) raises E13 thin -> O13,
    f14: def(A14) raises E14 thin -> O14
) raises _Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14] -> Node[F]:
    """Rewrite `subject` bottom-up with 15 clauses."""
    return _rewrite[_Error15[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _push1(f12, _push1(f13, _push1(f14, _Nil()))))))))))))))))


def rewrite[
    F: Data,
    A0: AnyType, O0: Value, E0: AnyType,
    A1: AnyType, O1: Value, E1: AnyType,
    A2: AnyType, O2: Value, E2: AnyType,
    A3: AnyType, O3: Value, E3: AnyType,
    A4: AnyType, O4: Value, E4: AnyType,
    A5: AnyType, O5: Value, E5: AnyType,
    A6: AnyType, O6: Value, E6: AnyType,
    A7: AnyType, O7: Value, E7: AnyType,
    A8: AnyType, O8: Value, E8: AnyType,
    A9: AnyType, O9: Value, E9: AnyType,
    A10: AnyType, O10: Value, E10: AnyType,
    A11: AnyType, O11: Value, E11: AnyType,
    A12: AnyType, O12: Value, E12: AnyType,
    A13: AnyType, O13: Value, E13: AnyType,
    A14: AnyType, O14: Value, E14: AnyType,
    A15: AnyType, O15: Value, E15: AnyType,
    //
](
    subject: Node[F],
    f0: def(A0) raises E0 thin -> O0,
    f1: def(A1) raises E1 thin -> O1,
    f2: def(A2) raises E2 thin -> O2,
    f3: def(A3) raises E3 thin -> O3,
    f4: def(A4) raises E4 thin -> O4,
    f5: def(A5) raises E5 thin -> O5,
    f6: def(A6) raises E6 thin -> O6,
    f7: def(A7) raises E7 thin -> O7,
    f8: def(A8) raises E8 thin -> O8,
    f9: def(A9) raises E9 thin -> O9,
    f10: def(A10) raises E10 thin -> O10,
    f11: def(A11) raises E11 thin -> O11,
    f12: def(A12) raises E12 thin -> O12,
    f13: def(A13) raises E13 thin -> O13,
    f14: def(A14) raises E14 thin -> O14,
    f15: def(A15) raises E15 thin -> O15
) raises _Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15] -> Node[F]:
    """Rewrite `subject` bottom-up with 16 clauses."""
    return _rewrite[_Error16[E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15]](subject, _push1(f0, _push1(f1, _push1(f2, _push1(f3, _push1(f4, _push1(f5, _push1(f6, _push1(f7, _push1(f8, _push1(f9, _push1(f10, _push1(f11, _push1(f12, _push1(f13, _push1(f14, _push1(f15, _Nil())))))))))))))))))


# --- end match overloads ---
