Chapter 7. Switch

This chapter covers

  • The last two core primitives: sample and switch
  • How to write video games in FRP

FRP code describes data flow in a directed graph structure, and until now those graphs have been static. Cells for storing state are constructed using the hold primitive, and the total number of them hasn’t been able to change as the program runs. switch allows you to change this structure dynamically. sample allows you to sample the value of a cell.

7.1. The sample primitive: getting a cell’s value

What you’re about to read may surprise you, coming from people as puritanical about compositionality as we are. Remember that in chapter 1 we talked about how people new to FRP will ask us, “How do you get the value?” We waved ...

Get Functional Reactive Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.