vscode-haskell icon indicating copy to clipboard operation
vscode-haskell copied to clipboard

Running HLS features on a standalone Haskell script

Open KristianBalaj opened this issue 2 years ago • 1 comments

Having a following script:

#!/usr/bin/env cabal
{- cabal:
build-depends: base
            , split
-}

import Data.List.Split (splitOn)

main :: IO ()
main = do
  let orders = splitOn "x" "axbxc"
  putStrLn $ head orders

I want to be able to have HLS features on this script. Is it possible in any way?

KristianBalaj avatar May 22 '22 09:05 KristianBalaj

Hi! Unfortunately, this is not possible at the moment. You might be able to get a similar result by using cabal install --lib base split --package-env=. and creating a hie.yaml file with the contents:

cradle:
  direct:
    arguments:
      - -package-env
      - .ghc.environment.x86_64-linux-<version> # check what file has been generated after `cabal install --lib --package-env=.`
      - Script.hs

Native support ticket: https://github.com/haskell/hie-bios/issues/217 Some context for environment files: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/packages.html#package-environments

fendor avatar May 22 '22 15:05 fendor

closing, since no activity, and also, not the job of vscode-haskell. See here the discussion for a workaround: https://github.com/haskell/haskell-language-server/discussions/3572

fendor avatar May 11 '23 12:05 fendor