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

Time:11-23

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.

CodePudding user response:

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
  • Related