skip to main content
10.1145/1411204.1411251acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Flask: staged functional programming for sensor networks

Published:20 September 2008Publication History

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.

Skip Supplemental Material Section

Supplemental Material

Video

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. Antony Courtney and Conal Elliott. Genuinely functional user interfaces. In 2001 Haskell Workshop, September 2001.Google ScholarGoogle Scholar
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. E. Goto. Monocopy and associative algorithms in an extended LISP. Technical Report 74-03, Univ. of Tokyo, Information Science Lab., May 1974.Google ScholarGoogle Scholar
  12. Ramakrishna Gummadi, Omprakash Gnawali, and Ramesh Govindan. Macro-programming wireless sensor networks using Kairos. In Proc. DCOSS'05, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle Scholar
  15. John Hughes. Generalising monads to arrows. Sci. Comput. Program, 37 (1-3): 67--111, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. John Hughes. Programming with arrows. In Advanced Functional Programming, volume 3622 of Lecture Notes in Computer Science, pages 73--129. Springer, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Graham Hutton. Higher-order functions for parsing. Journal of Functional Programming, 2 (3): 323--343, July 1992.Google ScholarGoogle ScholarCross RefCross Ref
  18. Simon L. Peyton Jones and Simon Marlow. Secrets of the glasgow haskell compiler inliner. J. Funct. Program, 12 (4&5): 393--433, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. Ryan Newton, Greg Morrisett, and Matt Welsh. The regiment macroprogramming system. In Proc. IPSN '07, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle Scholar
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. John Peterson, Paul Hudak, and Conal Elliott. Lambda in motion: Controlling robots with Haskell. Lecture Notes in Computer Science, 1551: 91--105, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  33. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  34. Walid Taha. Multi-stage programming: Its theory and applications. Technical Report CSE-99-TH-002, Oregon Graduate Institute of Science and Technology, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Walid Taha and Tim Sheard. MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science, 248 (1--2): 211--242, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  37. Z. Wan, W. Taha, and P. Hudak. Real-time FRP. In International Conference on Functional Programming (ICFP '01), Florence, Italy, September 2001a. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Zhanyong Wan. Functional Reactive Programming for Real-Time Reactive Systems. .d. dissertation, Computer Science Department, Yale University, October 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Zhanyong Wan, Walid Taha, and Paul Hudak. Event-driven FRP. Lecture Notes in Computer Science, 2257: 155+, 2001b. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Stephen Weeks, Matthew Fluet, Henry Cejtin, and Suresh Jagannathan. http://www.mlton.org/.Google ScholarGoogle Scholar
  41. 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 ScholarGoogle ScholarCross RefCross Ref
  42. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  43. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  44. 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 ScholarGoogle Scholar
  45. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  46. Hongwei Xi, Chiyan Chen, and Gang Chen. Guarded recursive datatype constructors. POPL '03, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Flask: staged functional programming for sensor networks

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      ICFP '08: Proceedings of the 13th ACM SIGPLAN international conference on Functional programming
      September 2008
      422 pages
      ISBN:9781595939197
      DOI:10.1145/1411204
      • cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 43, Issue 9
        ICFP '08
        September 2008
        399 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1411203
        Issue’s Table of Contents

      Copyright © 2008 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 20 September 2008

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Author Tags

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate333of1,064submissions,31%

      Upcoming Conference

      ICFP '23

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!