Skip to content

tree_sitter_accuracy_audit: haskell NODE_MAPS excludes tree-sitter's bind node, undercounting point-free functions as false positives #1566

Closed

Description

@squid-protocol

Summary

This is a bug in tests/tools/tree_sitter_accuracy_audit.py's ground truth for Haskell, not in GitGalaxy's engine — same class of issue as already-fixed #1505 and #1511. The audit tool's NODE_MAPS is missing tree-sitter-haskell's bind node type, causing point-free function definitions to be systematically undercounted as false positives (alleged "extra" detections by GitGalaxy).

Root Cause

NODE_MAPS["haskell"]["func_node_types"] = {"function"} (line ~387) only includes function nodes. However, tree-sitter-haskell's grammar puts point-free function definitions — i.e. name :: A -> B followed by name = expr with no explicit argument patterns — under a bind node, not a function node, even though the type signature has an arrow and the value is unambiguously a function by any practical definition.

Verified by parsing a minimal snippet directly:

  • Point-free name = expr produces: signature (with function type inside it, i.e. the type-signature node) + a top-level bind node containing variable + match
  • Explicit-pattern name arg = expr produces: a top-level function node

Impact

Because func_node_types only includes "function", every point-free definition in the corpus is invisible to the real_functions ground truth set:

  1. Ground truth itself undercounts real functions
  2. GitGalaxy's correct detection of these (regex already requires an arrow in the type signature before counting as a function, per haskell func_start matches point-free VALUE bindings (no arrow in type) as if they were functions #1312 fix) is scored as a false-positive "extra"

This artificially depresses Haskell's measured func_recall / func_precision in docs/self_scan/tree_sitter_accuracy_history.csv (currently worst of any language at ~42% recall / ~76% precision) — true numbers are meaningfully better once point-free functions are counted correctly.

Verification

On the pinned language-crucible/data/haskell/pandoc corpus, roughly 25 of the ~31 reported "extra" (alleged false-positive) names are point-free definitions with arrow-containing type signatures.

Confirmed examples (all real point-free function definitions):

  • trim (Shared.hs:177, trim :: T.Text -> T.Text; trim = T.dropAround isWS)
  • triml (Shared.hs:181)
  • trimr (Shared.hs:195)
  • stringify (Shared.hs:363-364)
  • capitalize (Shared.hs:396-397)
  • tshow (Shared.hs:170-171)
  • removeFormatting (Shared.hs:344-345)
  • collapseFilePath (Shared.hs:765-766)
  • hasLineBreaks (Shared.hs:614-615)
  • combineLines (Shared.hs:438-439)
  • And more in the same file

Fix Direction

  1. Add "bind" to haskell's func_node_types in NODE_MAPS
  2. Update the node's name-getter (_get_node_name) to correctly extract the variable field's name from a bind node the same way it does for function nodes
  3. Important: The walk should only count a bind node as a real function if there's a paired signature node with a function-typed (arrow-containing) signature for the same name, to avoid flipping the problem into over-counting true non-function value bindings (this mirrors the exact reasoning haskell func_start matches point-free VALUE bindings (no arrow in type) as if they were functions #1312 already applied on the GitGalaxy-regex side of the same distinction)

Related Work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdata-integritytesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions