简体   繁体   中英

Trying to install System.Random on stack

I'm using stack 1.6.1. In src/Main.hs I start with

module Main where

import System.IO
import System.Random
...

I do not use anything from System.Random at this time.

When I run stack ghci I get

/Users/mkaravan/end2end/Music/music/src/Main.hs:4:1: error:
    Could not find module ‘System.Random’
    Use -v to see a list of the files searched for.
  |
4 | import System.Random
  | ^^^^^^^^^^^^^^^^^^^^

I've had no luck with any of the following commands:

stack install System.Random
stack install system.random
stack install random

I get this error:

>>> stack install System.Random
Error parsing targets: Directory not found: System.Random

How do I get System.Random to run in Stack?

Probably the most straightforward command is stack ghci --package random . But in theory stack install random should have worked as well. However, since you haven't included the output from that call, it's not clear what didn't work with it.

You probably need to add random to the dependencies section in your package.yaml (or if you are not using hpack, to build-depends in *.cabal ). This tells stack that the package depends on the random package, which contains the System.Random module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM