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

Tim Newsham newsham at lava.net
Tue Aug 12 20:28:49 EDT 2008

> so that fromAscList's the result of parsing the map as a list, via,
>    instance Binary a => Binary [a] where
>        put l  = put (length l) >> mapM_ put l
>        get    = do n <- get :: Get Int
>                    replicateM n get
> so that's a length-prefixed list, strictly. Which is possibly where the
> stack's being consumed. Does just bumping the stack size a bit help?

ugh.. length prefix..
I could bump the stack size to fix my immediate situation, but my goal
is to have a server with a huge in-memory data set, and my test data
so far is quite small.

> Alternatively, you could consider serialising the Map in some other
> format (i.e. newtype the list, and serialise that say, in a lazy/chunked
> encoding).

hackery :(
but that sounds like the obvious fix.

>>   Log: savedState.bin: openFile: resource busy (file is locked)
>> this does not occur if the program wasnt loaded.  My best guess here
>> is that B.readFile isnt completing and closing the file for some
>> reason.  Is there a good way to force this?
> Lazy IO. So force the result to be evaluated, and then close the handle,
> or use strict bytestring reading.

There is no visible handle.  It's all hidden in readFile.
I will try forcing the data.

> -- Don

Tim Newsham

More information about the Haskell-Cafe mailing list