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 optOccurence #174

Open
Kreijstal opened this issue Nov 1, 2022 · 0 comments
Open

add optOccurence #174

Kreijstal opened this issue Nov 1, 2022 · 0 comments

Comments

@Kreijstal
Copy link

Kreijstal commented Nov 1, 2022

I was looking through the source code, and apparently there is no way to add a parser dynamically, since the function repeatable is not available :(

it'd be nice if you could add something like

return repeatable(this, l => l < occurrence, l => l === occurrence);

optoccurrence(occurrence) {
        return repeatable(this, l => l < occurrence, () => true);
    }

or even

occurrencerange(start,end) {
      return repeatable(this, l => l < end,  l => l >= start);
}

or both?

I would love to do a pull request, but I have no idea about haskell, and I can't understand what something like "// Parser 'a 'c => unit -> Parser (List 'a) 'c" means, so out of fear of just being wrong, I will just ask politely here 😁.

Yes, I know you could use something like .opt().occurrence(x) however, it seems wasteful, when x is big

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