
29 Aug
2006
29 Aug
'06
9:05 a.m.
Parsec provides "count n p" to run the parser p exactly n times. I'm looking for a combinator "countBetween m n p" which will run the parser between m and n times. It does not exist in Parsec. Much to my surprise, it seems quite difficult to write it myself and, until now, I failed (the best result I had was with the "option" combinator, which unfortunately requires a dummy value, returned when the parser fails). Does anyone has a solution? Preferrably one I can understand, which means not yet with liftM :-)