liveBook · Manning

Concurrency

As explained in Functional Design and Architecture: Examples in Haskell

A programming technique for structuring multiple computations whose execution can overlap in time.

Concurrency structures applications whose parts can react independently and execute with overlapping activity. An actor-based simulator may give each part its own thread, while preserving concurrent behavior even in a single-threaded implementation. section 8.0

Treat concurrent design as an architectural problem because interactions among threads and shared mutable state create several failure modes:

  • Race conditions can corrupt shared data or leave it invalid. section 9.1.1
  • Deadlocks and livelocks can stop useful progress, while starvation can leave available threads unused. section 9.1.1
  • Poor resource management can cause unclear lifetimes, leaks, overflow, and incorrect exception handling. section 9.1.1

Prefer structures that make concurrent behavior readable and maintainable. Composable software transactional memory reduces multithreading complexity, while IORefs, MVars, and STM TVars provide distinct state-handling choices. TVars are thread-safe and transactional; bare threads remain limited resources that require safe organization. section 9.1 section 9.3

Reactive simulator and application framework

A reactive simulator can assemble independent actor-like parts with concurrent state. A broader framework can place business logic in free monads, expose STM as an interface, and use STM at the implementation layer for safe concurrency. section 8.0 section 9.3

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Explains major failure modes and compares STM with bare threads, while stopping short of comprehensive multithreading pitfalls and implementation internals.
Examples
Uses a reactive simulator, actor-like components, concurrent web servers, command-line applications, and STM-backed framework state.
What it assumes
Assumes familiarity with threads and application architecture while teaching concurrency hazards, state choices, and safe organization explicitly.
What you can do after
Build it from scratch by selecting state mechanisms, organizing threads safely, and incorporating STM into maintainable application architecture.
How it connects
Connects concurrency with the actor model, reactive programming, shared mutable state, software transactional memory, and free monads.

Also explained in

Compare how 23 books explain concurrency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.