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 parseWithLength #56

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

raehik
Copy link
Collaborator

@raehik raehik commented Mar 16, 2024

Returns parse result along with number of bytes consumed. Maybe useful for low level binary parsing.

  • Add Stateful version
  • Figure out a better name?
  • Add some basic tests (parse a bytestring of length N (QuickCheck prop), parse a Word32)

Returns parse result along with number of bytes consumed.
Maybe useful for low level binary parsing.
@raehik
Copy link
Collaborator Author

raehik commented Mar 16, 2024

I found myself wanting this in a library where I define arbitrary null-padded data. I parse a value of the type, then parse(/skip) nulls until a given size is reached. For that, I need to check how many bytes the parser consumed. (Previously I was doing something silly, now I'm taking a second look I realize I should be using such a combinator.)

@raehik raehik marked this pull request as draft March 16, 2024 20:56
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

Successfully merging this pull request may close these issues.

2 participants