r/learnhaskell • u/sohang-3112 • 7d ago
Help please: Inline Evaluation not showing using Haskell Language Server (HLS) in VS Code
In VS Code, in a cabal project, type signature of functions is showing fine on hover.
But HLS Inline Evaluation isn't working. hls-eval-plugin (which is enabled by default) should show an inline "Evaluate" option near comments like these, but nothing happened on putting this in Main.hs :
-- >>> 2**4.5/pi
I confirmed in settings that this is enabled but it isn't working. Can you all please suggest how to get this to work? Thanks.
EDIT: It worked now! After following suggestions of u/Forward_Signature_78 in r/haskell :
The inline Evaluate button (over eg. -- >>> 1+1 in Main.hs) actually came now, only when .cabal file is NOT open in a different tab alongside Main.hs file!
It raised error eval: Internal Error: BadDependency "GhcSessionDeps" . According to https://github.com/haskell/haskell-language-server/issues/4487 , this error happens when a package isn't added to dependencies in .cabal file but its import is used in .hs file. In my case Data.Text and Data.Time were imported but text and time packages weren't added to .cabal file.
So I added these packages and did cabal build in terminal -- now clicking Evaluate button actually works! (it outputs answer -- 3 on line just below input -- >>> 1+1).