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
