Importing System.Random in Haskell

I need to generate random ints in my code but I can’t figure out how to import the package. I wrote this:

import System.Random (randomRIO)

but I keep getting an error.

Repl link: CMPT 383 Assignment 3 - Replit

1 Like


The problem is that your code wants to use the System.Random package, but Replit does not have that stored, so you need to install it using the Cabal package manager.

There is a template available that uses the Cabal package manager as a file, but I’ve never done it that way before, so I don’t know how it works.

The way I got working was I used Cabal with the command line instead. Go to the Shell (it’s next to the Console), and type:

cabal update
cabal install --lib random

random allows you to use System.Random

Hope this helps!