Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add serialization from/to ByteStrings? #3

Open
TerrorJack opened this issue Oct 3, 2017 · 3 comments
Open

Add serialization from/to ByteStrings? #3

TerrorJack opened this issue Oct 3, 2017 · 3 comments

Comments

@TerrorJack
Copy link

To use compact to serialize from/to ByteStrings, currently we have to go through temporary files, which makes it a bit inconvenient. Surely in-memory serialization has a lot use cases, so it would be nice if it is supported :)

@bgamari
Copy link
Collaborator

bgamari commented Oct 3, 2017

Note that the interface for this would likely need to be CPS'd due to the interface of withSerializedCompact. The consumer would be expected for force the entire lazy bytestring.

@ezyang
Copy link
Owner

ezyang commented Oct 8, 2017

Is the terminal state of the compact normal form truly a ByteString, or is the ByteString simply being used as a convenient interchange format for some other API of interest?

I'm a bit nervous about adding a lazy ByteString API because, although it in principle should be possible to do, it is very tricky to do correctly. Unlike most ForeignPtrs, the lazy ByteString has to either be CPS'd (as @bgamari suggests) or setup to keep a Haskell data live (not trivial, but should be possible). But I guess we should bite the bullet and do it.

@rightfold
Copy link

In addition to bytestrings it would be useful if the library allows serializing to a region in memory given by a pointer. The primary use case for this I have in mind is shared memory with mmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants