-
Notifications
You must be signed in to change notification settings - Fork 56
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
Feature request: bytesRead, bytesWritten #8
Comments
I'm glad that you're finding it a useful library :) The easiest way to implement this would be some additional bookkeeping in the state of the Get monad, though I'm not sure what the performance implications of that would be. If you'd like to experiment, I'd be happy to accept a patch. I like the idea of bytesWritten, and could see that being invaluable when rendering out data. We've been contemplating a rewrite of the Put monad, so this could be a good opportunity to add that in! |
Thank you for the quick response. I may submit a patch. I looked at the Get code earlier; but I was not sure if it would be better to add an argument to the Get type or to add another field to the Incomplete constructor of the More type. In the meantime I have my own code set up using StateT to track a byte offset counter, which I am incrementing by hand. It works fine - but requires careful testing to make sure that my bookkeeping is correct. Which is some motivation for me to work on a patch. |
I think that adding another field to the |
(I'm closing this as it looks like you'll submit a pull request when this feature is ready :) |
@hallettj two years late, but have you come up with anything for this? I would like Alternatively if @elliottt has any more advice on how to go about this, that would be useful ;) - not sure what all (if anything) has changed since the comments above, or if they still apply. |
Not much has changed since my previous comments, and I think the recommendations still make sense. If you come up with something that works well, I'm happy to look it over :) |
It would be helpful for me to have a bytesRead function, like the one in binary, that produces a count of the number of bytes that have been consumed from input. This would be useful for deserializing formats that refer to previous byte offsets in the input, such as DNS messages that contain compressed domain names.
A complementary bytesWritten function would also be helpful for writing such formats. I have not been able to find a bytesWritten feature in any serialization library that I have looked at.
Also, I want to say thank you for publishing such a useful library!
The text was updated successfully, but these errors were encountered: