def zip_cmp(self, other, fn): """ Compare the data constructor and all of the fields of two ADTs. """ if self.__ADT_slot__ == other.__ADT_slot__: if len(nt_to_tuple(self)) == 0: return fn((), ()) return fn(nt_to_tuple(self), nt_to_tuple(other)) return fn(self.__ADT_slot__, other.__ADT_slot__)
def show(self): if len(self.__class__._fields) == 0: return self.__class__.__name__ nt_tup = nt_to_tuple(self) if len(nt_tup) == 1: tuple_str = "(%s)" % Show[nt_tup[0]].show(nt_tup[0]) else: tuple_str = Show[nt_tup].show(nt_tup) return "{0}{1}".format(self.__class__.__name__, tuple_str)
def __eq__(self, other): return self.__class__ == other.__class__ and nt_to_tuple(self) == nt_to_tuple(other)
def __ne__(self, other): return self.__class__ != other.__class__ or nt_to_tuple(self) != nt_to_tuple(other)
def __ne__(self, other): return self.__class__ != other.__class__ or \ nt_to_tuple(self) != nt_to_tuple(other)
def __eq__(self, other): return self.__class__ == other.__class__ and \ nt_to_tuple(self) == nt_to_tuple(other)