Setting up Haskell in VS Code on macOS

Quick Note

So Many Choices!

Up Up and Away

curl https://gitlab.haskell.org/haskell/ghcup/raw/master/bootstrap-haskell -sSf | sh
(Note: on OS X, in the course of running ghcup you will be given a dialog box to install the command line tools. Accept and the requirements will be installed for you. You will then need to run the command again.)
. "$HOME/.ghcup/env"
echo '. $HOME/.ghcup/env' >> "$HOME/.zshrc"
cat << EOF >> ~/.zprofile
# Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF

Creating a Project

mkdir myproject && cd myproject
cabal init -n --is-executable
cabal v2-run
Hello, Haskell!
code .

From Editor to IDE

cabal update && cabal install ghcid
ghcid "--command=ghci Main.hs"

Making Things Purdy

I am a sad file of code :(

Adding Some Style

cabal install hlint
doubleSecond :: Num t => [t] -> [t]
doubleSecond xs = [x | x <- zipWith (*) xs $ concat (repeat [1,2])]

Debugging our Happy Mistakes

cabal install phoityne-vscode haskell-dap
"ghciCmd": "stack ghci --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show",
"ghciCmd": "cabal exec -- ghci -i${workspaceRoot}",
"startup": "${workspaceRoot}/Main.hs",

Haskell IDE Engine

The Haskell Tool Stack

Other resources

Now We’re Ready to Learn Haskell

--

--

A programmer looking for ways to see the forest instead of the trees.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store