[Haskell-cafe] Global Package Install

Viktor Dukhovni ietf-dane at dukhovni.org
Thu Feb 18 20:35:10 UTC 2021


On Thu, Feb 18, 2021 at 12:22:52AM -0800, A. Mc. wrote:

> I am trying to add the package System.Random to be able to run it the same
> way Data.List or Data.Char, et cetera does in ghci and in doing a ghc
> command line build.  I've tried using $ stack ghci --package random which I
> have to run every single time I want to load a module that imports anything
> from System.Random and I've already tried $ cabal install --lib random
> which only works with cabal, and I've used the command $ stack install
> random, which says 'cache populated' but if a restart and load a dependent
> module, still is not working for me.  I've also tried to update the .yaml
> file by putting System.Random into the brackets is the sr directory, but
> this I'm guessing isn't what you're supposed to do as it doesn't work
> either. I'm using Cygwin on a Windows 10 operating system.  Your assistance
> in this matter would be greatly appreciated.

You can use "cabal repl -z" to run ghci with the Cabal "user" package
database in scope:

    $ ghci
    GHCi, version 9.0.1: https://www.haskell.org/ghc/  :? for help
    λ> :set -package iproute
    cannot satisfy -package iproute
        (use -v for more information)
    λ>
    Leaving GHCi.

    $ cabal repl -z
    Resolving dependencies...
    Build profile: -w ghc-9.0.1 -O1
    In order, the following will be built (use -v for more details):
     - fake-package-0 (lib) (first run)
    Configuring library for fake-package-0..
    Preprocessing library for fake-package-0..
    Warning: No exposed modules
    GHCi, version 9.0.1: https://www.haskell.org/ghc/  :? for help
    Loaded GHCi configuration from /tmp/cabal-repl.-87318/setcwd.ghci
    λ> :set -XOverloadedStrings
    λ> :set -package iproute
    package flags have changed, resetting and loading new packages...
    λ> import Data.IP
    λ> import Numeric
    λ> showHex (fromIPv4w "127.0.0.1") ""
    "7f000001"

-- 
    Viktor.


More information about the Haskell-Cafe mailing list