I used cabal installed required packages for my project,but when I trying to load those packages,GHCI still complains.
--lib
should have done it, unfortunately I am not a Win user so I cannot help more.
While you wait for more meaningful answers, you could get around this by creating a cabal project in an empty folder (cabal new
) and adding whatever dependency you like in projectname.cabal
.
I was driven crazy by this system, really
I found a stackoverflow thread https://stackoverflow.com/questions/62335595/ghci-unable-to-recognize-packages-installed-with-cabal-on-windows-10 stating that I can use cabal install --lib --package-env . random to import packages installed with cabal,and it works.
You can use cabal repl --build-depends …
to get ghci
running with the listed dependencies in scope, outside of any cabal projects. Under the hood, it creates a temporary package. See elsewhere for a more detailed discussion.