Skip to main content

Haskell

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/haskell

In short

Haskell is a purely functional, statically typed language with lazy evaluation, known for its expressive type system and mathematically precise code.

What is Haskell?

Haskell is a general-purpose, purely functional programming language designed by a committee of researchers and first defined in 1990. It is named after the logician Haskell Curry. The language is standardized in the Haskell 2010 report, while in practice nearly all code targets the Glasgow Haskell Compiler (GHC), which adds many optional language extensions.

In Haskell, functions are pure by default: a function can't change variables or perform input and output unless its type says so, using the IO type. It uses lazy evaluation, meaning expressions are computed only when their values are actually needed, which allows elegant tricks like working with infinite lists. Its static type system infers most types automatically and uses type classes, such as Eq and Show, to describe behavior shared across types, similar to interfaces in other languages.

Haskell is used in compilers and programming language research, financial systems, static analysis tools and backend services where correctness matters. Many ideas now common in mainstream languages, such as type inference, pattern matching, algebraic data types and Option-style types for missing values, were refined in Haskell and its relatives. Writing Haskell is often compared to writing mathematical definitions: you describe what a value is, and the compiler checks that the pieces fit together.

Haskell is often compared with F# and OCaml, which are also statically typed functional languages with strong type inference. The key difference is that F# and OCaml evaluate expressions eagerly and allow side effects anywhere, while Haskell is lazy by default and tracks side effects in the type system, which makes it stricter and more distinctive to learn.

Key takeaways

  • Haskell is purely functional: side effects are tracked in the type system through types like IO.
  • It uses lazy evaluation, computing values only when they are needed.
  • Its static type system infers most types and uses type classes for shared behavior.
  • GHC is the compiler used for nearly all Haskell code.
  • Many modern language features were refined in Haskell and its relatives.

Example

Types, higher-order functions and laziness in Haskellhaskell
-- A type signature: takes a list of Ints, returns an Int
sumOfSquares :: [Int] -> Int
sumOfSquares xs = sum (map (^ 2) xs)

-- Lazy evaluation: an infinite list, only the needed part is computed
evens :: [Int]
evens = [0, 2 ..]

main :: IO ()
main = do
  print (sumOfSquares [1, 2, 3])  -- 14
  print (take 5 evens)            -- [0,2,4,6,8]

Readers ask

Why is Haskell called purely functional?

Because ordinary Haskell functions cannot have side effects. Actions like reading files or printing text are values of type IO that the runtime executes, so a function's type tells you whether it can affect the outside world.

Is Haskell used in industry?

Yes, though it's a niche choice. Companies use it for financial systems, compilers, developer tooling and backend services where strong correctness guarantees are worth the learning curve.

What is a monad in Haskell?

A monad is a pattern for chaining computations that carry extra context, such as possible failure (Maybe), multiple results (lists) or input and output (IO). Haskell's do notation is syntax for writing those chained steps in a readable, sequential style.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings