tfausak / purple-yolk

:hatching_chick: A Haskell IDE for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=taylorfausak.purple-yolk
MIT License
26 stars 2 forks source link

Provide a workflow for managing missing packages #2

Closed tfausak closed 4 years ago

tfausak commented 4 years ago

When you import a module that your package does not depend on, you get a message like this:

Could not load module `Data.ByteString'
It is a member of the hidden package `bytestring-0.10.8.2'.
You can run `:set -package bytestring' to expose it.
(Note: this unloads all the modules in the current scope.)
Use -v to see a list of the files searched for.

You may also get a message like this if the package is missing rather than hidden:

Could not find module `Pipes'
Use -v to see a list of the files searched for.

Assuming you typed the module name correctly, the only thing to do in these scenarios is to add a dependency on the package and restart GHCi. Currently Purple Yolk does not make this easy. There's no way to manually restart it, so I typically end up reloading VSCode entirely.

As a quick and dirty solution to this problem, Purple Yolk could provide a "Restart GHCi" command that you could call using Ctrl+Shift+P. That way you wouldn't have to restart VSCode.

Ideally Purple Yolk could recognize this situation and offer a notification to restart GHCi once the problem has been fixed. Or perhaps it could restart itself when project- or package-level files (like stack.yaml, cabal.project, package.yaml, or *.cabal) change.

tfausak commented 4 years ago

This is fixed in that you can manually work around it now by restarting GHCi without reloading VSCode completely. However it might be nice to have a more automated solution in the future.