Beispiel #1
0
def extract_tuple_eltypes(tuple_type, n):
    """
    Extract the element types from the (static) tuple type and return them
    in a tuple.
    """
    if typematch(tuple_type, StaticTuple):
        return extract_statictuple_eltypes(tuple_type)
    else:
        assert typematch(tuple_type, GenericTuple), tuple_type
        base_type = tuple_type.parameters[0]
        return (base_type, ) * n
Beispiel #2
0
def extract_tuple_eltypes(tuple_type, n):
    """
    Extract the element types from the (static) tuple type and return them
    in a tuple.
    """
    if typematch(tuple_type, StaticTuple):
        return extract_statictuple_eltypes(tuple_type)
    else:
        assert typematch(tuple_type, GenericTuple), tuple_type
        base_type = tuple_type.parameters[0]
        return (base_type,) * n
Beispiel #3
0
def extract_statictuple_eltypes(tuple_type):
    if typematch(tuple_type, EmptyTuple):
        return ()

    hd, tl = tuple_type.parameters
    return (hd, ) + extract_statictuple_eltypes(tl)
Beispiel #4
0
def extract_statictuple_eltypes(tuple_type):
    if typematch(tuple_type, EmptyTuple):
        return ()

    hd, tl = tuple_type.parameters
    return (hd,) + extract_statictuple_eltypes(tl)