To include Cabal dependencies I run cabal install mypackage
I then run cabal repl and from REPL use import library
This allows to use newly added library from GHCi.
Is same possible using WinGhci ? Run a WinGhci REPL which has access to installed Cabal dependencies ?
You can use :! to execute shell commands. I.e. run :!cabal install mypackage from within the WinGHCi repl. But then you can't import mypackage until you restart WinGHCi. That's my experience at least. I'm interested in an answer as well...
Running :!cabal repl inside WinGHCi repl is just not sensible (which answers the title to your question literally).
Related
I'm new to Haskell, and have found the :type command in the ghci REPL to be really useful for interactively figuring out how things work. So far I've only used things from the base package, but now I'd like to use something from distributive with the :type command in the REPL.
How in the world do I do this? If it matters, I'm on macOS and have done brew install ghc cabal-install. But nothing I've tried will either install or import the distributive package, and the error messages are not very good. I've found lots of related questions and documentation, but nothing shows a worked example, and I'm unable to infer what commands to use.
I eventually figured this out. The missing pieces were needing to first update cabal (even though I had just installed it), and to use --lib as an argument when installing:
brew install ghc cabal-install
cabal update
cabal install --lib distributive
ghci
import Data.Distributive
I don't fully understand the system of module usage in Python yet.
I know how to install modules in the terminal, and how to install them using the interpreter section of Pycharm, but I don't understand the difference of installing either way, and how to install to a singular location which will enable usage of the module universally.
I found that by installing through terminal using pip3 that the modules were usable in the shell as well as Pycharm
Recently Installed VS Code in my Ubuntu14.04 . Installed Haskell using Stack.
Getting these errors. Kindly help.
Error: Couldn't start ghc-mod process Error: Command failed: ghc-mod version
Error: Cannot hlint the haskell file. The hlint program was not found. Use the 'haskell.hlint.executablePath' setting to configure the location of 'hlint'
It looks like you've installed 2 extensions for vscode, one for linting and one for running ghc-mod, but you don't have hlint or ghc-mod installed.
If you are using this ghc-mod extension, make sure you have ghc-mod installed through cabal or through stack.
IF you are using this linter extension, make sure you have hlint installed through cabal or through stack.
To install with cabal, run:
cabal install hlint
and
cabal install ghc-mod
To install via stack, see the stack documentation.
After cabal install random, I try ghc-mod list but it still doesn't see the package.
cabal --version
cabal-install version 1.22.6.0
using version 1.22.4.0 of the Cabal library
ghc-mod --version
ghc-mod version 5.5.0.0 compiled by GHC 7.10.3
I have now also tried adding random-1.1 to my global stack.yaml (trying to make a simple script here...) and installed via stack install random to no avail.
My file seems to run fine with runhaskell though.
When you type stack install random, and then run stack ghci or install with stack, the import succeeds
> import System.Random --succeeds
If you run ghc outside of stack, it won't necessarily use the same setup.
I want to try doing regexes in GHCi. I tried loading the module
:mod +Text.Regex.Posix
But got this error instead
<no location info>:
Could not find module ‘Text.Regex.Posix’
It is not a module in the current program, or in any known package.
But I should have Text installed
ghc-pkg find-module Text.Regex.Posix would give me
/usr/local/Cellar/ghc/7.8.4/lib/ghc-7.8.4/package.conf.d
/Users/a/.ghc/x86_64-darwin-7.8.4/package.conf.d
What do I do?
I have no problem with this though:
import Text.Read
Why?
The problem is that you simply don't have the regex-posix package installed. This is the package that exports the Text.Regex.Posix module. Text.Read is exported by the base package which comes with every Haskell distribution.
You can see this by running ghc-pkg find-module Text.Read. To install the regex-posix package globally run the command cabal install regex-posix. If you don't want to install it globally or run into problems getting it to install, it would be better to try installing it with the same command in a sandbox after running cabal sandbox init in the directory of your choice.