Skip to content

Instantly share code, notes, and snippets.

@DarinM223
Last active August 1, 2018 03:13
Show Gist options
  • Save DarinM223/0d166e259a3dd90921e380a27ca0baba to your computer and use it in GitHub Desktop.
Save DarinM223/0d166e259a3dd90921e380a27ca0baba to your computer and use it in GitHub Desktop.
Autoreload workflow

How I use Ghcid in a stack project

  1. Install ghcid with cabal install ghcid

  2. Add the ghcid neovim plugin to ~/.config/nvim/init.vim: Plugin 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' }

  3. Close neovim and reopen it and run :PluginInstall to install the plugin.

  4. Open a stack project in neovim and open a Haskell file (a file with a .hs extension)

  5. Run Ghcid with :Ghcid --restart=[project].cabal -c "stack repl --ghci-options=-fno-code" where [project] is the name of the project. If you want to load tests (but not load the app/Main module), run :Ghcid.

  6. Now whenever you add new files or update the dependencies, open a new terminal in neovim and run stack build. Ghcid will automatically restart and watch the new modules/dependencies.

  7. To delete a module you have to follow these steps:

    1. Edit the [project].cabal file and remove the modules that you want to delete
    2. Delete the files/directories which correspond to the deleted modules
    3. Delete the [project].cabal file
    4. Run stack build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment