separated_foldl
and separated_foldr
#434
Replies: 2 comments 1 reply
-
To clarify, you are not wanting
Instead you are looking for btw besides forking the combinators, a workaround for this would be |
Beta Was this translation helpful? Give feedback.
-
Yes, that's correct. I assumed that |
Beta Was this translation helpful? Give feedback.
-
Reading through documentation for
winnow
combinators, I can't help but wonder whyseparated_foldl1
andseparated_foldr1
are a thing, butseparated_foldl
andseparated_foldr
are not.I am writing a simple parser for basic expression language. At a certain point, I wanted to add good error reporting to see what winnow can do in that regard. To improve error messages, I wanted to add occasional cuts (this is needed to prevent backtracking from jumping to less relevant alternatives). Specifically, I wanted to add a cut for RHS of binary operator expressions.
I am using
separated_foldl1
for parsing, but it does not leave me the opportunity to change parser used for the first element.This is what I think it should look like
So, to sum up, I think having
separated_foldl
andseparated_foldr
combinators could be useful. They can be reimplemented outside ofwinnow
, but that's not a great solution IMO -separated_foldl1
is quite big andseparated_foldl
wouldn't be any smaller. On the other hand, I believe it wouldn't take much code at all to add those towinnow
, as most of the code from existing versions could be reused (andseparated_foldl1
/separated_foldr1
could then just call into a new version).Beta Was this translation helpful? Give feedback.
All reactions