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).
Option 1: Installing via GHCup (Recommended)
- 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- 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-installVerification
Verify that GHC and Cabal are installed and accessible:
ghc --version
cabal --versionWriting and Running Code
Interactive REPL (GHCi)
Launch the interactive Glasgow Haskell Compiler REPL:
ghciEvaluate 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.hsCompiling to Native Binary
Compile the file into a standalone executable using ghc:
ghc -O2 hello.hs -o hello
./hello