liveBook · Manning

Simulation model

As explained in Functional Design and Architecture: Examples in Haskell

A simulation model is a computational representation of a system whose behavior can be executed and observed in a simulator.

A simulation model is an executable representation of a system whose behavior can be observed in a simulator. When business logic accesses mutable key–value state, the model must represent that state explicitly rather than treating the simulator as stateless. section 8.2.2

A stateful simulation model should make several design choices explicit:

  • Keep simulator state in memory when the real system would use an external key–value store. section 8.2.2
  • Use independently mutable values when concurrent updates should avoid replacing the entire map. section 8.2.2

Fine-grained simulated storage

A runtime can store a map from keys to independently mutable values: MVar (Map Key (MVar Value)). Updating one value then avoids rebuilding and replacing the whole map, unlike CoarseGrainedMap = MVar (Map Key Value).

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Explains state representation, interface completeness, mutability granularity, and concurrency, but stops short of a full simulator implementation.
Examples
Uses Store and Load operations, an in-memory nested-MVar map, and a coarse-grained map as a contrast.
What it assumes
Assumes familiarity with business logic and key–value storage while introducing simulator state and concurrent mutability.
What you can do after
Apply it by modeling external mutable state in memory and choosing update granularity appropriate for concurrent simulation.
How it connects
Connects simulation models with mutable state, key–value storage, concurrency, and interpreters.

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.