TIDE
Languages

Haskell

Installing Haskell and GHCup on Ubuntu in TIDE

Haskell

Haskell is an advanced, purely functional programming language with strong static typing, lazy evaluation, and powerful type inference. It is widely applied in computational science, compiler engineering, financial tech, and formal verification.

Installation

The official installer for Haskell toolchains is GHCup. It manages GHC (Glasgow Haskell Compiler), Cabal (the Haskell package manager), Stack, and HLS (Haskell Language Server).

  1. Install system development libraries required for compilation:
apt update
apt install -y build-essential curl libffi-dev libgmp-dev libncurses-dev libtinfo-dev zlib1g-dev git
  1. Run the non-interactive GHCup installer:
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
BOOTSTRAP_HASKELL_GHC_VERSION=recommended \
BOOTSTRAP_HASKELL_CABAL_VERSION=recommended \
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

source "$HOME/.ghcup/env"

To persist the environment variables, add source "$HOME/.ghcup/env" to your ~/.bashrc.

Option 2: Using System Packages (APT)

For a minimal GHC setup using Ubuntu repositories:

apt update
apt install -y ghc cabal-install

Verification

Verify that GHC and Cabal are installed and accessible:

ghc --version
cabal --version

Writing and Running Code

Interactive REPL (GHCi)

Launch the interactive Glasgow Haskell Compiler REPL:

ghci

Evaluate expressions inside GHCi:

Prelude> putStrLn "Hello from GHCi REPL!"

Type :q to exit.

Writing a Haskell Script

Create a file named hello.hs:

main :: IO ()
main = putStrLn "Hello, World from Haskell in TIDE!"

Interpreting Source Code Directly

Execute the file directly using runghc:

runghc hello.hs

Compiling to Native Binary

Compile the file into a standalone executable using ghc:

ghc -O2 hello.hs -o hello
./hello

Official Resources

On this page