I'm trying to parse a string using megaparsec
.
Part of it is a repetition of strings separated by a separator and I'm using sepBy
for this.
Consider for example
sepBy (char 'a') (char 's')
This parses correctly ""
, "a"
, "asa"
, ...
The problem appears if I need to continue parsing with another parser which starts with my separator, as in
(,) <$> sepBy (char 'a') (char 's') <*> string "something"
If I try to parse the string "asasomething"
with this parser I'd expect to get ("aa", "something")
. Instead I get an error because I don't have an a
after the second s
.
I tried also with sepEndBy
but the result is the same