Skip to content
Sign upLog in
← Back to Community

System.Random in Haskell?

Profile icon

Hello. I'm a complete Haskell noob, so I'm probably missing something obvious here. I can't seem to import the System.Random module. I've tried import System.Random but it throws an error. The exact error is as follows:

Could not find module 'System.Random'
Use -v to see a list of the files searched for.
3 | import System.Random
| ^^^^^^^^^^^^^^^^^^^^
compiler exit status 1

Anyway, the module (is it a module?) was going to be used to select a random element from a list, detailed in list.hs
I think it may be possible to do it using the IO monad, but as I said earlier I don't really have any idea what I'm doing.
Any help would be greatly appreciated.

Edit 1:
On a related note, Go doesn't seem to want to import the "math/rand" package either! It throws an error saying that no metadata was found for the package. I think I'm seeing a pattern here...

Answered by JackFly26 [earned 5 cycles]
View Answer
Profile icon
Profile icon

System.Random isn't part of the base part of haskell; it's in the random package. You'll need to make a cabal project and run it after installing the random package.

Profile icon

looks like Repl simply doesn't have System.Random.