-
Notifications
You must be signed in to change notification settings - Fork 32
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
ByteString: More efficient IO read/write #129
Conversation
I think the right thing is to use the same tag for both. The tags only differ because of serialization. But that's better done with some subfield of a foreign pointer. I think it's a straightforward change. I'll do it later today. |
I've pushed a change that gets rid of T_BSTR. I'm on vacation in New Zealand, so responses are a bit slow. :) |
Unfortunately, I think this just moved the problem. It's still not possible to simply convert between a foreign pointer and a bytestring using |
It can probably be fixed by just removing the sanity checks. The fptype doesn't matter, except for serialization. |
Ok, I'll try that. |
7e3b32b
to
8503cfb
Compare
I added two new primitives, |
Just setting the type to bytestring isn't sound unless the pointer was originally a bytestring. A bytestring has a size that is used in serialization. The serialization code needs a sanity check for NOSIZE. I'll look at it some more tonight. |
|
Having |
Implement
hPut
,hGet
,hGetContents
using block IO and changereadFile
,writeFile
,appendFile
to use them.Implements #112.
The code currently compiles, but it doesn't work, since
primBS2FPtr
,primFPtr2BS
&primFPtrLen2BS
aren't implemented correctly (_primitive "I"
doesn't work, since whileByteString
andForeignPtr
have essentially the same representation, they have different tags). I'm not sure what the best way forward is here. Ideally there would be conversion between bytestrings and forptrs without having to copy the payload, but I'm not sure that's possible. Another idea is to addmallocByteString
andwithByteString
(so that we don't have to go throughForeignPtr
), but that would mean code duplication.