Installing a Haskell package (System.Random) with cabal

As thousands of people no doubt have, I am learning Haskell through the Learn You a Haskell Tutorial, and I’ve reached the point where you’re supposed to use System.Random. I am coming at this question from a noobish perspective, I mostly have no idea what I’m doing. It seems that System.Random is something I would have to install. Based on some googling, it looks like the way you’re supposed to do that is generally through cabal, but I am having trouble figuring out how to get cabal working. If I make any cabal command I get a “command not installed. Multiple versions of this command were found in Nix” message, but whichever option I select, it ultimately ends up not allowing me to make progress. I have been floundering about trying to install cabal (assuming it’s not already installed) and/or System.Random and only become more confused as to what’s going on. Any guiding light would be very much appreciated.

Repl link/Link to where the bug appears:

**Screenshots, links, or other helpful context:


**

code snippet

After chose this option, you need type 2 commands:

1- cabal install --lib base
2- cabal install random

This issue may already be effectively closed due to timeframe, but I wanted to throw in an answer to help anyone who is using the new nix system and not knowing what to do as many examples online show installation of modules using cabal. If you are using the old cabal system, the following will likely not apply.

First and foremost, replit has put out a guide for installation of modules with nix using nodejs as an example. This can be found at the following url: NodeJS Example

Second, there may be some more specific things to worry about than the above article goes into. Nodejs is a standalone program, not just a haskell thing. Many haskell modules are actually part of haskellPackages (e.g. Data.List.Ordered would be found in the haskell package data-ordlist). Their instructions still work for how to find the module, I just wanted to point out that it must be prefixed with haskellPackages unlike nodejs.

Another thing to note is that when I tried this, I got an error along with others. Here is another individual trying to install JuicyPixel: Haskell, JuicyPixel. The solution for them was to use the haskellPackages.ghcWithPackages structure and call their package from there (e.g. (pkgs.haskellPackages.ghcWithPackages (pkgs: with pkgs; [ JuicyPixels]))) although this was not the suggested method from the replit example, it seemed to work for them.