-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing problem with ghc-8.2.1 #1553
Comments
Relevant #1168. |
I'am working on making interactive working again as well. The 2 things I've done so far are: Added
Thia sisables the new (very nice) ghc8.2 error messages with source code snippets, as it seems not to be supported by the error parser yet. In #1555 Next step would be to fix/extend the error parsers. |
As mentioned by @ruomad the problem sits in To illustrate the changes between before/after ghc 8.2. I tested the load on the shell with both versions and both cases (one or multiple modules loaded). Behavior ghc-8.0.2:
Behavior ghc-8.2.1:
Try to fix:The change from 8.02 to 8.2.1 are:
So I added another condition to (defun haskell-process-load-complete (session process buffer reload module-buffer &optional cont)
"Handle the complete loading response. BUFFER is the string of
text being sent over the process pipe. MODULE-BUFFER is the
actual Emacs buffer of the module being loaded."
(when (get-buffer (format "*%s:splices*" (haskell-session-name session)))
(with-current-buffer (haskell-interactive-mode-splices-buffer session)
(erase-buffer)))
(let* ((ok (cond
((haskell-process-consume
process
"Ok, modules loaded: \\(.+\\)\\.$")
t)
((haskell-process-consume
process
"Ok, ([[:digit:]]+) modules? loaded.$")
t)
((haskell-process-consume
process
"Failed, modules loaded: \\(.+\\)\\.$")
nil)
(t
(error (message "Unexpected response from haskell process.")))))
(modules (haskell-process-extract-modules buffer))
(cursor (haskell-process-response-cursor process))
(warning-count 0)) But existing regex is used match a group (the comma seperated list of module names), which no longer exists in ghci 8.2. So my matcher works But I don't have the string with the modules which seems to be used further down in the chain. |
@alios your code is missing 2 close parens and your regexp is incorrect. Remove the parens in the regexp or double backslash them. Since you're capturing the count of modules and that isn't used, you can drop them. I'm still trying to figure out how to get the modules printing so they can be introspected properly... but I don't know ghc's flags at all. |
Actually you need the parens so it has SOMETHING to process as module names, even if it is just a number. |
The module list seems to be only important if you turn on haskell-process-reload-with-fbytecode or you turn on haskell-process-auto-import-loaded-modules. I turn them off (never needed them) so I'm doing OK. But I can't speak for other people's use cases. |
The relevant change in ghc is But it should be possible to get the necessary information from |
Btw, the way, the changes in haskell-load.el need to match the case of failure, too. |
Is anyone aware of a solution to the problems with GHC 8.2.1, or at least of a way to work around them? It's rather unpleasant that haskell-mode doesn't support that compiler properly at the moment since many projects switch to the new GHC version and it's getting more and more difficult (for me) to stick to 8.0.x. Any help remedying this issue would be very much appreciated. |
Did someone talk to some upstream developers/has connections? Some machine readable output would be interesting to have behind some flag. |
Fixing the @alios solution I got my code loaded again... But I don't know if will work always and the modules names are missing because the breaking change of new ghc, as people above commented. (defun haskell-process-load-complete (session process buffer reload module-buffer &optional cont)
"Handle the complete loading response. BUFFER is the string of
text being sent over the process pipe. MODULE-BUFFER is the
actual Emacs buffer of the module being loaded."
(when (get-buffer (format "*%s:splices*" (haskell-session-name session)))
(with-current-buffer (haskell-interactive-mode-splices-buffer session)
(erase-buffer)))
(let* ((ok (cond
((haskell-process-consume
process
"Ok, modules loaded: \\(.+\\)\\.$")
t)
((haskell-process-consume ;; new condition
process
"Ok, \\([[:digit:]]+\\) modules? loaded.$")
t)
((haskell-process-consume
process
"Failed, modules loaded: \\(.+\\)\\.$")
nil)
(t
(error (message "Unexpected response from haskell process.")))))
(modules (haskell-process-extract-modules buffer))
(cursor (haskell-process-response-cursor process))
(warning-count 0))
(haskell-process-set-response-cursor process 0)
(haskell-check-remove-overlays module-buffer)
(while
(haskell-process-errors-warnings module-buffer session process buffer)
(setq warning-count (1+ warning-count)))
(haskell-process-set-response-cursor process cursor)
(if (and (not reload)
haskell-process-reload-with-fbytecode)
(haskell-process-reload-with-fbytecode process module-buffer)
(haskell-process-import-modules process (car modules)))
(if ok
(haskell-mode-message-line (if reload "Reloaded OK." "OK."))
(haskell-interactive-mode-compile-error session "Compilation failed."))
(when cont
(condition-case-unless-debug e
(funcall cont ok)
(error (message "%S" e))
(quit nil))))) @peti I think you can at least silent the useless errors with it... |
@ryukinix, thank you very much for the updated patch. It does remedy the parser errors when loading a module, indeed, but another significant problem remains, i.e. Emacs still fails with a "parse error" in case the loaded Haskell module contains syntax errors. With ghc 8.0.x and before, Haskell mode would display those error messages in the ghci process buffer, but with 8.2.x it no longer does. This makes development with 8.2 pretty much unpractical, still. 😞 |
I'm glad that this helped in someway. Sad about the syntax errors, I understand that this is not good enough... would be nice if the GHC developers instead of just removing features because they THINK that no ones use, just disable by default and keep some flag to be possible enable again... as the commit that @swilde attached on this thread, seems that doesn't exists such thing. They just removed all the shit :/ We need to figure out another approach to handling this cases... more hacks? 😆 |
Raise an issue on the ghc bug tracker for this. It's trivial to bring this back and hide the new behavior behind a flag. Which in my opinion is what should have been done in the first place so I agree with you there. I can assure you that all these "quiet the UI" patches have all been quite controversial but a good way to raise a stink and get it fixed before release is to try the RC builds. I don't think you guys should reduce the quality of your code with hacks for something that can be easily corrected upstream. Anyways, raise a ticket. There's still time to correct it for 8.4 |
Alternatively, go to https://phabricator.haskell.org/rGHC14ff644c45e04ac6441f2faa3d2a518a7201ab11 log in (you can do so with your GitHub credentials if you don't have an account) and scroll to the bottom, you'll find an box with actions, pick The original author an reviewers will be notified of this then. |
Please do come raise this idea with us either on IRC ( We would love to put in place some machine readable output to make consumers like |
To summarize: Sven Panne kindly brought this issue to my attention this morning on However, in general I'm not at all fond of adding complexity to the compiler to allow a downstream project to continue using a REPL as a language server. In fact, I would like to deprecate this flag as soon as possible. The ultimate solution here, as mentioned in this thread, is to design a machine-readable interface. Let's do this. I've opened #1570 to track this. |
So ... what is the current state of affairs? Can I use ghc 8.2.2 with a current version of haskell-mode? |
The good news is that -fshow-loaded-modules restores listing loaded modules. But there are bad news too. In the GHC User's Guide, The release note says "-show-mods-loaded" erroneously (probably because hastily). (The flag reference has it right, though.) If you don't use -fshow-loaded-modules, then there is also a change: Whereas 8.2.1 gives "Ok, 5 modules loaded.", 8.2.2 gives "Ok, five modules loaded.". I have only tested up to five, I don't know where it ends. |
For anyone looking for a quick fix. |
To further elaborate on @mschristiansen's quick fix: in my case, I had to add |
To further elaborate again, for |
For people like me who find it difficult to follow the above instructions: (setq haskell-process-args-ghci
'("-ferror-spans" "-fshow-loaded-modules"))
(setq haskell-process-args-cabal-repl
'("--ghc-options=-ferror-spans -fshow-loaded-modules"))
(setq haskell-process-args-stack-ghci
'("--ghci-options=-ferror-spans -fshow-loaded-modules"
"--no-build" "--no-load"))
(setq haskell-process-args-cabal-new-repl
'("--ghc-options=-ferror-spans -fshow-loaded-modules")) |
raxod502, you need to add "--ghc-options" twice: (setq haskell-process-args-cabal-repl |
This is related to the whole problem of GHC changes of the info at version 8.2.1 This fix was borrowed from: haskell/haskell-mode#1553
This is related to the whole problem of GHC changes of the info at version 8.2.1 This fix was borrowed from: haskell/haskell-mode#1553
It error'd otherwise when loading a module. haskell/haskell-mode#1553 (comment)
With current haskell-mode and GHC 8.4.3, this works for me:
|
For those who still want their Change you
By default stack doesn't call
I am sure similar approach will work for cabal as well, except that system |
Is there a plan to fix this issue? If I understand correctly, the interactive Haskell integration has been completely broken since last September. What?? I totally get that open-source takes time to maintain, but I'm just wondering what the status is. Are we waiting for a pull request to be submitted? Are we aiming to get something changed upstream? Are we still trying to figure out what the correct approach is? |
Generally the solution should come in the form of #1570. GHC added the Someone just needs to take ownership of |
For the record, I have opened a GHC ticket where we can collect design ideas. Please do chime in; we would love to improve GHC's tooling story but we need your input to do so. |
Thanks! In the meantime (before all of this gets fixed properly) would it make sense to put my workaround #1553 (comment) or something similar in the documentation of |
It seems the messages when loading a file have changed with ghc-8.2.1.
I got the error "Unexpected response from haskell process".
After looking into it, I fixed it by changing the regex in haskell-load.el. My patch is :
--- Source/hs/haskell-load.el 2017-09-06 12:24:28.341913600 +0200
+++ .emacs.d/elpa/haskell-mode-20170903.948/haskell-load.el 2017-09-06 12:30:54.954209500 +0200
@@ -107,11 +107,11 @@
(let* ((ok (cond
((haskell-process-consume
process
I didn't check it's working on previous ghc versions, but it's meant to do it.
The text was updated successfully, but these errors were encountered: