Saltar al contenido ForoHackers

Haskell: start here

Haskell
#571 · Ophuscado · · Denunciar

Haskell is a purely functional, lazily evaluated language with a powerful static type system. Side effects are tracked in types, so most of a program is pure and easy to reason about. It is a research and teaching favourite and a source of ideas that other languages borrow, and it is used in compilers, finance and tools where correctness matters.

Key concepts

  • Purity: functions have no side effects; effects such as input and output appear in the type.
  • Laziness: expressions are evaluated only when their value is needed, allowing infinite structures and new control forms.
  • Type inference and algebraic data types: the compiler infers most types; data is built from sums and products.
  • Type classes: overloaded behaviour defined per type, the basis of Functor, Monad and friends.
  • Monads and effects: a general interface for sequencing computations with context.
  • Immutability and recursion: no loops with mutable counters; folds and recursion instead.

Vocabulary

  • Monad: a type with operations to sequence steps that carry context, such as failure or state.
  • Thunk: a delayed computation waiting to be evaluated.
  • Point-free style: defining functions by composition without naming arguments.
  • Cabal and Stack: build and package tools for Haskell projects.

What to study, in order

  1. Expressions, functions, lists and recursion in the interactive interpreter.
  2. Types, type signatures, data declarations and pattern matching.
  3. Higher-order functions, folds and list comprehensions on small problems.
  4. Type classes, Maybe and Either, then Functor, Applicative and Monad.
  5. Input and output, and a small program such as a parser or a text tool.
  6. Laziness and its costs: space leaks and how to find them.

Related tags

#functional-programming #type-theory #ocaml #compilers

Inicia sesión o únete para responder.