Welcome to my Haskell repository! This repository contains various Haskell programs.
To run Haskell programs, you'll need to have Haskell installed on your system. The most common way to run Haskell code is by using the Glasgow Haskell Compiler (GHC).
If you haven't installed GHC yet, you can do so by following these steps:
-
Linux:
- You can typically install GHC using your package manager. For example, on Ubuntu, you can run:
$ sudo apt-get update $ sudo apt-get install ghc
- You can typically install GHC using your package manager. For example, on Ubuntu, you can run:
-
macOS:
- You can install GHC using Homebrew. If you haven't installed Homebrew yet, follow the instructions on brew.sh, then run:
$ brew update $ brew install ghc
- You can install GHC using Homebrew. If you haven't installed Homebrew yet, follow the instructions on brew.sh, then run:
-
Windows:
- You can download the GHC installer from the official GHC website and follow the installation instructions.
Once you have GHC installed, you can compile and run Haskell programs from the command line.
-
Write your Haskell program: Create a
.hsfile containing your Haskell code. For example, let's say you have a program calledhello.hswith the following content:main :: IO () main = putStrLn "Hello, world!"
-
Compile your Haskell program: Open a terminal or command prompt, navigate to the directory containing your Haskell file, and run the following command:
$ ghc -o hello hello.hsThis command tells GHC to compile
hello.hsand produce an executable namedhello. -
Run your Haskell program: After compiling successfully, you can run the executable:
$ ./helloYou should see the output: Hello, world!