1\chapter*{Introduction} 2\epigraph{The Filet-o-Fish contains a battered fish patty made mostly 3 from pollock and/or hoki.}{Wikipedia} 4 5 6Filet-o-Fish, abbreviated \emph{FoF} hereafter, is a tool for the 7working language designer. Developed in the context of 8Barrelfish\cite{schuepbach:mmcs08}, FoF aims at easing the development 9of Domain-Specific Languages (DSL) as well as enhancing their 10safety. As a side effect of FoF's design, it also becomes easier for 11the user of a DSL to understand ``what is going on''. 12 13To achieve this goal, Filet-o-Fish defines a set of 14\emph{combinators}. A combinator is a Haskell function manipulating 15some Haskell data-types. In this case, our combinators manipulate an 16abstraction of the C language constructs, such as integers, floats, 17structures, arrays, etc. Altogether, this set of combinators defines 18an \emph{embedded language} in Haskell. To avoid the confusion with 19the DSLs we are willing to implement, we term this embedded language 20the \emph{meta-language}. 21 22You seems confused now. Listen. The Hamlet compiler is implemented 23with Filet-o-Fish. Hamlet is a Domain-Specific Language. In Hamlet's 24compiler, we use FoF to \emph{get the job done}, ie. to get the actual 25C code out of our capability system description. Hence, the Hamlet 26compiler is partly developed in the FoF meta-language. Understood? 27 28However, Filet-o-Fish is much more than a language to get the job 29done: being able to compile the meta-language to C is just one 30side-effect of our work. By writing a DSL compiler with FoF, you 31actually define the \emph{semantics} of the DSL. Whereas the syntax 32defines the set of legal expressions of a language, the semantics 33assign a meaning to the terms of the language. Note that the C 34language does not have any formal semantics. And, no, this is not 35normal. This is Evil. 36 37For a DSL, the benefit of having a formal semantics is twofold. First, 38the semantics of your DSL is the most precise and accurate description 39of the behavior of your domain-specific constructs. An informal, 40in-English specification of the DSL might fail to capture some 41specific points. The formal semantics is an ultimate documentation, 42which doesn't lie. Second, defining a formal semantics is a necessary 43step before any compiler correctness proof, be it mechanized or on 44paper. Therefore, thanks to FoF, you get a formal, mechanized 45semantics of your DSL. And this is for free. 46 47Finally, this document is the literate Haskell code of Filet-o-Fish: 48the code described in the following pages is the one that is compiled 49by the Haskell compiler. Therefore, this is the most accurate, 50up-to-date documentation of Fof's internals. 51 52So much marketing, let us look at the code. 53 54