haskell / haskell/haskell-mode
`haskell-interactive-type-show-for-ambiguous` is not respected
- Dominant language
- Emacs Lisp
- Stars
- 1.4k
- Forks
- 354
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 2
Description
Hi, I'm used to having non-`Show`able objects printed as their types, as the variable `haskell-interactive-type-show-for-ambiguous` is documented to do, but it's currently not working. Some debugging shows that the haskell process is not giving exactly the same error message as what is expected. Here's the full backtrace:
*Backtrace*
```
Debugger entered--entering a function:
* haskell-interactive-mode-trigger-compile-error((((name . "haskell") (next-error-region # . #) (next-error-locus) (interactive-buffer . #) (current-dir . "/home/rvs314/.tmp/") (cabal-checksum) (cabal-dir . "/home/rvs314/.tmp/") (process (name . "haskell") (current-response-cursor . 0) (current-response . ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n\4") (command-queue) (inferior-process . #) (is-restarting) (current-command . #s(haskell-command :state #1 :go # :live # :complete #)) (suggested-imported) (sent-stdin) (evaluating) (session . #2))) ((name . "haskell") (current-response-cursor . 0) (current-response . ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n\4") (command-queue) (inferior-process . #) (is-restarting) (current-command . #s(haskell-command :state #1 :go # :live # :complete #)) (suggested-imported) (sent-stdin) (evaluating) (session (name . "haskell") (next-error-region # . #) (next-error-locus) (interactive-buffer . #) (current-dir . "/home/rvs314/.tmp/") (cabal-checksum) (cabal-dir . "/home/rvs314/.tmp/") (process . #3))) "show" 250) ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n")
#((((name . "haskell") (next-error-region # . #) (next-error-locus) (interactive-buffer . #) (current-dir . "/home/rvs314/.tmp/") (cabal-checksum) (cabal-dir . "/home/rvs314/.tmp/") (process (name . "haskell") (current-response-cursor . 0) (current-response . ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n\4") (command-queue) (inferior-process . #) (is-restarting) (current-command . #s(haskell-command :state #1 :go # :live # :complete #)) (suggested-imported) (sent-stdin) (evaluating) (session . #2))) ((name . "haskell") (current-response-cursor . 0) (current-response . ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n\4") (command-queue) (inferior-process . #) (is-restarting) (current-command . #s(haskell-command :state #1 :go # :live # :complete #)) (suggested-imported) (sent-stdin) (evaluating) (session (name . "haskell") (next-error-region # . #) (next-error-locus) (interactive-buffer . #) (current-dir . "/home/rvs314/.tmp/") (cabal-checksum) (cabal-dir . "/home/rvs314/.tmp/") (process . #3))) "show" 250) ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n")
haskell-command-exec-complete(#s(haskell-command :state (((name . "haskell") (next-error-region # . #) (next-error-locus) (interactive-buffer . #) (current-dir . "/home/rvs314/.tmp/") (cabal-checksum) (cabal-dir . "/home/rvs314/.tmp/") (process (name . "haskell") (current-response-cursor . 0) (current-response . ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n\4") (command-queue) (inferior-process . #) (is-restarting) (current-command . #1) (suggested-imported) (sent-stdin) (evaluating) (session . #3))) ((name . "haskell") (current-response-cursor . 0) (current-response . ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n\4") (command-queue) (inferior-process . #) (is-restarting) (current-command . #1) (suggested-imported) (sent-stdin) (evaluating) (session (name . "haskell") (next-error-region # . #) (next-error-locus) (interactive-buffer . #) (current-dir . "/home/rvs314/.tmp/") (cabal-checksum) (cabal-dir . "/home/rvs314/.tmp/") (process . #4))) "show" 250) :go # :live # :complete #) ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n")
haskell-process-collect(((name . "haskell") (next-error-region # . #) (next-error-locus) (interactive-buffer . #) (current-dir . "/home/rvs314/.tmp/") (cabal-checksum) (cabal-dir . "/home/rvs314/.tmp/") (process (name . "haskell") (current-response-cursor . 0) (current-response . ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n\4") (command-queue) (inferior-process . #) (is-restarting) (current-command . #s(haskell-command :state (#1 #10 "show" 250) :go # :live # :complete #)) (suggested-imported) (sent-stdin) (evaluating) (session . #1))) " print it\n\n\4" ((name . "haskell") (current-response-cursor . 0) (current-response . ":19:1-4: error: [GHC-39999]\n • No instance for ‘Show (() -> String)’\n arising from a use of ‘print’\n (maybe you haven't applied a function to enough arguments?)\n • In a stmt of an interactive GHCi command: print it\n\n\4") (command-queue) (inferior-process . #) (is-restarting) (current-command . #s(haskell-command :state (((name . "haskell") (next-error-region # . #) (next-error-locus) (interactive-buffer . #) (current-dir . "/home/rvs314/.tmp/") (cabal-checksum) (cabal-dir . "/home/rvs314/.tmp/") (process . #3)) #3 "show" 250) :go # :live # :complete #)) (suggested-imported) (sent-stdin) (evaluating) (session (name . "haskell") (next-error-region # . #) (next-error-locus) (interactive-buffer . #) (current-dir . "/home/rvs314/.tmp/") (cabal-checksum) (cabal-dir . "/home/rvs314/.tmp/") (process . #3))))
haskell-process-filter(# " print it\n\n\4")
```
The response GHC seems to be giving back is:
```
:24:1-3: error: [GHC-39999]
• No instance for ‘Show (Integer -> Integer -> Integer)’
arising from a use of ‘print’
(maybe you haven't applied a function to enough arguments?)
• In a stmt of an interactive GHCi command: print it
```
Which doesn't match the regexes used in the definition of `haskell-interactive-mode-trigger-compile-error` when [first checking for an error](https://github.com/haskell/haskell-mode/blob/2dd755a5fa11577a9388af88f385d2a8e18f7a8d/haskell-interactive-mode.el#L1036) (there's no newline to begin the message) then [later when it is checked to be a `Show` error](https://github.com/haskell/haskell-mode/blob/2dd755a5fa11577a9388af88f385d2a8e18f7a8d/haskell-interactive-mode.el#L1045) (GHC uses `‘` rather than `(` to delimit the constraint). If you modify them to match the error message, then everything else works. I'm not sure if this is a regression that should be solved that way, as I'm not too familiar with the internals of how the process handling works, but I'd be happy to send over my changes as a PR if they are appropriate.
Versions
```
~ $ version
GNU Emacs 30.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.51, cairo version 1.18.4)
of 2025-12-03, modified by Debian
~ $ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.12.2
```
Contributor guide
Research direction
Start in haskell-interactive-mode.el at haskell-interactive-mode-trigger-compile-error, especially the checks around lines 1036 and 1045. Reproduce the response with GHC 9.12.2 and inspect how its error text is matched. Done means the documented type display works for the reported Show error while existing process-error handling remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs-lisp, haskell
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100