
21 Feb
2009
21 Feb
'09
1:10 a.m.
On Fri, Feb 20, 2009 at 6:40 AM, Achim Schneider
wren ng thornton
wrote: (b) allows instances to have a fixed type for keys (like Data.Trie and Data.IntMap have),
Can't we do some type magic to automagically select Data.Trie if the key is a (strict) bytestring?
I believe this is a key feature of Associated Types: you can create "self-optimizing libraries" that select a different container structure depending on the type. For example, class XMapK k where type XMap k :: * -> * insert :: k -> XMap k v -> XMap k v and then instance XMapK Int where type XMap Int = Data.IntMap.IntMap insert = Data.IntMap.insert etc. Alex