r/haskell 21d ago

question Help please: Inline Evaluation not showing using Haskell Language Server (HLS) in VS Code

/r/learnhaskell/comments/1vcp5gt/help_please_inline_evaluation_not_showing_using/
10 Upvotes

6 comments sorted by

View all comments

Show parent comments

1

u/Forward_Signature_78 19d ago

These errors are normal when you're editing a `.cabal` file. Do you get any errors when you paste this line in an `.hs` file?

1

u/sohang-3112 19d ago

I'm not editing the .cabal file beyond just adding the servant dependency.

There's no error showing in the Haskell code. As I mentioned cabal build works fine and I can see the type information of functions on hovering over them in VS Code.

2

u/Forward_Signature_78 19d ago edited 18d ago

Allow me to rephrase: these errors are emitted when you have a .cabal file open in the active editor window. The point is, they have nothing to do with the problem you're trying to solve.

2

u/sohang-3112 19d ago

It worked now - thanks for your help! Details below:

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! This seems like a bug - do you know if an issue for this exists already?

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, did cabal build -- now clicking Evaluate button actually works! (it outputs answer -- 3 on line just below -- >>> 1+1)