On 03/09/10 11:11, Henning Thielemann wrote:

Ivan Lazar Miljenovic schrieb:
On 3 September 2010 04:57, Arie Peterson <ar...@xs4all.nl> wrote:
On Thu, 2 Sep 2010 19:30:17 +0200, Daniel Fischer
<daniel.is.fisc...@web.de> wrote:
Why would one consider using Ord for Map an abuse?
A kludge, for performance reasons, but an abuse?
Because it forces one to declare Ord instances for types which have no
natural ordering. It is useful to *not* have such instances, in order to
catch programming errors.

What precisely do you mean by natural ordering?

E.g. I wanted to have a Set of Gaussian (complex) integers, but I did
not want to define an Ord instance for them, because writing
  a < (b :: Gaussian)
is a bug with high probability.

Isn't this what newtype is good for? Instead of declaring Ord Gaussian to get Set Gaussian and risking the bug you describe, create newtype GaussianInSet = G Gaussian, declare Ord GaussianInSet and use Set GaussianInSet.

Thanks,

Neil.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to