liveBook · Manning

Coarse-grained data model

As explained in Functional Design and Architecture: Examples in Haskell

A coarse-grained data model organizes mutable data into large units that must be replaced together during updates.

A coarse-grained data model places mutable values inside one large container, so changing an entry requires replacing or re-uploading the whole container. This simplifies the outer structure but can repeat costly updates under concurrency. section 8.2.2

The practical contrast is fine-grained mutability: separate inner MVars let updates target one value without altering the outer map. A coarse-grained map instead constructs new maps for repeated changes to the same key, increasing MVar updates. section 8.2.2

Map replacement versus nested mutability

With CoarseGrainedMap = MVar (Map Key Value), updating one key means re-uploading a new map. A nested structure such as MVar (Map Key (MVar Value)) can alter an inner value directly.

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Contrasts whole-map replacement with nested mutable values and defers a fuller treatment of coarse-grained versus fine-grained design.
Examples
Uses CoarseGrainedMap and a nested MVar map to contrast outer-container replacement with direct inner-value updates.
What you can do after
Evaluate update efficiency and concurrency trade-offs when choosing between coarse-grained and fine-grained mutable state.
How it connects
Connects data granularity to fine-grained data models, concurrency, STM, and MVar-based state.

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.