Directing javascript with arrows (functional pearl)
Title | Directing javascript with arrows (functional pearl) |
Publication Type | Reports |
Year of Publication | 2008 |
Authors | Khoo YP, Hicks MW, Foster JS, Sazawal V |
Series Title | Technical Reports of the Computer Science Department |
Date Published | 2008/// |
Abstract | JavaScript, being a single-threaded language, makes extensive use of event-driven programming to enable responsive web applications. However, standard approaches to sequencing events are messy, and often lead to code that is difficult to understand and maintain. We have found that arrows, a generalization of monads, are an elegant solution to this problem. Arrows allow us to easily write asynchronous programs in small, modular units of code, and flexibly compose them in many different ways, while nicely abstracting the details of asynchronous program composition. In particular, we show how to use arrows to construct a variety of state machines, such as autoscrollers and drag-and-drop handlers. |