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 Parser.orElse() and Parser.orElseEither() #22

Closed
wants to merge 2 commits into from

Conversation

routis
Copy link

@routis routis commented Jan 5, 2024

This PR adds two new ways of combining two parsers.

Parser.orElse(other)

This function combines two parsers by trying the first one and if it fails trying the other. This function allows the combination of individual parsers for each member of a sealed hierarchy, thus producing a parser for a sum type.

Parser.orElseEither(other)

This is combines two parsers like Parser.orElse() but contrary to the orElse() case the two parser can produce unrelated outputs. Effectively, allows the combination of an two unrelated parsers (outcome wise) with an OR relationship.

@routis
Copy link
Author

routis commented Jan 5, 2024

I am closing this. Mixed github accounts.

@routis routis closed this Jan 5, 2024
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