1 \section{\acrlong{EDSL
}s
}
2 There are several techniques available for creating
\glspl{EDSL
}. Each of
3 them have their own advantages and disadvantages such as extendability,
4 typedness and view support. In the following subsections each of the main
5 techniques are briefly explained.
7 \subsection{Deep embedding
}
8 A deep
\gls{EDSL
} means that the language is represented as an
\gls{ADT
}. Views
9 are functions that transform something to the datatype or the other way around.
10 As an example we have the simple arithmetic
\gls{EDSL
} shown in
11 Listing~
\ref{lst:exdeep
}. Deep embedding has the advantage that it is very
12 simple to build and the views are easy to make and add. However, there are also
15 \begin{lstlisting
}[language=Clean,label=
{lst:exdeep
},caption=
{A minimal deep
27 The expressions created with this language are not type-safe. In the given
28 language it is possible an expression such as
\CI{Plus (LitI
4) (LitB True)
}
29 which to add a boolean to an integer. Evermore so, extending the
\gls{ADT
} is
30 easy and convenient but extending the views accordingly is tedious and has to
31 be done individually for all views.
33 The first downside of the type of
\gls{EDSL
} can be overcome by using
34 \glspl{GADT
}. Listing~
\ref{lst:exdeepgadt
} shows the same language, but
35 type-safe with a
\gls{GADT
}\footnote{Note that
\glspl{GADT
} are not supported
36 in
\gls{Clean
}. They can be simulated using bimaps
}\todo{cite
}. Unfortunately
37 the lack of extendability stays a problem.
39 \begin{lstlisting
}[language=Clean,label=
{lst:exdeep
},
%
40 caption=
{A minimal deep
\gls{EDSL
}}]
43 | LitB Bool -> DSL Bool
44 | Var String -> DSL Int
45 | Plus (DSL Int) (DSL Int) -> DSL Int
46 | Minus (DSL Int) (DSL Int) -> DSL Int
47 | And (DSL Bool) (DSL Bool) -> DSL Bool
48 | E.e: Eq (DSL e) (DSL e) -> DSL Bool & == e
51 \subsection{Shallow embedding
}
53 \subsection{Class based shallow embedding
}
54 \todo{while iTasks is also a DSL
\ldots}
55 \glspl{mTask
} are expressed in a class based shallowly embedded
\gls{EDSL
}.
56 There are two main types of
\glspl{EDSL
}.
57 \todo{Small shallow embedded dsl intro
}
58 \todo{Small deep embedded dsl
}
59 \todo{Show that class based has the best of both worlds
}