Using Set: Hypergraph type

Marcin 'Qrczak' Kowalczyk
4 Sep 2001 20:19:26 GMT

Tue, 4 Sep 2001 21:12:41 +0300, Eray Ozkural <> pisze:

> Thanks for the suggestion, but isn't this a bit inefficient? Ordinarily one 
> would like to compare two elements of a set by reference, not by content.

There is no such thing in Haskell. mkSet [mkSet [1, 2]] is
indistinguishable from mkSet [mkSet [1, 2]] even if {1,2} sets
were created independently.

Whether representations of particular mkSet [1, 2] objects are shared
is an implementation detail.

Well, there are compiler-dependent unsafe functions which could detect
sharing, but they are not normally used. Functional programming is
about values, not about objects with identities.

You could implement a "tagged object" type, like
    data Tagged a = Tagged Integer a
give objects unique numbers as they are created, and make Eq and Ord
instances which compare these numbers only, ignoring the real value.

 __("<  Marcin Kowalczyk *
  ^^                      SYGNATURA ZASTĘPCZA