Skip to content

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.

3 participants