Exemple #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
Exemple #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
Exemple #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)
Exemple #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)