[Haskell-cafe] two problems with Data.Binary and Data.ByteString

Tim Newsham newsham at lava.net
Tue Aug 12 21:01:37 EDT 2008

> Doesn't Data.Map.size run in O(1) time? Maybe something like using
> different encodings for big maps in the default implementation would
> help?

ugh, of course.  Ok, so I fixed it to:

loadState db = do
     d <- decode <$> B.readFile stateFile
     let force = sum $ map (sum . map fromEnum . M.keys) $ M.elems d
     print force
     force `seq` atomically $ writeTVar db d

(my keys are dates, which are Enum).  This should look at
every key in every inner map.  Shouldn't that be sufficient to
force the entire data set (or do I have to touch the fields in the
data elements too?).  I still get the same error condition.

> Felipe.

Tim Newsham

More information about the Haskell-Cafe mailing list