Skip to content

ghc-pkg out of scope

Summary

I'm having trouble getting started with Haskell. Running version 8.6.5 of GHCi of get the following error:

prelude> ghc-pkg list

<interactive>:1:1: error: Variable not in scope: ghc

<interactive>:1:5: error: Variable not in scope: pkg :: t0 -> a

<interactive>:1:9: error:
    * Variable not in scope: list
    * Perhaps you meant `last' (imported from Prelude)

Either I'm missing a first step, or something's gone very wrong.

Steps to reproduce

Unless this is a common behavior and I'm missing a beginner step, I'm clueless as to why I'd get this error. (So I'd appreciate information about how to figure it out, or how to delete everything and start from scratch.) I can do some basic work like adding, defining new functions, etc. But I tried to use a package I'd installed (and which I can find in my cabal folder), and ghci didn't recognize any of the functions from it. So I tried to check if ghci could find the package, and it doesn't even recognize these basic functions.

It's perhaps relevant (I don't know) that I had some trouble installing the ghci: I originally installed 8.10.3, through chocolatey, but the package I'm hoping to learn doesn't work with it, so I had to install version 8.6.5 directly. I couldn't find an uninstall in the original, and I'm new to programming with compiled languages & command prompt (I have experience in R, Python, and Julia) so I didn't touch 8.10.3 when I installed 8.6.5. The path seems go to 8.6.5 before 8.10.3 since when I open a command prompt and type ghc it opens GHCi, version 8.6.5. But perhaps the two versions are interfering with each other somehow???

I'm worried that if I try to start again from scratch I'll keep parts of what I have that will cause problems. (Or that I'm missing a beginner step and reinstalling everything won't help.)

Expected behavior

It should give me the list installed packages--or at least recognize the commands.

Environment

  • GHC version used:

Optional:

  • Windows (64 bit):
Edited by Matthew Petersen
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information