Unordered map

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Fri Aug 1 06:18:30 EDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aaron Denney wrote:

> If you're going to make users write an
> equality function, making them write an ordering adds little effort, and
> a reasonable amount of gain.  Usually.

Then why is there a distinction between e.g.
Map and SortedMap (and Set and SortedSet) in the Java libraries?

Yes yes I know Haskell is not Java etc. but they must have given
this some thought. (Of course them making everything an instance of
Eq and Hash is a design error but that's not the point here.)

The practical problem with Haskell's type class mechanism
is that all instances (of Eq, Ord) are global,
so if one library (Data.Map) requires them,
then you're stuck with these instances for all of your program.
Of course the same thing holds for Java's "implements Comparable<>"
but they have local types. Well, Haskell has newtype,
but that's (module-)global.

Best regards, J.W.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iEYEARECAAYFAkiS4vYACgkQDqiTJ5Q4dm+GAACfZ6sedaApVtDaErb/1A0IL650
e80AoKnIQQfvdOhBUgtct7WqkVxtg4ps
=AV1r
-----END PGP SIGNATURE-----


More information about the Libraries mailing list