[Haskell-cafe] Sharing on equality
Johan Brinch
brinchj at gmail.com
Tue Dec 13 16:52:47 CET 2011
Hey all,
Can GHC eliminate one of two equal ByteStrings, when they are compared
and turns out to be equal?
Say i have a map, ByteString -> Int.
I now do a lookup on a ByteString and if it exists, I insert this
ByteString into a list.
Is it possible to avoid using more memory, than used by the keys in
the map + the list structure?
I.e. is it possible to eliminate the redundant ByteStrings somehow?
I guess, this could be done by having lookup return the key as well,
and then insert this key into the list, however, that's a bit ugly and
somewhat anti-intuitive.
Here's an example program, to illustrate the idea:
https://gist.github.com/1472418
--
Johan Brinch
More information about the Haskell-Cafe
mailing list