ABSTRACT
Severely resource-constrained devices present a confounding challenge to the functional programmer: we are used to having powerful abstraction facilities at our fingertips, but how can we make use of these tools on a device with an 8- or 16-bit CPU and at most tens of kilobytes of RAM? Motivated by this challenge, we have developed Flask, a domain specific language embedded in Haskell that brings the power of functional programming to sensor networks, collections of highly resource-constrained devices. Flask consists of a staging mechanism that cleanly separates node-level code from the meta-language used to generate node-level code fragments; syntactic support for embedding standard sensor network code; a restricted subset of Haskell that runs on sensor networks and constrains program space and time consumption; a higher-level "data stream" combinator library for quickly constructing sensor network programs; and an extensible runtime that provides commonly-used services.
We demonstrate Flask through several small code examples as well as a compiler that generates node-level code to execute a network-wide query specified in a SQL-like language. We show how using Flask ensures constraints on space and time behavior. Through microbenchmarks and measurements on physical hardware, we demonstrate that Flask produces programs that are efficient in terms of CPU and memory usage and that can run effectively on existing sensor network hardware.
Supplemental Material
Available for Download
Supplemental material for: Flask: staged functional programming for sensor networks
- Andreas M. Ali, Kung Yao, Travis C. Collier, Charles E. Taylor, Daniel T. Blumstein, and Lewis Girod. An empirical study of collaborative acoustic source localization. In IPSN '07, pages 41--50, 2007. Google Scholar
Digital Library
- Amol Bakshi, Viktor K. Prasanna, Jim Reich, and Daniel Larner. The abstract task graph: A methodology for architecture-independent programming of networked sensor systems. In Proc. Workshop on End-to-End, Sense-and-Respond Systems, Applications, and Services, pages 19--24, 2005a. Google Scholar
Digital Library
- Amol Bakshi, Viktor K. Prasanna, Jim Reich, and Daniel Larner. The abstract task graph: a methodology for architecture-independent programming of networked sensor systems. In EESR '05: Proceedings of the 2005 workshop on End-to-end, sense-and-respond systems, applications and services, pages 19--24, Berkeley, CA, USA, 2005b. USENIX Association. Google Scholar
Digital Library
- Elaine Cheong, Judith Liebman, Jie Liu, and Feng Zhao. TinyGALS: A programming model for event-driven embedded systems. In SAC, pages 698--704, 2003. Google Scholar
Digital Library
- Koen Claessen and John Hughes. Quickcheck: a lightweight tool for random testing of haskell programs. In ICFP '00: Proceedings of the fifth ACM SIGPLAN international conference on Functional programming, pages 268--279, New York, NY, USA, 2000. ACM. Google Scholar
Digital Library
- Antony Courtney and Conal Elliott. Genuinely functional user interfaces. In 2001 Haskell Workshop, September 2001.Google Scholar
- Conal Elliott and Paul Hudak. Functional reactive animation. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP '97), volume 32(8), pages 263--273. ACM, August 1997. Google Scholar
Digital Library
- David Gay, ilip Levis, J. Robert von Behren, Matt Welsh, Eric A. Brewer, and David E. Culler. The nesC language: A holistic approach to networked embedded systems. In Proc. Programming Language Design and Implementation (PLDI '03), pages 1--11. ACM, 2003. Google Scholar
Digital Library
- Omprakash Gnawali, Ki-Young Jang, Jeongyeup Paek, Marcos Vieira, Ramesh Govindan, Ben Greenstein, August Joki, Deborah Estrin, and Eddie Kohler. The Tenet architecture for tiered sensor networks. In SenSys '06: Proceedings of the 4th international conference on Embedded networked sensor systems, pages 153--166, New York, NY, USA, 2006. ACM Press. Google Scholar
Digital Library
- Michael Gordon, William Thies, Michal Karczmarek, Jasper Lin, Ali S. Meli, Christopher Leger, Andrew A. Lamb, Jeremy Wong, Henry Hoffman, David Z. Maze, and Saman Amarasinghe. A stream compiler for communication-exposed architectures. In ASPLOS '02, 2002. Google Scholar
Digital Library
- E. Goto. Monocopy and associative algorithms in an extended LISP. Technical Report 74-03, Univ. of Tokyo, Information Science Lab., May 1974.Google Scholar
- Ramakrishna Gummadi, Omprakash Gnawali, and Ramesh Govindan. Macro-programming wireless sensor networks using Kairos. In Proc. DCOSS'05, 2005. Google Scholar
Digital Library
- Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David E. Culler, and Kristofer S. J. Pister. System architecture directions for networked sensors. In ASPLOS '00, pages 93--104, 2000. Google Scholar
Digital Library
- Paul Hudak, Antony Courtney, Henrik Nilsson, and John Peterson. Arrows, robots, and functional reactive programming. In Summer School on Advanced Functional Programming 2002, Oxford University, volume 2638 of Lecture Notes in Computer Science, pages 159--187. Springer-Verlag, 2003.Google Scholar
- John Hughes. Generalising monads to arrows. Sci. Comput. Program, 37 (1-3): 67--111, 2000. Google Scholar
Digital Library
- John Hughes. Programming with arrows. In Advanced Functional Programming, volume 3622 of Lecture Notes in Computer Science, pages 73--129. Springer, 2004. Google Scholar
Digital Library
- Graham Hutton. Higher-order functions for parsing. Journal of Functional Programming, 2 (3): 323--343, July 1992.Google Scholar
Cross Ref
- Simon L. Peyton Jones and Simon Marlow. Secrets of the glasgow haskell compiler inliner. J. Funct. Program, 12 (4&5): 393--433, 2002. Google Scholar
Digital Library
- Simon L. Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. Simple unification-based type inference for GADTs. In Proceedings of the 11th ACM SIGPLAN International Conference on Functional Programming, ICFP '06, pages 50--61. ACM, 2006. Google Scholar
Digital Library
- Simon Peyton Jones, Jean-Marc Eber, and Julian Seward. Composing contracts: an adventure in financial engineering (functional pearl). ACM SIGPLAN Notices, 35 (9): 280--292, 2000. Google Scholar
Digital Library
- Nupur Kothari, Ramakrishna Gummadi, Todd Millstein, and Ramesh Govindan. Reliable and efficient programming abstractions for wireless sensor networks. In Proceedings of the 2007 ACM SIGPLAN conference on Programming language design and implementation (PLDI '07), pages 200--210, 2007. Google Scholar
Digital Library
- Philip Levis, David Gay, and David Culler. Active sensor networks. In NSDI '05: Proceedings of the Second USENIX/ACM Symposium on Networked System Design and Implementation, 2005. Google Scholar
Digital Library
- Liqian Lu, Tian He, Tarek Abdelzaher, and John Stankovic. Design and comparison of lightweight group management strategies in EnviroSuite. In Proc. International Conference on Distributed Computing in Sensor Networks (DCOSS), Marina Del Rey, CA, June 2005. Google Scholar
Digital Library
- Samuel Madden, Michael J. Franklin, Joseph M. Hellerstein, and Wei Hong. TinyDB: an acquisitional query processing system for sensor networks. ACM Transactions on Database Systems, 30 (1): 122--173, 2005. Google Scholar
Digital Library
- Geoffrey Mainland. Why it's nice to be quoted: quasiquoting for haskell. In Haskell '07: Proceedings of the ACM SIGPLAN workshop on Haskell workshop, pages 73--82, New York, NY, USA, 2007. ACM. Google Scholar
Digital Library
- Ryan Newton, Greg Morrisett, and Matt Welsh. The regiment macroprogramming system. In Proc. IPSN '07, 2007. Google Scholar
Digital Library
- Ryan Newton, Lewis Girod, Michael Craig, Sam Madden, and Greg Morrisett. Wavescript: A case-study in applying a distributed stream-processing language. Technical Report MIT-CSAIL-TR-2008-005, MIT CSAIL, 2008.Google Scholar
- Henrik Nilsson, Antony Courtney, and John Peterson. Functional reactive programming, continued. In Proceedings of the 2002 ACM SIGPLAN Haskell Workshop (Haskell'02), pages 51--64, Pittsburgh, Pennsylvania, USA, October 2002. ACM Press. Google Scholar
Digital Library
- Izzet Pembeci, Henrik Nilsson, and Greogory Hager. Functional reactive robotics: An exercise in principled integration of domain-specific languages. In PPDP '02, October 2002. Google Scholar
Digital Library
- John Peterson, Paul Hudak, and Conal Elliott. Lambda in motion: Controlling robots with Haskell. Lecture Notes in Computer Science, 1551: 91--105, 1999. Google Scholar
Digital Library
- Tim Sheard and Simon Peyton Jones. Template metaprogramming for Haskell. In Manuel M. T. Chakravarty, editor, ACM SIGPLAN Haskell Workshop 02, pages 1--16. ACM Press, October 2002. Google Scholar
Digital Library
- Jacob Sorber, Alexander Kostadinov, Matthew Garber, Matthew Brennan, Mark D. Corner, and Emery D. Berger. Eon: a language and runtime system for perpetual systems. In Proc. SenSys '07, pages 161--174, New York, NY, USA, 2007. ACM. ISBN 978-1-59593-763-6. Google Scholar
Digital Library
- Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. System F with type equality coercions. In TLDI '07: Proceedings of the 2007 ACM SIGPLAN international workshop on Types in languages design and implementation, pages 53--66, 2007. Google Scholar
Digital Library
- Walid Taha. Multi-stage programming: Its theory and applications. Technical Report CSE-99-TH-002, Oregon Graduate Institute of Science and Technology, 1999. Google Scholar
Digital Library
- Walid Taha and Tim Sheard. MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science, 248 (1--2): 211--242, 2000. Google Scholar
Digital Library
- Ben Titzer, Daniel K. Lee, and Jens Palsberg. Avrora: scalable sensor network simulation with precise timing. In Fourth International Symposium on Information Processing in Sensor Networks (IPSN '05), pages 477--482, 2005. Google Scholar
Digital Library
- Z. Wan, W. Taha, and P. Hudak. Real-time FRP. In International Conference on Functional Programming (ICFP '01), Florence, Italy, September 2001a. Google Scholar
Digital Library
- Zhanyong Wan. Functional Reactive Programming for Real-Time Reactive Systems. .d. dissertation, Computer Science Department, Yale University, October 2002. Google Scholar
Digital Library
- Zhanyong Wan, Walid Taha, and Paul Hudak. Event-driven FRP. Lecture Notes in Computer Science, 2257: 155+, 2001b. Google Scholar
Digital Library
- Stephen Weeks, Matthew Fluet, Henry Cejtin, and Suresh Jagannathan. http://www.mlton.org/.Google Scholar
- Geoff Werner-Allen, Jeff Johnson, Mario Ruiz, Jonathan Lees, and Matt Welsh. Monitoring volcanic eruptions with a wireless sensor network. In Proc. Second European Workshop on Wireless Sensor Networks (EWSN '05), January 2005a.Google Scholar
Cross Ref
- Geoff Werner-Allen, Pat Swieskowski, and Matt Welsh. Motelab: A wireless sensor network testbed. In Proc. Fourth International Conference on Information Processing in Sensor Networks (IPSN'05), Special Track on Platform Tools and Design Methods for Network Embedded Sensors (SPOTS), April 2005b. Google Scholar
Digital Library
- Geoff Werner-Allen, Konrad Lorincz, Jeff Johnson, Jonathan Lees, and Matt Welsh. Fidelity and yield in a volcano monitoring sensor network. In Proc. 7th USENIX OSDI, Seattle, WA, Nov 2006. Google Scholar
Digital Library
- Kamin Whitehouse, Feng Zhao, and Jie Liu. Semantic Streams: a framework for declarative queries and automatic data interpretation. Technical Report MSR-TR-2005-45, Microsoft Research, One Microsoft Way, Redmond, WA 98052, April 2005.Google Scholar
- Kamin Whitehouse, Jie Liu, and Feng Zhao. Semantic Streams: a framework for composable inference over sensor data. In Proc. Third European Workshop on Wireless Sensor Networks (EWSN), Zurich, Switzerland, February 2006. Google Scholar
Digital Library
- Hongwei Xi, Chiyan Chen, and Gang Chen. Guarded recursive datatype constructors. POPL '03, 2003. Google Scholar
Digital Library
- Ning Xu, Sumit Rangwala, Krishna Kant Chintalapudi, Deepak Ganesan, Alan Broad, Ramesh Govindan, and Deborah Estrin. A wireless sensor network for structural monitoring. In SenSys '04, pages 13--24, 2004. Google Scholar
Digital Library
Index Terms
Flask: staged functional programming for sensor networks
Recommendations
Flask: staged functional programming for sensor networks
ICFP '08Severely resource-constrained devices present a confounding challenge to the functional programmer: we are used to having powerful abstraction facilities at our fingertips, but how can we make use of these tools on a device with an 8- or 16-bit CPU and ...







Comments