v0.7.0.0 — `<?>` and `commit` error-reporting combinators
New features
Two additive combinators for controlling error reporting at choice boundaries. Existing parsers compile unchanged.
(<?>) :: Parser a -> String -> Parser a— replaces a parser's failure with a singleLabeled lbl poscarrying the label and the position where the labeled parser started. Use to surface "expected an X here" diagnostics instead of whatever character-level mismatch the deepest internal parser happened to produce.commit :: Parser a -> Parser a— marks a parse path as committed: if it fails, surrounding<|>propagates the failure rather than backtracking to the next alternative. Built on a new internalCommitted [Error]marker that theAlternativeinstance recognises and strips.parseunwraps any top-levelCommitted, so external callers never observe the marker.Errorgains two constructors:Labeled !String !PosandCommitted ![Error]. Pattern-matching code that explicitly listed everyErrorconstructor will get a non-exhaustive-match warning and need to add the new cases.
The <|> instance gains one extra pattern match on its failure path — a head-of-list check for the Committed marker — which is constant-time and only runs when an alternative has already failed. The success path is byte-identical.
Performance
INLINABLEpragmas on numeric parsers.dec,hex,oct,bin,digs, andsignedall becameNum a => …in 0.5.x but lacked unfoldings, so cross-module callers paid dictionary-passing overhead on every digit. Adding{-# INLINABLE #-}recovers ~27% on the Log workload (188 μs → 137 μs), putting MiniParser back in the same league as Megaparsec on that benchmark. CSV and JSON also see modest improvements.
Bench fixes
perf-comparebuild fixed. The benchmark project's.cabalwas missing ascientificbuild-dep added toMiniParser.Basein 0.5.x, andBenchLog.hs/BenchJSON.hsstill referencedMP.nat(renamed toMP.decin 0.5.x). Both fixed;cabal bench bench-csv bench-log bench-jsonnow runs cleanly.
Documentation
- New Error Labeling and Cut section in
README.mdwith worked examples for both combinators, a "scope ofcommit" note, and an explicit rule-of-thumb thatcommitgoes on the outside,<?>on the inside — putting<?>outsidecommitsilently discards theCommittedmarker. - Performance Benchmarks section refreshed with new numbers and a softened analysis (MiniParser is "competitive with Megaparsec" rather than "consistently faster" — Log is now within ~3% of Megaparsec instead of ahead).
Tests
- 13 adversarial cases added to
test/Test.hscovering nested-label override,<?>overempty/pFailStr/eof, triple-nestedcommit, scope-after-success,commit empty, nested-<|>commit propagation, and two documented footguns (the<?>-outside-commitorder trap, andcommitinsidemanybeing stripped at the inner<|>). Suite count is now 338 (was 313 in 0.6.0.0).