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

Rewrite rules for parser primitives #556

Open
lrworth opened this issue Mar 8, 2024 · 1 comment
Open

Rewrite rules for parser primitives #556

lrworth opened this issue Mar 8, 2024 · 1 comment

Comments

@lrworth
Copy link

lrworth commented Mar 8, 2024

I've just replaced

M.many (M.anySingleBut '\n')

with

M.takeWhileP Nothing (/= '\n')

and my program used an order of magnitude less memory and time. It seems the latter should always be preferred.

Would it be good for a REWRITE rule to make this substitution (and other similar ones)? I'd be happy to submit a PR.

@lrworth
Copy link
Author

lrworth commented Mar 8, 2024

The substitution I made is not always possible because of the types. The rule could apply chunkToTokens to retain the list result, but that may undo the performance gain.

I'll leave this open in case someone has a bright idea.

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

1 participant