3 Dec 13:43
Using Ord for keys of maps and sets
From: Yitzchak Gale <gale <at> sefer.org>
Subject: Using Ord for keys of maps and sets
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2007-12-03 12:47:00 GMT
Subject: Using Ord for keys of maps and sets
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2007-12-03 12:47:00 GMT
Henning Thielemann wrote: > I already told about by scepticism about using Ord for keys of maps and > sets: > http://www.haskell.org/pipermail/libraries/2007-April/007411.html Yes. There are a number of different scenarios for the ordering that you want to use for indexing: 1. A default ordering for the type that is a natural ordering. 2. A default ordering for indexing that is not a natural ordering. 3. An application-specific ordering. 4. More than one ordering for the same type, determined statically. 5. More than one ordering for the same type, determined dynamically, i.e., parameterized orderings. My experience has been that all of these cases do come up quite often in real life. One solution would be to have Data.Map.Indexable, etc. as alternatives using Indexable instead of Ord, so that we could avoid newtype wrapping in case 2. We could allow for case 3 by not providing any default instances for Indexable. Or we could provide default(Continue reading)
RSS Feed