8 Reactive applications

This chapter covers

  • The actor model and how to design it
  • The MVar Request–Response pattern
  • How to create a stateful concurrent simulator
  • More information on reactive architectures

Looking back at the work we have done so far, we can be proud of ourselves. We have learned a lot, discussed many interesting ideas in software design, and tackled a variety of engineering problems. The solutions and approaches we’ve explored are all part of functional declarative design—a methodology for building applications from end to end in functional languages. This chapter provides the final proof that the methodology really works. We’re going to assemble many parts of our Andromeda software and produce its final result—the simulator. I promised we’d do it, and here we are!

This is a good time to talk about reactive applications. Our simulator is an application with individual parts that are able to react to something. “Individual” here means that the parts will have their own threads, and they will act as small, separate applications. In other words, this chapter will slightly touch on a specific reactive model of interactions—namely, the actor model.

8.1 Actor model

8.1.1 Simulation of actors

8.1.2 The architecture of the simulator

8.1.3 The MVar Request–Response pattern

8.2 Implementing the simulator

8.2.1 Simulator as an actor

8.2.2 Stateful simulation model

Summary