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
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
def extract_statictuple_eltypes(tuple_type): if typematch(tuple_type, EmptyTuple): return () hd, tl = tuple_type.parameters return (hd, ) + extract_statictuple_eltypes(tl)
def extract_statictuple_eltypes(tuple_type): if typematch(tuple_type, EmptyTuple): return () hd, tl = tuple_type.parameters return (hd,) + extract_statictuple_eltypes(tl)