def pretty_type(d): if cc.is_type_any(d): return "any" if cc.is_type_atom(d): return "atom" if cc.is_type_atomlit(d): return pretty(cc.get_literal_from_atomlit(d)) if cc.is_type_float(d): return "float" if cc.is_type_integer(d): return "integer" if cc.is_type_integerlit(d): return pretty(cc.get_literal_from_integerlit(d)) if cc.is_type_list(d): return "[%s]" % pretty_type(cc.get_inner_type_from_list(d)) if cc.is_type_nil(d): return "[]" if cc.is_type_tuple(d): return "tuple" if cc.is_type_tupledet(d): return "{%s}" % ", ".join( map(pretty_type, cc.get_inner_types_from_tupledet(d))) if cc.is_type_union(d): return "|".join(map(pretty_type, cc.get_inner_types_from_union(d))) if cc.is_type_range(d): bs = cc.get_range_bounds_from_range(d) return "%s..%s" % (cc.get_lower_bound(bs), cc.get_upper_bound(bs)) if cc.is_type_generic_fun(d): return "fun()" if cc.is_type_complete_fun(d): args, ret = d["a"][:-1], d["a"][-1] args = cc.get_parameters_from_complete_fun(d) ret = cc.get_rettype_from_fun(d) return "fun(({}) -> {})".format(", ".join(map(pretty_type, args)), pretty_type(ret))
def pretty_type(d): if cc.is_type_any(d): return "any" if cc.is_type_atom(d): return "atom" if cc.is_type_atomlit(d): return pretty(cc.get_literal_from_atomlit(d)) if cc.is_type_float(d): return "float" if cc.is_type_integer(d): return "integer" if cc.is_type_integerlit(d): return pretty(cc.get_literal_from_integerlit(d)) if cc.is_type_list(d): return "[%s]" % pretty_type(cc.get_inner_type_from_list(d)) if cc.is_type_nil(d): return "[]" if cc.is_type_tuple(d): return "tuple" if cc.is_type_tupledet(d): return "{%s}" % ", ".join(map(pretty_type, cc.get_inner_types_from_tupledet(d))) if cc.is_type_union(d): return "|".join(map(pretty_type, cc.get_inner_types_from_union(d))) if cc.is_type_range(d): bs = cc.get_range_bounds_from_range(d) return "%s..%s" % (cc.get_lower_bound(bs), cc.get_upper_bound(bs)) if cc.is_type_generic_fun(d): return "fun()" if cc.is_type_complete_fun(d): args, ret = d["a"][:-1], d["a"][-1] args = cc.get_parameters_from_complete_fun(d) ret = cc.get_rettype_from_fun(d) return "fun(({}) -> {})".format(", ".join(map(pretty_type, args)), pretty_type(ret))
def isNil(cls, typ): return cc.is_type_nil(typ)