Jeffrey Bosboom's Blog

[blog] [projects] [about]

Papers: StreamIt in Haskell

Embrace, Defend, Extend: A Methodology for Embedding Preexisting DSLs, Case in Point, StreamHs: StreamIt in Haskell (Abhishek Kulkarni, Ryan Newton)

ACM DL, gratis PDF

This paper argues for embedding domain-specific languages into general-purpose languages as a way to reuse the engineering effort spent building the DSLs, while working around their bugs, adding metaprogramming capabilities, and adding new abstractions using the tools of the embedding language. To demonstrate the value of this approach, the paper presents StreamHs, an embedding of StreamIt in Haskell. StreamHs’s low-level interface is a fairly literal mirror of StreamIt constructs (filters, pipelines and splitjoins). Recognizing that stream programs are already expressed in Haskell via infinite lists, StreamHs provides high-level list-like operators that desugar to the low-level interface. Being embedded permits replacing StreamIt’s (somewhat buggy) compile-time evaluation with Haskell metaprogramming. StreamHs’s programs are executed by emitting StreamIt code, calling the StreamIt compiler and running the resulting binary.

For me, the key insight of this paper is that embedded domain-specific languages enable metaprogramming. I’d realized this before, but thought in terms of “not having to commit to the program until run time”. This paper was the first I’ve read to explicitly say metaprogramming, which crystallized the idea for me.