kr.angelov: > On Wed, Aug 13, 2008 at 1:18 AM, Don Stewart <[EMAIL PROTECTED]> wrote: > > 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.
If you have a more efficient instance Binary Map, please send a patch. Collaborate! -- Don _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe