
6 Feb
2008
6 Feb
'08
11:07 a.m.
On Wed, 6 Feb 2008, Denis Bueno wrote:
On Feb 6, 2008 10:36 AM, Henning Thielemann
wrote: type SomethingWithKV k a = KV {getKV :: (k, a)} instance Buildable (Map k a) (SomethingWithKV k a) where empty = Map.empty insert s m = uncurry Map.insert (getKV s) m
I have done this before -- it's very convenient, and I think makes the code that uses empty and insert more robust, and easier to read.
But why do you want to have the special type SomethingWithKV, but not MapSomething ?
Do you mean a map that maps SomethingWithKV to whatever, instead of k to v?
I mean a Map that is specialised for storing SomethingWithKV instead of plain pairs. (If I imagine a Map as a list of pairs that is optimized for efficiency.)