Repository navigation
Description
Summary
Found while verifying #1503-#1506 (the tree-sitter ground-truth fixes for args counting): after fixing the audit tool's ground truth, haskell's OWN args engine regex (in gitgalaxy/standards/language_standards.py, used by the real GitGalaxy scan, not just the accuracy-measurement tool) still had two real, distinct bugs causing args_exact_match to under-measure (31/81 -> 43/81 after the ground-truth fix alone).
Root cause 1: signature-less equations measure 0
Typeclass instance methods and where/let-local helpers routinely have no restated :: type signature at all (the same shape #1435/#1442 taught func_start to recognize). The args regex only knew how to count a :: signature's arrows, a lambda's params, or an @Type application -- none of which exist for e.g.:
isPandocCiteproc (JSONFilter f) = takeBaseName f == "pandoc-citeproc"so args_count fell back to 0 regardless of true arity (real=1 per tree-sitter, got=0).
Root cause 2 (bigger impact): qualified/dotted type names truncate the :: capture
The :: signature's capture-group character classes never included .. Real-world Haskell overwhelmingly writes qualified/imported type names with a dot (T.Text, IO.Newline, M.Map) -- confirmed:
inquotes :: T.Text -> T.Text
inquotes txt = T.cons '\"' (T.snoc txt '\"')captured only T (one letter) as the signature text -- zero arrows counted from a real 1-arrow signature, i.e. every arrow after the first dotted type silently vanished. This affected the majority of real corpus mismatches, since qualified imports are extremely common style (pandoc's corpus especially).
Fix (already implemented, see PR)
- Added a new capture-group alternative to
argsfor the signature-less equation's own LHS pattern list (name pat1 pat2 = ...), anchored to the absolute start of the block so it only ever reads the function's own first line. Routed through a new_count_haskell_pattern_listindetector.py(depth-and-string-aware, since a naive whitespace split wrongly splits a single parenthesized compound pattern like(MetaList xs)into two tokens). Explicitly excludes Haskell reserved keywords (let,where,data, etc.) from being mistaken for a function name -- confirmedlet x = 1(a value binding, not an equation) must never match. - Added
.to the::signature capture's character classes (both first-char and continuation) to stop the truncation at qualified type names.
args_exact_match: 31/81 (pre-#1503) -> 43/81 (ground-truth fix only) -> 70/81 (86.4%) with both engine fixes.
Remaining known gaps (NOT fixed, out of scope for this issue)
- Arrow-count vs. actual-binding-arity divergence for point-free/partially-applied equations. A function like
writerFn :: IO.Newline -> FilePath -> Text -> IO ()with equationswriterFn eol "-" = UTF8.putStrWith eolbinds only 2 patterns per equation even though the signature has 3 arrows, because the body itself evaluates to a partially-applied function value (typeText -> IO ()). Tree-sitter's ground truth (equation pattern count) is arguably the more semantically correct measure here; GitGalaxy's arrow-counting can't distinguish "this arrow is a real curried parameter" from "this arrow is part of the point-free return type" without actual type inference. No regex fix available. - Haddock inline comments interrupting a multi-line signature capture, e.g.:
The comment-skipping alternation only applies BEFORE the capture group opens, not between tokens inside it, so a trailing
tabFilter :: Int -- ^ Tab stop -> T.Text -- ^ Input -> T.Text
-- ^ ...haddock comment on an early line of a multi-line signature likely truncates it the same way the dot-bug did. Not chased in this issue -- would need the skippable-comment alternation folded into the capture group's own repetition, which needs its own careful ReDoS-safety pass.
This only affects extraction-pillar args-counting accuracy (epic #813) and the args_exact_match measurement (epic #1227/#1261), not risk scoring.
Activity