26

I'm new with Haskell and have trouble with its package.

I want to import System.Random but

Could not find module `System.Random'

Then I tried to import System but

Could not find module `System'.

It is a member of the hidden package `haskell98-2.0.0.0'.


I tried to search this problem, but those solutions still don't work.

As this said, I tried to install cabal on my Mac OS X using MacPort, but

Error: The following dependencies were not installed: ghc Error: Status 1 encountered during processing.

I have installed Haskell Platform and can use ghci in command-line. GHCi, version 7.2.1


Then I tried to use ghc-pkg expose haskell98-2.0.0.0 as this one says.

But this time, I can't even run ghci.

Top level:

Ambiguous interface for `Prelude':

it was found in multiple packages: base haskell98-2.0.0.0


So, what can I do without using cabal?

Community
  • 1
  • 1
Ovilia
  • 7,066
  • 12
  • 47
  • 70
  • 5
    The Haskell Platform should come with Cabal. You shouldn't need to install anything else (other than the random package -- `cabal install random`) – Tyler Sep 01 '11 at 16:40
  • According to the page you linked, Haskell Platform based on GHC 7.2.x has not been released yet. You are asking for troubles if you have replaced GHC in Haskell Platform. – Tsuyoshi Ito Sep 02 '11 at 21:05

4 Answers4

23

The System.Random module belongs to the random package, which is no longer included with GHC as of version 7.2.1.

I'm not sure what to do about your Cabal problem, as I'm not familiar with Mac OS X, but I'd recommend getting that to work first. Installing random should then be trivial using Cabal.

As a possible workaround, you might want to consider using an older version of GHC.

hammar
  • 138,522
  • 17
  • 304
  • 385
18

the cabal incantation:

cabal install random
ssanj
  • 2,169
  • 3
  • 19
  • 28
  • won't this be a global install and should be discouraged? instead the dependencies should be added to the .cabal file? – dade Aug 10 '20 at 12:10
  • yeah, you're right. You could use a cabal sandbox these days. – ssanj Aug 12 '20 at 01:44
0

The answer here is a little bit dated and would lead to a global install and should be discouraged.

A better approach will be to add the random package as dependency in the .cabal file.

Something like this:

build-depends:       base ^>=4.13.0.0 --base package
                   , random           -- random package where System.Random can be found
dade
  • 3,340
  • 4
  • 32
  • 53
0
cabal repl -b random # -b is short for --build-depends

This answer was based on another stackoverflow thread here. Basically it installs the package random as a dependency of your project rather than installing it globally. Packages are installed globally if you just write cabal install random - which we dont usally want.

Awshaf Ishtiaque
  • 441
  • 5
  • 11