Getting started

Haskell is a compiled, statically typed, purely functional language, and these twelve lessons put the compiler on the machine and a first program through it. They cover what the language is and where it runs, the install of GHC and cabal, the interactive shell, the first build and the exit status it returns, then functions and signatures, the numeric types, and the conditional that closes the part. Every later lesson assumes the toolchain of this one.

1.1 What Haskell is and where it runs purity, laziness and types before run time, the native binary, ghc and the first program Open 1.2 Install GHC and cabal the packages per system and the install pages, ghcup in words, PATH, ghc --version, ghc-pkg list, the version this course uses Open 1.3 GHCi: the interactive shell :load, :reload, :type, :info, :set, the transcript a reader can rerun Open 1.4 runghc, ghc and the exit status the interpreter against the compiler, the artefacts of a build, exitWith and $? Open 1.5 Your first program module Main (main) where, main :: IO (), putStr and putStrLn, the build and the run Open 1.6 Warnings, errors and -Wall unused imports and bindings, -Werror, a type error and its GHC code Open 1.7 Functions, application and layout definitions, application, parentheses, backticks, the offside rule Open 1.8 Types and type signatures every binding has a type, polymorphism, String is [Char], a wrong signature Open 1.9 Int, Integer, Double and defaulting machine integers, arbitrary precision, floats, div and mod against quot and rem, fromIntegral, type defaulting Open 1.10 Char, String and Bool character literals, escapes, Data.Char, ++, comparisons, && and ||, not Open 1.11 Tuples pair types, fst and snd, zip and unzip, a tuple as a result, the arity limit Open 1.12 if, guards and pattern guards if then else, guarded equations, otherwise, a pattern guard, the hlint rewrite Open

Lessons