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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.