[Haskell-cafe] Why does Data.Map exist when...

Tony Morris tmorris at tmorris.net
Mon Jul 16 23:31:16 EDT 2007


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

...it seems to be a special case of Set? Does Data.Map add anything more
useful than Map' below?

import Data.Set as Set

newtype MyPair a b = MP (a, b)
  deriving Show

instance (Eq a) => Eq (MyPair a b) where
  MP (a, _) == MP (a', _) = a == a'

instance (Ord a) => Ord (MyPair a b) where
  MP (a, _) `compare` MP(a', _) = a `compare` a'

type Map' k a = Set (MyPair k a)

- --
Tony Morris
http://tmorris.net/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGnDgEmnpgrYe6r60RAu4FAJ93Fwcx7ZX08+qO4ZlzRVV52TXpNQCeNr7u
ioq0XrWt/Wymfh52W1spiFk=
=FC5h
-----END PGP SIGNATURE-----


More information about the Haskell-Cafe mailing list