Functional Reactive Programming

Afp0405
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. An implementation of this concept is Yampa.

Papers

paper use
Arrows, Robots, and Functional Reactive Programming Paul Hudak, Antony Courtney, Henrik Nilsson and John Peterson, 2002 covers most of the presentation inculding AFrob (robots)
Functional Reactive Programming, Continued Henrik Nilsson, Antony Courtney and John Peterson, 2002 dynamic collections - read it if you want to know more of AFP. For an alternative example see next paper
The Yampa Arcade Antony Courtney, Henrik Nilsson and John Peterson, 2003 describes an example application witch uses dynamic collections

  • For more info about Arrows take a look at the page of HaskellArrows or at http://www.haskell.org/arrows/
  • If you want to see the robot examples go to the Yampa page and download and compile the package. This is not easy.
    • Best changes are with Linux and GHC5 (with profiling libraries) and GreenCard.
    • If you have HGL you don't need GreenCard (you can find a binary at http://www.haskell.org/greencard/).
    • If you don't have Profiling you need to remove the profiling option in the Makefile
    • One of the installs fails because it tries to install a file twice. To fix, open the Makefile and remove the source file from the list of sources, and run make install again.
    • If you use windows. Good luck! (I hope you have an working HGL)

Assignment

Extend rcFollowWall (defined at slide 35) so that the robot turns right when the wall makes a corner to the right. you can use any function shown in the papers or slides.

  • use the range finder to find the distance to the wall in front of you (slide 34)
  • define tooClose, notTooClose :: Distance -> SF RobotInput (Event ())
  • use 'switch' to switch behavior between follow the wall or turn (slide 15)
  • use a second 'switch' to switch from turning to following the wall again (slide 15)
  • when you are stuck, make a drawing of the signal functions
  • feel free to contact me at cddouma@cs.uu.nl

note that instead of the two switches you can use a drSwitch but it needs more understanding.

Results

name result
9952330 +
0019593 []
0054445 []
Arjan Oosting +
Joost Verhoog -
Mart Kolthof []
Niels van der Velden +
Peter Nagel -
Robert van Herk -

Common mistake: mrFinalize (ddVelTR v (lim 0.2 omega)) is not a Signal Function. So you cannot pass it to switch.

Errata

slide 8
type of first is: SF a b -> SF (a,c) (b,c)
slide 12
type of constant is: b -> SF a b
slide 15
replace && with &&&

-- DoumaCD - 22 Sep 2003

Topic attachments
I Attachment Action Size Date Who Comment
pdfpdf frp.pdf manage 8671.9 K 21 Oct 2003 - 07:36 DoumaCD Presentation (PDF, big!)
pptppt frp.ppt manage 184.0 K 21 Oct 2003 - 07:35 DoumaCD Presentation (PowerPoint, hopefully)
elsesxi frp.sxi manage 107.4 K 21 Oct 2003 - 07:34 DoumaCD Presentation (OpenOffice Impress)