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

ByteString parser improvements #84

Open
LinuxUser404 opened this issue Dec 14, 2017 · 4 comments
Open

ByteString parser improvements #84

LinuxUser404 opened this issue Dec 14, 2017 · 4 comments

Comments

@LinuxUser404
Copy link

ByteString parser seems to be not usable because there are 0 parser functions operating on ByteString. When we operate on strings of chars we have useful parsers like "oneOf", "digit", "spaces". It would be nice to have something like "zeros"(for bytes filled with zeros), "bigEndiandInt32", "byte" to consume bytes from the ByteString stream and write the results into appropriate data types. Something similar was done in "HCodecs"(and many other places where people try to handle some specific file formats). Parsec would be a more natural place to look for such convenient general functions.

@int-index
Copy link
Contributor

There is a well-maintained for of Parsec — https://hackage.haskell.org/package/megaparsec — that has support for ByteString and even custom input stream types.

@LinuxUser404
Copy link
Author

Thanks for your reply. So basically if I need some extra functionality I should use a different package... Is there any reason why those are different packages while they are meant to do the same thing?

@int-index
Copy link
Contributor

No technical reason, just a communication issue (I guess merging these changes upstream was difficult). I think if @mrkkrp got commit bits, he would not be opposed to having all these changes directly in parsec.

@hvr
Copy link
Member

hvr commented Dec 30, 2017

It's not really a communication issue; it's more like that parsec is more conservative at this point given it has to carry a lot of weight in the ecosystem, and any misstep may have significant cost; while megaparsec is free to explore the design space and can move faster.

I intend to improve parsec by stealing ideas from megaparsec/trifecta/parsers, while avoiding bigger changes that would completely break API compatibility. However, we do have a diversity of parsers, and there is not going to be "the one" parser to rule them all. Parsec just happens to be one of the oldest ones and tries to keep its dependency footprint light enough to be consumable by lib:Cabal. Personally, I often use and recommend megaparsec or attoparsec for projects for which Parsec is not a good fit; or you can just go for https://hackage.haskell.org/package/parsers which abstracts over parser libraries.

Long story short: PRs which add (popular) functionality to Parsec are quite welcome. :-)

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

3 participants