Haskell: an infix definition (a <+> b = ..., x `plus` y = ...) is indexed under its left operand's name

Author: umaxfunCreated Sep 30, 2026Updated Sep 30, 2026
Labelsparsing/qualitywindows

Version

codebase-memory-mcp 0.11.0

Platform

macOS (Apple Silicon)

Install channel

GitHub release archive / install.sh / install.ps1

Binary variant

standard

What happened, and what did you expect?

A top-level Haskell function defined in infix form gets a Function node named after its left operand, and the function itself has no node. This happens with symbolic operators (a <+> b = ... becomes a) and with backtick infix (x `plus` y = ... becomes x). The prefix form works: (!) a b = ... is indexed as (!).

On pandoc (1539a541f):

  • src/Text/Pandoc/Parsing/General.hs:710 (<+?>) is indexed as a;
  • src/Text/Pandoc/Readers/Org/Meta.hs:77 (~~>) is indexed as a;
  • test/Tests/Helpers.hs:154 (=?>) is indexed as x.

The other 29 operators with a type signature in pandoc are indexed as (op).

Expected: (<+>) and plus, as for the prefix form.

Reproduction

repro/M.hs:

haskell
module M where

(<+>) :: Int -> Int -> Int
a <+> b = a + b

plus :: Int -> Int -> Int
x `plus` y = x + y

f :: Int
f = 1 <+> 2
codebase-memory-mcp cli index_repository --repo-path repro --name repro
codebase-memory-mcp cli query_graph --project repro --query "MATCH (n) WHERE n.label = 'Function' RETURN n.name, n.start_line, n.end_line ORDER BY n.start_line"

Actual: a (line 4), x (line 7), f (line 10). Expected: (<+>) (line 4), plus (line 7), f (line 10).

The grammar parses this file without errors (tree-sitter-haskell 0.23.1: root_node.has_error is false). The function nodes on lines 4 and 7 have no name field. Their first child is an infix node (a <+> b, x `plus` y) that holds the operator, so the wrong name comes from extraction, not from parsing.

Confirmations

  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Source: DeusData/codebase-memory-mcp