Haskell-language-server: Use stack/cabal cradle if no project config + ghc not in PATH + stack/cabal in PATH

Created on 21 Dec 2020  路  6Comments  路  Source: haskell/haskell-language-server

  • Opening a single file require to have ghc in path
  • However stack users can do a stack repl to load those files (stack uses the global project configuration)
  • So if we have stack in PATH but no GHC we could use stack to load those files as well
  • Not sure if it can be done in hie-bios or implicit-hie-cradle

//cc @Avi-D-coder @fendor

hie-bios implicit-hie enhancement setup

Most helpful comment

I can take a look on Christmas.

All 6 comments

I can take a look on Christmas.

Thinking in it twice, there exists the possibility of use cabal, as you can set in cabal global config the path to ghc without having it in the global PATH. Not sure if that is a common setup though.
Maybe we should check if cabal exec ghc -- --version works (and in a similar way stack exec ghc -- --version, maybe with --skip-ghc-check to avoid its download?) and proceed to use cabal or stack if ghc is set.

Awesome, this is exactly what I have hoped for a few weeks, but couldn't come up with some specification. Thank you for raising this issue!

I have to say that it arose in a conversation with a haskell beginner (@hieung1401 in the fp discord channel), who was using directly stack for fire a repl.
He had to create a stack project only to make hls work. But even experienced haskell developers work with standalone files so it can be handy for everybody.

Yes, true. I installed system GHC only to make HLS work for small scripts that I need to use from time to time. If HLS supports such a stack detection mechanism, it would allow much compact setting for Haskell dev.

I would say that cabal could not be as useful as stack cause you can configure the stack global project as you want, including dependencies, but afaik you cant do the same in the global cabal config, only set the path to ghc.
So in this case i would choose stack first if both tools are available.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

expipiplus1 picture expipiplus1  路  3Comments

Sir4ur0n picture Sir4ur0n  路  4Comments

alanz picture alanz  路  4Comments

ProofOfKeags picture ProofOfKeags  路  4Comments

expipiplus1 picture expipiplus1  路  4Comments