This method is OS, GHC version, and editor agnostic.
Enable docker in your stack.yaml file
# stack.yaml docker: enable: true
Set up direnv to use the paths given by stack.
# .envrc export PATH=$(/usr/local/bin/stack path --bin-path)
$ direnv allow .
Install ghcid and copy it to directory for compiler tools
$ stack build --copy-compiler-tool ghcid
Run the following command while editing code in your favorite editor
$ ghcid --command "stack repl" --test ":main"
This post first appeared on Me In Words | A Compendium Of Plagiarized Ideas, please read the originial post: here