Arrows, Robots, and Functional Reactive Programming

Functional reactive programming, or FRP, is a paradigm for programming hybrid systems – i.e., systems containing a combination of both continuous and discrete components – in a high-level, declarative way. The key ideas in FRP are its notions of continuous, time-varying values, and time-ordered sequences of discrete events. Yampa is an instantiation of FRP as a domain-specific language embedded in Haskell. This paper describes Yampa in detail, and shows how it can be used to program a particular kind of hybrid system: a mobile robot. Because performance is critical in robotic programming, Yampa uses arrows (a generalization of monads) to create a disciplined style of programming with time-varying values that helps ensure that common kinds of timeand space-leaks do not occur. No previous experience with robots is expected of the reader, although a basic understanding of physics and calculus is assumed. No knowledge of arrows is required either, although we assume a good working knowledge of Haskell. This paper is dedicated in memory of Edsger W. Dijkstra for his influential insight that mathematical logic is and must be the basis for sensible computer program construction.

[1]  Henrik Nilsson,et al.  Functional reactive programming, continued , 2002, Haskell '02.

[2]  Paul Hudak,et al.  Lambda in Motion: Controlling Robots with Haskell , 1999, PADL.

[3]  Paul Hudak The Haskell School of Expression: Learning Functional Programming through Multimedia , 1999 .

[4]  Michael R. M. Jenkin,et al.  Computational principles of mobile robotics , 2000 .

[5]  Ross Paterson,et al.  A new notation for arrows , 2001, ICFP '01.

[6]  Conal Elliott,et al.  Functional Implementations of Continuous Modeled Animation (Expanded Version) , 1998 .

[7]  Richard S. Bird,et al.  A calculus of functions for program derivation , 1990 .

[8]  Antony Courtney,et al.  Genuinely Functional User Interfaces , 2001 .

[9]  Paul Hudak,et al.  Prototyping real-time vision systems: an experiment in DSL design , 1999, Proceedings of the 1999 International Conference on Software Engineering (IEEE Cat. No.99CB37002).

[10]  Paul Hudak,et al.  A language for declarative robotic programming , 1999, Proceedings 1999 IEEE International Conference on Robotics and Automation (Cat. No.99CH36288C).

[11]  Paul Hudak,et al.  Event-Driven FRP , 2002, PADL.

[12]  Paul Hudak,et al.  Real-time FRP , 2001, ICFP '01.

[13]  Paul Hudak,et al.  Functional reactive programming from first principles , 2000, PLDI '00.

[14]  Paul Hudak,et al.  Functional reactive animation , 1997, ICFP '97.

[15]  John Hughes,et al.  Generalising monads to arrows , 2000, Sci. Comput. Program..

[16]  Gregory D. Hager,et al.  Functional reactive robotics: an exercise in principled integration of domain-specific languages , 2002, PPDP '02.