This repository contains a Haskell implementation of the Miller-Rabin primality test. This README provides instructions for students who may not have used Haskell before, guiding them through the process of running the Main.hs file.
To run the Haskell code, you need:
-
Haskell Toolchain:
- Install the Haskell Platform or the GHC (Glasgow Haskell Compiler).
- Alternatively, install
Stackfor managing Haskell projects (optional, not required for this guide).
-
A Text Editor or IDE:
- You can use any text editor (e.g., VS Code, Sublime Text, or even Notepad++).
- For a Haskell-specific environment, consider Haskell Language Server.
-
Clone the Repository:
git clone https://github.com/tjeong117/haskell.git cd miller-rabin -
Install GHC (If Not Already Installed):
- On Windows: Download the installer from the Haskell Platform.
- On macOS/Linux:
Use a package manager:
# macOS brew install ghc # Linux (Debian/Ubuntu) sudo apt install ghc
-
Run the Program:
runghc Main.hs
This command will interpret and run the
Main.hsfile without compiling it. -
Optional: Compile the Program: If you want to compile the program for faster execution:
ghc -o miller-rabin Main.hs ./miller-rabin
When you run the program, you may be prompted to input a number to test its primality. For example:
$ runghc Main.hs
Enter a number to check for primality: 17
17 is a prime number.- GHC not found: Ensure
ghcis installed and added to your system's PATH. - Dependencies missing: If your program uses libraries not included in GHC by default, you may need
cabalorstackto install them.
Feel free to open an issue if you encounter any problems or have questions!
