
5 Nov
2008
5 Nov
'08
10:20 a.m.
On Wed, Aug 13, 2008 at 1:18 AM, Don Stewart
instance Binary a => Binary [a] where put l = put (length l) >> mapM_ put l get = do n <- get :: Get Int replicateM n get
Of course I changed this as well. Now it is: instance (Ord k, Binary k, Binary e) => Binary (Map.Map k e) where put m = put (Map.size m) >> mapM_ put (Map.toAscList m) get = liftM Map.fromDistinctAscList get You don't have to convert the map to list just to compute its size. The Map.size is a O(1) function.