GHCI unable to recognize packages installed with Cabal on windows 10

妖精的绣舞 提交于 2021-02-05 10:40:14

问题


I am a beginner with Haskell and for an assignment I needed to install System.Random. So I installed the package using Cabal through command line (originally with cabal install random and then with cabal install --lib random), however, when I run GHCI it doesn't recognize that the package is installed. When I run it I get this error:

Could not find module `System.Random'
    Use -v to see a list of the files searched for.
  |
3 | import System.Random
  | ^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.

I tried a few things to fix this, however, none of them seem to work. I tried to copy the files from the cabal directory where the package is saved and place them in the same folder as my project but I received this error.

     File name does not match module name:
    Saw: `Main'
    Expected: `Random'
  |
1 | #if __GLASGOW_HASKELL__ >= 701
  | ^
Failed, no modules loaded.

I then attempted to run ghc with "ghc -iC:\DirectoryToPackage AssignmentThatCallsPackage.hs" and this gave the same error as above. I also attempted this solution given here ghc can't find my cabal installed packages the second answer to make the package global but when I tried to run the line "runhaskell Setup install" it gave me an access denied error. I feel I have tried other solutions, but I can't remember what else I tried at the moment. I have been stuck on this for a while now so any help would be appreciated. Thank you in advance.

来源:https://stackoverflow.com/questions/62335595/ghci-unable-to-recognize-packages-installed-with-cabal-on-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!