Generic tries (long)

Isaac Dupree isaacdupree at
Sat Jun 21 09:51:00 EDT 2008

Jamie Brandon wrote:
>> Why not just use
>>  class (Ord k, GMap map k) => OrderedGMap map k where
> Most of the maps I will be implementing will respect the ordering that
> would be derived by GHC, regardless of the actual Ord instance. There
> is no way, in general, to derive a trie that respects an existing Ord
> instance but I still want to expose the bytewise ordering in the trie.

Well, you could use a newtype for the key, when necessary.  But does 
that suffer from
1. the risk of accidentally not using a newtype?
2. is it an inconvenience to the users of the map? I can't tell...

Is it a bad idea to require an Ord context even if you don't use it? It 
could supply a default method... but would surely confuse people like 
(1) above.


More information about the Libraries mailing list