Repository navigation
fix(haskell): args regex misses signature-less equations and truncates qualified/dotted type signatures - #1513
Merged
Conversation
…s qualified/dotted type signatures Two distinct bugs in the haskell "args" engine regex, found while verifying #1503-#1506's ground-truth fixes: 1. Typeclass instance methods and where/let-local helpers routinely have no restated `::` signature (same shape #1435/#1442 taught func_start to recognize) -- args_count fell back to 0 regardless of true arity. Added a new capture-group alternative for the equation's own LHS pattern list (`name pat1 pat2 = ...`), routed through a new detector.py _count_haskell_pattern_list (depth-aware, so a parenthesized compound pattern like `(MetaList xs)` counts as one argument, not two via naive whitespace-split). Explicitly excludes Haskell reserved keywords so `let x = 1` is never mistaken for a function equation. 2. The `::` signature capture's character classes never included "." -- real-world qualified/imported type names (`T.Text`, `IO.Newline`) truncated the whole captured signature at the first dot, silently dropping every arrow after it (confirmed: `inquotes :: T.Text -> T.Text` captured only "T", zero arrows from a real 1-arrow signature). This affected the majority of real corpus mismatches. args_exact_match: 31/81 -> 43/81 (ground-truth fix alone, #1507) -> 70/81 (86.4%) with both fixes here. Remaining known gap (documented, not fixed): arrow-count vs. actual-binding-arity diverges for point-free/partially-applied equations (e.g. `writerFn`'s signature has 3 arrows but its equations only bind 2 patterns, since the body itself returns a function value) -- not fixable without real type inference. tcl's own separate default-value-parameter overcount bug filed as #1512, not fixed here. Fixes #1511. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Found while verifying #1503-#1506's ground-truth args-counting fixes (PR #1507, merged): haskell's own
argsengine regex (not the accuracy-measurement tool) had two distinct real bugs.Signature-less equations measured 0. Typeclass instance methods and
where/let-local helpers routinely have no restated::signature (same shape haskell func_start: hardcoded '< 2 lines' floor in _slice_by_indentation drops every abstract typeclass method signature #1435/haskell func_start: typeclass instance methods and where-clause locals without an explicit '::' signature are structurally invisible #1442 taughtfunc_startto recognize), e.g.isPandocCiteproc (JSONFilter f) = .... Added a new capture-group alternative for the equation's own LHS pattern list, anchored to the block's absolute start. Routed through a new_count_haskell_pattern_listindetector.py-- depth-and-string-aware, since a naive whitespace split would wrongly split a single parenthesized compound pattern like(MetaList xs)into two tokens. Explicitly excludes Haskell reserved keywords (let,where,data, ...) from being mistaken for a function name --let x = 1must never match.Qualified/dotted type names truncated the
::capture (bigger real-world impact). The signature capture's character classes never included.-- real-world Haskell overwhelmingly writes qualified type names with a dot (T.Text,IO.Newline). Confirmed:inquotes :: T.Text -> T.Textcaptured onlyT(one letter, zero arrows) from a real 1-arrow signature -- every arrow after the first dotted type silently vanished. Added.to both character classes.args_exact_match: 31/81 (pre-#1503) → 43/81 (ground-truth fix alone) → 70/81 (86.4%) with both fixes here.Remaining known gap (documented, not fixed)
Arrow-count vs. actual-binding-arity diverges for point-free/partially-applied equations, e.g.
writerFn :: IO.Newline -> FilePath -> Text -> IO ()has 3 arrows, but its equations (writerFn eol "-" = UTF8.putStrWith eol) only bind 2 patterns, since the body itself evaluates to a partially-applied function value. Tree-sitter's ground truth (equation pattern count) is arguably more semantically correct here; fixing GitGalaxy's side would need real type inference, not a regex change. Left as-is.tcl has its own separate, unrelated args-overcounting bug (default-value braced parameters like
proc foo {{db db}}) found during the same verification pass -- filed as #1512, not fixed here (out of scope for a haskell-only PR).Verification
Fixes #1511.
🤖 Generated with Claude Code