eval not working after certain haskell code?
Closed this issue · 8 comments
Hi,
I experienced, that some comments containing >>> are not evaluated in certain lines of my file. I tried to reproduce the behavior with this peace of code:
-- >>> 2 + 2
-- 4
myfunc :: [Int] -> String
-- >>> 2 + 2
-- 4
myfunc [] = ""
-- >>> 2 + 2
-- 4
myfunc [i] = show i
-- >>> 2 + 2
-- No "Refresh" or "Evaluate", no respone!
myfunc (i:is) = show i ++ ", " ++ myfunc is
-- >>> 2 + 2
-- No "Refresh" or "Evaluate", no respone!
I'm using archlinux, vim, coc, and haskell-language-server-wrapper.
I have first asked this question in coc.nvim, but it may be an issue with the hls?
neoclide/coc.nvim#5410
Seems no one else has the issue?
I can confirm this issue. I am running Neovim on NixOS/nixpkgs v25.05.
I haven't had time to create a reproduction yet, but my initial feeling was that it was related to large modules or TemplateHaskell/QuasiQuotes. However, I have also seen it in simpler modules.
Hi, I think this issue is more or less known, there are certain situations where the eval plugin is not working, for example between function bodies, but I didn't find the existing issues, then I forgot to comment :)
I assigned a couple of labels, if you want to look into it, we are happy to give a couple of pointers.
I would be interested to look into it, only that it will take me forever and a day, probably.
To reproduce it, it needs no module or anything but just a view lines, similar to what I posted. Even less code is needed, only:
f :: [a] -> Int
f [] = 0
f [i] = 1
-- >>> 3 + 3
This is not a complete function, of course. If f [] = and f [i] = are both in the code, the failure occurs, after the f [i] =. In the picture below are some simple situations when the failure occurs and when not.
I also have the impression, as @fendor mentioned, that it has to do with function body. Only that in haskell, as far as I know, you can't signal the end of a function body?
Third thing, I wonder if the problem occurs already before the eval plugin has a chance to "look" at the line? So, if this line gets filtered out before the eval plugin runs? If this can be excluded, it would reduce the places to look at, I guess?

I wonder what version of haskell-language-server / ghc you're using.
I remember I improved the way that eval plugin searches for comments more than a year ago in #4113
The behavior your screenshot shows looks exactly like what I fixed in that PR.
Tried your reproducer on ghc 9.6.7 + latest hls and it works fine.
Thanks @jhrcek
Looks like am a bit outdated.
I'm using archlinux with their latest versions, which are:
ghc 9.4.8-1
haskell-language-server 2.1.0.0-43
Indeed, that's quite old.
Based on the changelogs, this issue has been fixed in hls 2.8.0.0 and the latest available version is 2.11.0.0.
My recommendation would be to use ghcup to install more recent version that has the fix:
https://haskell-language-server.readthedocs.io/en/stable/installation.html#ghcup
Wonderful!
It works.
Thanks.
I installed ghcup and the currently recommended versions of hls and ghc.
