streamly icon indicating copy to clipboard operation
streamly copied to clipboard

Add Parslet type for non-failing parsers

Open harendra-kumar opened this issue 1 year ago • 1 comments

The Scanl type now represents the use cases where we need to extract the intermediate values of the accumulator. The Fold type would not have the extract operation anymore thus making the accumulator opaque until the fold finishes. The Fold type is more of a simpler parser now. Can we push all the non-failing parser use-cases from Parser to the Fold type? Pushing backtracking into Folds would make tee/distribute less useful (more complicated) but anyway that is the domain of scans.

But backtracking can potentially make the splitWith applicative less efficient, so maybe keep the Fold type for non-backtracking cases and use a new Parslet type for non-failing backtracking parsers.

The consumer types will then have this hierarchy (more general to more specialized): Scanl => Fold => Parslet => Parser.

harendra-kumar avatar Jul 30 '24 06:07 harendra-kumar

See #1776 and #2102

Data.Parser.Simple would use more efficient splitting applicative using noErrorUnsafeSplitWith etc. It will support all other instances except alternative.

harendra-kumar avatar Jun 21 '25 12:06 harendra-kumar