liveBook · Manning

Purely functional language

As explained in Learn Haskell by Example

A pure functional programming language is a language in which computations are primarily expressed through functions without observable side effects.

A purely functional language expresses computation through functions that behave like mathematical functions: they consume supplied input, produce output, and have no side effects. Because a function depends only on its inputs, reading the code is enough to analyze its behavior more reliably. section 1.1.1 section 1.5

Purity excludes interactions with state outside the function, including:

  • Reading or writing files, network sockets, databases, threads, or other processes. section 1.2.2
  • Using values that change between accesses, such as random numbers or the current time. section 1.2.2
  • Reading from or writing directly to memory. section 1.2.2
  • Controlling necessary effects through software design patterns; Haskell uses monadic programming for this purpose. section 1.2.2

Purity encourages safe, composable, and declarative code: programs describe intermediate results rather than a sequence of instructions. Haskell combines this model with compilation, garbage collection, and libraries for concurrency and parallelism, while leaving memory-management details to the runtime. section 1.1.1 section 1.5

How Learn Haskell by Example covers it

How deep it goes
Defines side effects and lists prohibited interactions, then points to monadic programming without developing its implementation.
Examples
Uses files, networks, databases, changing values, threads, processes, and direct memory access as excluded side-effect examples.
What you can do after
Evaluate functions as input-output transformations and recognize when an operation requires controlled effect handling.
How it connects
Connects purity with pure functions, side effects, monadic programming, declarative programming, concurrency, and parallelism.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.