When querying completions for operators GHCi returns a list containing all imported names rather than suitable completions.
For example, if you simply start GHCi and run :complete repl ">>" command it will give you all names from base and Prelude. Then if you import something else, for example :m +Data.Text, the result of query will contain names from Data.Text also.
In case of projects (cabal repl) things are worst, because returned list contains all names imported project-wise and it could be really huge.
The problem comes from using the default word_break_chars when completing identifiers in ghc/ghc/InteractiveUI.hs:
-- We initialize readline (in the interactiveUI function) to use -- word_break_chars as the default set of completion word break characters. -- This can be overridden for a particular command (for example, filename -- expansion shouldn't consider '/' to be a word break) by setting the third -- entry in the Command tuple above. -- -- NOTE: in order for us to override the default correctly, any custom entry -- must be a SUBSET of word_break_chars. word_break_chars :: String word_break_chars = let symbols = "!#$%&*+/<=>?@\\^|-~" specials = "(),;[]`{}" spaces = " \t\n" in spaces ++ specials ++ symbolswrapIdentCompleter = wrapCompleter word_break_chars
The problem comes from using the default word_break_chars
Oh, so I suppose potential solution is to check if prefix to be completed starts with operator symbol, and if the case do not use wrapIdentCompleter in completeIdentifier.
A space is needed between the variable and the operator for completion to work.
To solve this nicely requires adding a function to haskeline, similar to completeWord, but which takes a predicate function instead of a list of escape characters.
The tests T10576a and T10576b are marked expect_broken for this issue.