This repository has been archived by the owner on Mar 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Setting up Haskell
Luke Lau edited this page Dec 29, 2019
·
3 revisions
You'll need GHC, a Haskell compiler, and cabal-install, the package manager:
addons:
apt:
packages:
- ghc
- cabal-install
sudo apt install ghc cabal-install
brew install ghc cabal-install
After they're installed be sure to run
cabal update
mkdir tests
cd tests
Create a file called tests.cabal
name: tests
version: 0.1.0.0
build-type: Simple
cabal-version: 2.0
test-suite tests
type: exitcode-stdio-1.0
main-is: Test.hs
build-depends: base
, lsp-test
And inside Test.hs
import Language.Haskell.LSP.Test
main = runSession "my-server" fullCaps "." $
liftIO $ putStrLn "Hello world"
To run your tests, inside the tests
directory call
cabal test
And lsp-test
should now be running your server!
For a more batteries-included testing setup with Hspec
, we recommend the following dependencies
test-suite tests
type: exitcode-stdio-1.0
main-is: Test.hs
build-depends: base
, lsp-test
, hspec
And a Test.hs
like
import Language.Haskell.LSP.Test
import Language.Haskell.LSP.Types
import Test.Hspec
main = hspec $ do
describe "my feature" $ do
it "does this" $ runSession ...
it "does that" $ runSession ...
describe "my other feature" $ do
it "works" $ runSession ...
it "works when" $ runSession ...