简体   繁体   中英

How do I import a Haskell package into the REPL for interactive use?

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:

  1. brew install ghc cabal-install
  2. cabal update
  3. cabal install --lib distributive
  4. ghci
  5. import Data.Distributive

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM