Flask is a programming language for sensor networks geared towards streaming data applications. It is realized as a domain-specific language embedded in Haskell. Its design is inspired by prior work on Functional Reactive Programming (FRP), but motivated by the constraints of sensor network platforms. Flask runs on real hardware, including both MicaZ and TelosB motes.

The key observation behind Flask is that in programs written in the FRP style, it is the point-wise manipulation of values that must be executed dynamically; the data flow configuration of these programs is typically static. Flask exploits this observation by explicitly staging the static and dynamic behavior of dataflow programs. Haskell serves as Flask’s meta language, and its full power is available for expressing how data flow graphs can be constructed using FRP-style combinators. Flask also requires that point-wise manipulation of signal values is always done in a restricted object-language. Because the dynamic behavior of the program is expressed only through a restricted object language, Flask programs can run on even 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. The current incarnation of Flask is described in our ICFP ‘08 paper. An earlier, Caml-based implementation is described in a tech report.

Matt Welsh’s macroprogramming page describes the historical macroprogramming project at Harvard.

Flask Distribution

The Flask 0.1 release is available here.



  1. Mainland, G., Morrisett, G. and Welsh, M. 2008. Flask: Staged Functional Programming for Sensor Networks. Proceeding of the 13th ACM SIGPLAN International Conference on Functional Programming (Victoria, BC, Canada, Sep. 2008), 335–346.
    DOI  PDF  BibTeX
      title = {Flask: Staged Functional Programming for Sensor Networks},
      booktitle = {Proceeding of the 13th {{ACM SIGPLAN International Conference}} on {{Functional Programming}}},
      author = {Mainland, Geoffrey and Morrisett, Greg and Welsh, Matt},
      year = {2008},
      month = sep,
      pages = {335--346},
      address = {{Victoria, BC, Canada}},
      doi = {10.1145/1411204.1411251},
      acceptrate = {35},
      citations = {100}


  1. Mainland, G., Morrisett, G., Welsh, M. and Newton, R. 2007. Sensor Network Programming with Flask. Proceedings of the 5th International Conference on Embedded Networked Sensor Systems (Sydney, Australia, Nov. 2007), 385–386.
    DOI  PDF  BibTeX
      title = {Sensor Network Programming with {{Flask}}},
      booktitle = {Proceedings of the 5th {{International Conference}} on {{Embedded Networked Sensor Systems}}},
      author = {Mainland, Geoffrey and Morrisett, Greg and Welsh, Matt and Newton, Ryan},
      year = {2007},
      month = nov,
      pages = {385--386},
      publisher = {{ACM}},
      address = {{Sydney, Australia}},
      doi = {10.1145/1322263.1322307},
      citations = {5}


  1. Mainland, G., Welsh, M. and Morrisett, G. 2006. Flask: A Language for Data-Driven Sensor Network Programs. Technical Report #TR-13-06. Harvard University.
    PDF  BibTeX
      title = {Flask: A Language for Data-Driven Sensor Network Programs},
      author = {Mainland, Geoffrey and Welsh, Matt and Morrisett, Greg},
      year = {2006},
      month = may,
      number = {TR-13-06},
      institution = {{Harvard University}},
      citations = {43}