Flask: staged functional programming for sensor networks

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.

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

[2]  Lewis Girod,et al.  WaveScript: A Case-Study in Applying a Distributed Stream-Processing Language , 2008 .

[3]  Kamin Whitehouse,et al.  Semantic Streams: A Framework for Composable Semantic Interpretation of Sensor Data , 2006, EWSN.

[4]  Michio Sugeno,et al.  Advances in Soft Computing — AFSS 2002 , 2002, Lecture Notes in Computer Science.

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

[6]  Gang Chen,et al.  Guarded recursive datatype constructors , 2003, POPL '03.

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

[8]  Paul Hudak,et al.  Functional reactive programming for real-time reactive systems , 2002 .

[9]  Simon L. Peyton Jones,et al.  Simple unification-based type inference for GADTs , 2006, ICFP '06.

[10]  Matt Welsh,et al.  Fidelity and yield in a volcano monitoring sensor network , 2006, OSDI '06.

[11]  Ramesh Govindan,et al.  Macro-programming Wireless Sensor Networks Using Kairos , 2005, DCOSS.

[12]  Andreas M. Ali,et al.  An Empirical Study of Collaborative Acoustic Source Localization , 2007, 2007 6th International Symposium on Information Processing in Sensor Networks.

[13]  Geoffrey Mainland Why it's nice to be quoted: quasiquoting for haskell , 2007, Haskell '07.

[14]  Deborah Estrin,et al.  A wireless sensor network For structural monitoring , 2004, SenSys '04.

[15]  M. Welsh,et al.  The Regiment Macroprogramming System , 2007, 2007 6th International Symposium on Information Processing in Sensor Networks.

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

[17]  Matt Welsh,et al.  MoteLab: a wireless sensor network testbed , 2005, IPSN '05.

[18]  Graham Hutton,et al.  Higher-order functions for parsing , 1992, Journal of Functional Programming.

[19]  David E. Culler,et al.  Active sensor networks , 2005, NSDI.

[20]  Robert Szewczyk,et al.  System architecture directions for networked sensors , 2000, ASPLOS IX.

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

[22]  Mark D. Corner,et al.  Eon: a language and runtime system for perpetual systems , 2007, SenSys '07.

[23]  Tarek F. Abdelzaher,et al.  Design and Comparison of Lightweight Group Management Strategies in EnviroSuite , 2005, DCOSS.

[24]  Henry Hoffmann,et al.  A stream compiler for communication-exposed architectures , 2002, ASPLOS X.

[25]  Todd Millstein,et al.  Kairos: a macro-programming system for wireless sensor networks , 2005, SOSP '05.

[26]  Simon L. Peyton Jones,et al.  Composing contracts: an adventure in financial engineering (functional pearl) , 2000, ICFP '00.

[27]  Jens Palsberg,et al.  Avrora: scalable sensor network simulation with precise timing , 2005, IPSN 2005. Fourth International Symposium on Information Processing in Sensor Networks, 2005..

[28]  Feng Zhao,et al.  TinyGALS: a programming model for event-driven embedded systems , 2003, SAC '03.

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

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

[31]  John Hughes Programming with Arrows , 2004, Advanced Functional Programming.

[32]  Viktor K. Prasanna,et al.  The Abstract Task Graph: a methodology for architecture-independent programming of networked sensor systems , 2005, EESR '05.

[33]  Paul Hudak,et al.  Arrows, Robots, and Functional Reactive Programming , 2002, Advanced Functional Programming.

[34]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[35]  Walid Taha,et al.  Multi-Stage Programming: Its Theory and Applications , 1999 .

[36]  Jie Liu,et al.  Semantic Streams: a Framework for Declarative Queries and Automatic Data Interpretation , 2005 .

[37]  Simon L. Peyton Jones,et al.  System F with type equality coercions , 2007, TLDI '07.

[38]  Matt Welsh,et al.  Monitoring volcanic eruptions with a wireless sensor network , 2005, Proceeedings of the Second European Workshop on Wireless Sensor Networks, 2005..

[39]  Ramesh Govindan,et al.  Reliable and efficient programming abstractions for wireless sensor networks , 2007, PLDI '07.

[40]  Simon L. Peyton Jones,et al.  Secrets of the Glasgow Haskell Compiler inliner , 2002, Journal of Functional Programming.

[41]  Wei Hong,et al.  TinyDB: an acquisitional query processing system for sensor networks , 2005, TODS.

[42]  Deborah Estrin,et al.  The Tenet architecture for tiered sensor networks , 2006, SenSys '06.

[43]  Walid Taha,et al.  MetaML and multi-stage programming with explicit annotations , 2000, Theor. Comput. Sci..