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

Adding 2 new combinators #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Adding 2 new combinators #25

wants to merge 1 commit into from

Conversation

Javran
Copy link

@Javran Javran commented Jan 31, 2015

would like to see these two combinators in parsec :)

  • countUpTo n is the equivalance of {,n} in regular expressions
  • countFromTo m n is the equivalence of {m,n} in regular expressions

`countUpTo n` is the equivalance of "{,n}" in regular expressions
`countFromTo m n` is the equivalence of "{m,n}" in regular expressions
@mrkkrp
Copy link
Contributor

mrkkrp commented Aug 12, 2015

@Javran, I like the idea. I will include this in Megaparsec, see mrkkrp/megaparsec#17. Not sure it will get any response here, but I would advice the following improvements for this PR:

  • define countUpTo in terms of countFromTo: countUpTo n = countFromTo 0 n, not other way around, because countFromTo is obviously more general of the two;
  • you have a typo in description of countUpTo: @countUpto n p@ ...;
  • please rewrite description of countFromTo;
  • better name variables in countFromTo as in description, i.e. m n p, not l r p, this will make the function easier to understand for readers of your code.

@hvr
Copy link
Member

hvr commented Aug 7, 2017

Note to myself, count and count' now live in http://hackage.haskell.org/package/parser-combinators-0.2.0/docs/src/Control-Applicative-Combinators.html#count

@mrkkrp am I right to assume that parser-combinators can be combined with parsec? or is there still some incentive to implement count/count' natively for parsec?

@mrkkrp
Copy link
Contributor

mrkkrp commented Aug 7, 2017

Yep, all combinators from parser-combinators can be used with Attoparsec, Parsec, Megaparsec, and probably Trifecta too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants