Skip to content
BENIBIX Learn

Haskell

Development🔤 LanguagesPopular Languages

Also known as Haskell Language, Haskell Programming

A language where code works like maths and types are checked first.

Think of it like

It is like a maths book that a computer can run.

Example

Lucy writes a function to square a number in Haskell, then maps it over a list. The result is [1,4,9].

Why it matters

Many ideas in newer languages were tried in Haskell first. Map and pattern matching are two of them.

Definition

Haskell is a purely functional programming language. Its functions work like maths: the same input always gives the same output, and nothing else changes. Every value has a type, checked before the program runs. The compiler can often work out the types for you. It is lazy, so it only works out a value when it is needed. It is loved for teaching and for code that must be right.

Example code

haskell
square x = x * x
main = print (map square [1, 2, 3])   -- [1,4,9]
Square each number in a list, with no loop in sight.
Haskell sits on the functional shelf, by the list arrow.

Common mistake

Trying to change a variable. In Haskell values do not change, so you make a new one instead.

Key takeaways

  1. 1
    Pure functions. Same input, same output.
  2. 2
    Strong types. Checked before it runs.
  3. 3
    Lazy. Work is done only when needed.

Learn it properly