Skip to content

haskell func_start: typeclass instance methods and where-clause locals without an explicit '::' signature are structurally invisible #1442

Closed

Description

@squid-protocol

Summary

Follow-up to #1435 (PR pending). After fixing the < 2 line-count floor that dropped abstract
typeclass method signatures, haskell func_start recall only moved from 52/94 (55.3%) to 53/94
(56.4%) on the language-crucible corpus -- a much smaller improvement than #1435's own framing
anticipated ("explains most of the recall gap"). Independent investigation found the real,
larger cause: func_start's regex (gitgalaxy/standards/language_standards.py, "haskell"
entry) structurally REQUIRES an explicit :: type-signature marker to match a function at all --
but two extremely common real-world Haskell patterns never have one:

Confirmed examples

1. Typeclass instance implementations that don't restate their own signature (idiomatic --
the signature already exists on the typeclass declaration, restating it on every instance is
unnecessary and uncommon in real code):

instance ToJSON HTMLMathMethod where
  toJSON PlainMath = String "plain"
  toJSON (WebTeX "") = String "webtex"
  toJSON (WebTeX url) = object ["method" .= String "webtex", ...]
  ...

(language-crucible/data/haskell/pandoc/Options.hs, ~line 144). None of these toJSON equations
have their own :: line -- func_start never matches any of them.

2. where-clause local helper functions, which Haskell allows (and real code commonly
omits) without a type signature:

applyFilters scrngin fenv filters args d = do
  ...
  foldM applyFilter d expandedFilters
  where
    applyFilter doc (JSONFilter f) = ...
    applyFilter doc (LuaFilter f)  = ...

(language-crucible/data/haskell/pandoc/Filter.hs, ~line 76-91). applyFilter has no signature
anywhere in the file -- invisible to func_start regardless of the < 2 floor.

Why this is harder than #1435

Both patterns are DEFINED by pattern-matched EQUATIONS (name pattern... = expr), not by a
type-signature line -- detecting them requires recognizing Haskell's equation syntax directly
(name at column matching the enclosing scope's indent, followed by argument patterns and =),
not just extending the current signature-anchored regex. This is a materially different
detection strategy, not a bounded regex tweak -- needs its own design pass before attempting a
fix, most likely a new func_start alternative (or a wholly separate _slice_by_indentation
gating path) that doesn't require :: at all, carefully scoped to avoid false-positiving on
every where-bound pattern-matched VALUE (non-function) binding, which is a much larger surface
of naturally-similar-looking Haskell syntax.

Scope note

This only affects func_start/args/class_start name-extraction accuracy (the extraction-
gauntlet pillar from epic #813), not GitGalaxy's risk-scoring rules, which are unaffected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginepriority: mediumtestingthreat: false-negative

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions