haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Codelens eval should not interact with IO

Open podocarp opened this issue 5 years ago • 4 comments

Subject of the issue

-- >>> getChar actually returns a value. It seems to be reading the characters from the link between the server and editor. However it does not seem to cause any crashes or ruin the link, on my editor at least. putStr etc. might also possibly be doing something unexpected although it does not seem to produce any noticeable effects on the editor.

Your environment

neovim 4.4, coc.nvim.

The codelens eval should perhaps perform some pre-processing and get rid of any IO first, just to be safe.

podocarp avatar Oct 03 '20 10:10 podocarp

Perhaps std{in,err,out} can be redirected or something, but I think it can still be useful to have IO in examples (e.g. IORefs/MVars)

googleson78 avatar Oct 03 '20 10:10 googleson78

@podocarp do you agree that handling std would be enough to make safe io calls?

jneira avatar Oct 05 '20 07:10 jneira

Sorry, I'm not an expert in Haskell so I'm the wrong person to be asking. However handling it still sounds like a good idea. I would think that things like getLine however would have to be blocked altogether because it makes no sense in the first place.

podocarp avatar Oct 18 '20 09:10 podocarp

I arrived here via:

  • #4506

The current documentation for hls-eval-plugin states:

IO expressions can also be evaluated but their output to stdout/stderr is NOT captured:

>>> print "foo" ()

However, on current Windows 11, with current Visual Studio Code and Haskell extension (v2.6.1), current Stack, HLS 2.11.0.0 (the latest available via GHCup) and GHC 9.10.2 (as HLS 2.11.0.0 does not support GHC 9.10.3):

-- >>> print "foo"

is stuck at Evaluate... regardless of any request to evaluate.

(In the same source file, at the same time, something like -- >>> "foo" evaluates as expected.)

mpilgrem avatar Oct 17 '25 20:10 mpilgrem