1

I get the error that couldn´t find module System.Random and I tried to do Cabal Update ; Cabal Install Random and Cabal update --lib random, in Windowns, and it assumes the same error.

I also have Ubuntu in a Virtual Box/Machine and I tried to do sudo apt-get install cabal update and it assumes, also, the same error.

James Z
  • 12,209
  • 10
  • 24
  • 44
jxz
  • 41
  • 4
  • You say "this error" but there isn't an error. It is unclear how you are trying to install System.Random and it is unclear to me if it fails both when trying on Windows and in your Ubuntu, or if it fails in your Ubuntu on Windows. Could you please edit your question so that it becomes easier to answer? – sshine Nov 05 '20 at 11:59

2 Answers2

3

The shortest path I can think of is: Consider installing Haskell Platform.

It comes with GHC and some pre-installed packages including random.

Otherwise, instead, on Ubuntu:

  • Commands are case-sensitive.

    Write commands in lowercase.

  • Install Cabal:

    sudo apt install cabal-install
    
  • Install the random package:

    cabal update
    cabal install --lib random
    
  • Try and see if the package is available in GHCi:

    $ ghci
    ...
    Prelude> import System.Random
    Prelude System.Random> 
    

    The things to type are ghci and import System.Random.

    Remember, uppercase/lowercase matters.

Rafael
  • 3
  • 4
sshine
  • 15,635
  • 1
  • 41
  • 66
  • I tried to install the Haskell Platform again and it stay the same – jxz Nov 05 '20 at 16:35
  • Since Haskell Platform *does* have `System.Random`, maybe you are using your old Haskell installation and not the newly installed Haskell Platform. Try and uninstall both and reinstall Haskell Platform and try again. Or explore option 2: Start by noticing the typos you made and how I have corrected them and type them in exactly. Programming will be hard from here and on if you don't type things correctly. That means you can't switch uppercase and lowercase letters, you can't leave out words or switch their order, and you can't copy-paste random bits of text that happened to be nearby. – sshine Nov 05 '20 at 16:47
  • 1
    The explanation for the Ubuntu did work. I tried to re-install the Haskell Platform and it says the error again that the module System.Random can not be found – jxz Nov 05 '20 at 19:18
0

Answers like cabal install x and stack install y are outdated.

In 2023 you should use ghcup to install your Haskell toolchain and then use cabal new / stack new commands to create a project and a basic package layout for your needs.

Add all the necessary packages to its dependencies and they will be available when you do cabal repl / stack repl inside that project.

wiz
  • 499
  • 4
  • 17