Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get match length in parsec

Tags:

haskell

parsec

Parsec's parse pattern "(some_input)" input returns the parsed data (as I specified in pattern.

How to know how much of input have it consumed (the pattern is not anchored with eof)? I don't want to add length tracking though the all pattern's internals (if discards some parts of input).

like image 276
Vi. Avatar asked Jan 30 '26 13:01

Vi.


1 Answers

  1. It is not easy with Parsec;
  2. If it is needed to skip header you can grab the rest of input using getInput;
  3. May be other parser libraries can do this.

(the answer is based on comments to the question)

like image 156
Vi. Avatar answered Feb 01 '26 06:02

Vi.