X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=dsl%2Fclass.tex;h=d5d3467f759b47c1d4cdfdc7d028b0d27855026d;hb=066dd25d4da01798ce7a5dd2c96e47040fa908d8;hp=5931da76135f4c050fd13d84e324e24e7a201e47;hpb=4e17593a20e8c3af4c82a0b14bc648ddc180c25d;p=phd-thesis.git diff --git a/dsl/class.tex b/dsl/class.tex index 5931da7..d5d3467 100644 --- a/dsl/class.tex +++ b/dsl/class.tex @@ -2,12 +2,12 @@ \input{subfilepreamble} +\setcounter{chapter}{0} + \begin{document} +\input{subfileprefix} \chapter{Deep embedding with class}% \label{chp:classy_deep_embedding} - -\input{subfileprefix} - \begin{chapterabstract} The two flavours of \gls{DSL} embedding are shallow and deep embedding. In functional languages, shallow embedding models the language constructs as functions in which the semantics are embedded. @@ -34,7 +34,7 @@ Consequently, adding new semantics, i.e.\ novel functions, is straightforward. It can be stated that the language constructs are embedded in the functions that form a semantics. If one wants to add a language construct, all semantics functions must be revisited and revised to avoid ending up with partial functions. -This juxtaposition has been known for many years \citep{reynolds_user-defined_1978} and discussed by many others \citep{krishnamurthi_synthesizing_1998} but most famously dubbed the \emph{expression problem} by Wadler \citep{wadler_expression_1998}: +This juxtaposition has been known for many years \citep{reynolds_user-defined_1978} and discussed by many others \citep{krishnamurthi_synthesizing_1998} but most famously dubbed the \emph{expression problem} by \citet{wadler_expression_1998}: \begin{quote} The \emph{expression problem} is a new name for an old problem. @@ -685,7 +685,6 @@ For example, \citet{svenningsson_combining_2013} show that by expressing the dee This paper differs from those approaches in the sense that it does not require a core language in which all extensions need to be expressible. \subsection{Comparison} -\todo[inline]{text moet beter} No \gls{DSL} embedding technique is the silver bullet. \Citet{sun_compositional_2022} provided a thorough comparison of embedding techniques including more axes than just the two stated in the expression problem. @@ -870,15 +869,15 @@ e1 :: (Typeable c, UsingExt '[Neg, Subst]) => Expr c Giving an instance for \haskelllhstexinline{Interp} for \haskelllhstexinline{DataType} that uses the extensions \haskelllhstexinline{e_1, e2, ...} and depends on interpretations \haskelllhstexinline{i_1,i_2, ...} is done as follows: \begin{lstHaskellLhstex} -instance ( UsingExt '[e_1, e_2, ...] s - , DependsOn '[i_1, i_2, ...] s - ) => Interp (DataType s) where +instance ( UsingExt '[e_1, e_2, ...] s, DependsOn '[i_1, i_2, ...] s) + => Interp (DataType s) where ... \end{lstHaskellLhstex} With these enhancements, there is hardly any boilerplate required to use classy deep embedding. The \haskelllhstexinline{Record} data type; the \haskelllhstexinline{CreateRecord} type class; and the \haskelllhstexinline{UsingExt} and \haskelllhstexinline{DependsOn} type families can be provided as a library only requiring the programmer to create the extension constructors with their respective implementations and smart constructors for language construct extensions. -The source code for this extension can be found here: \url{https://gitlab.com/mlubbers/classydeepembedding}. +The source code for this extension can be found here: \url{https://gitlab.com/mlubbers/classydeepembedding}.\footnote{Lubbers, M. (2022): Library and examples for enhanced classy deep embedding.\ Zenodo.\ \href{https://doi.org/10.5281/zenodo.7277498}{10.5281/zenodo.7277498}.} +It contains examples for expressions, expressions using \glspl{GADT}, detection of sharing in expressions (modelled after \citet{kiselyov_implementing_2011}), a \gls{GADT} version of sharing detection, and a region \gls{DSL} (modelled after \citet{sun_compositional_2022}). \section{Data types and definitions}% \label{sec:cde:appendix}