Haskell

The Glasgow Haskell Compiler (ghc)

Installation

Ubuntu
apt install ghc
Alma Linux
dnf install ghc
Source Code

required ghc

# Download ghc-{version}-src.tar.xz from https://www.haskell.org
tar xJf ghc-{version}-src.tar.xz
cd ghc-{version}
./boot 
./configure [options]... [VAR=VALUE]...
make
make install

Examples

Fibonacci Numbers
-- Fibonacci Numbers
import System.Environment (getArgs)

fib :: Int -> Int
    fib 0 = 0
    fib 1 = 1
    fib n = fib(n - 2) + fib(n - 1)

main = do
    argv <- getArgs
    let n = read (argv !! 0) :: Int
    print $ fib n

{-
    example
        compile:
            ghc -O -o fib_hs fib.hs
        run:
            ./fib_hs 39
-}