Skip to content

How to make Haskell Language Server read the cabal dependencies as a comment in the script? #3465

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

Closed
TheOddler opened this issue Jan 25, 2023 · 3 comments
Labels
status: needs triage type: support User support tickets, questions, help with setup etc.

Comments

@TheOddler
Copy link

Your environment

Which OS do you use?
NixOS 22.11

Which version of GHC do you use and how did you install it?
9.0.2 installed using nix

Which LSP client (editor/plugin) do you use?
VS Codium+vscode-haskell

Which version of HLS do you use and how did you install it?
1.8.0.0 installed using nix

Have you configured HLS in any way (especially: a hie.yaml file)?
No

What's wrong?

I was trying to use haskell to write some small scripts, by adding a shebang at the top of the file and de dependencies as a comment at the top of the file, like this:

#! /usr/bin/env nix-shell
#! nix-shell -i cabal -p ghc cabal-install

{- cabal:
build-depends:
  , base ^>= 4.15
  , elm-syntax
-}

import Language.Elm.Expression as Elm

main :: IO ()
main = do
  putStrLn "Hello"

If I then make the file executable (chmod +x ...) it runs as expected (showing Hello).

However, in my editor (VS Code) I get the error Could not find module ‘Language.Elm.Expression’.

Is there a way to tell the Haskell Language Server to read those build-depends in the comment at the top of the file?
I'm not sure what to call that comment, so Googling didn't help, but probably just because I don't know what to call it.

@TheOddler TheOddler added status: needs triage type: support User support tickets, questions, help with setup etc. labels Jan 25, 2023
@fendor
Copy link
Collaborator

fendor commented Jan 25, 2023

Hi! Thank you for this bug report!

The answer is, unfortunately: currently not all without resorting to some hacks
Relevant issue: #111

@fendor
Copy link
Collaborator

fendor commented Jan 31, 2023

Closing in favour of #111 to avoid duplication. Feel free to reopen, if I am missing something

@fendor fendor closed this as completed Jan 31, 2023
@TheOddler
Copy link
Author

Thank you! I'll follow #111.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage type: support User support tickets, questions, help with setup etc.
Projects
None yet
Development

No branches or pull requests

2 participants