restructure
[phd-thesis.git] / dsl / dsl_techniques.tex
index 3e92c03..22b9977 100644 (file)
@@ -1,11 +1,9 @@
 \documentclass[../thesis.tex]{subfiles}
 
 \documentclass[../thesis.tex]{subfiles}
 
-\begin{document}
-\ifSubfilesClassLoaded{
-       \pagenumbering{arabic}
-}{}
+\include{subfilepreamble}
 
 
-\chapter{\texorpdfstring{\Acrshort{DSL}}{DSL} embedding techniques}%
+\begin{document}
+\chapter{\texorpdfstring{\Glsxtrshort{DSL}}{DSL} embedding techniques}%
 \label{chp:dsl_embedding_techniques}%
 An \gls{EDSL} is a language embedded in a host language created for a specific domain\todo{citation needed?}.
 Properties such as referential transparency, minimal syntax, powerful type systems and rich data types make \gls{FP} languages excellent candidates for hosting \glspl{EDSL}.
 \label{chp:dsl_embedding_techniques}%
 An \gls{EDSL} is a language embedded in a host language created for a specific domain\todo{citation needed?}.
 Properties such as referential transparency, minimal syntax, powerful type systems and rich data types make \gls{FP} languages excellent candidates for hosting \glspl{EDSL}.
@@ -90,7 +88,7 @@ eval (Eq l r) = case (eval l, eval r) of
        (l, r)       -> error ("Can't compare " ++ show l ++ " to " ++ show r)
 \end{lstHaskell}
 
        (l, r)       -> error ("Can't compare " ++ show l ++ " to " ++ show r)
 \end{lstHaskell}
 
-\subsection{\texorpdfstring{\Acrlongpl{GADT}}{Generalised algebraic data types}}
+\subsection{\texorpdfstring{\Glsxtrlongpl{GADT}}{Generalised algebraic data types}}
 Deep embedding has the advantage that it is easy to build and views are easy to add.
 On the downside, the expressions created with this language are not necessarily type-safe.
 In the given language it is possible to create an expression such as \haskellinline{LitI 4 `Plus` LitB True} that adds a boolean to an integer.
 Deep embedding has the advantage that it is easy to build and views are easy to add.
 On the downside, the expressions created with this language are not necessarily type-safe.
 In the given language it is possible to create an expression such as \haskellinline{LitI 4 `Plus` LitB True} that adds a boolean to an integer.
@@ -99,7 +97,7 @@ Extending the \gls{ADT} is easy and convenient but extending the views according
 The first downside of this type of \gls{EDSL} can be overcome by using \glspl{GADT}~\citep{cheney_first-class_2003}.
 \Cref{lst:exdeepgadt} shows the same language, but type-safe with a \gls{GADT}.
 \glspl{GADT} are not supported in the current version of \gls{CLEAN} and therefore the syntax is hypothetical (See \todo{insert link to appendix}).
 The first downside of this type of \gls{EDSL} can be overcome by using \glspl{GADT}~\citep{cheney_first-class_2003}.
 \Cref{lst:exdeepgadt} shows the same language, but type-safe with a \gls{GADT}.
 \glspl{GADT} are not supported in the current version of \gls{CLEAN} and therefore the syntax is hypothetical (See \todo{insert link to appendix}).
-However, it has been shown that \glspl{GADT} can be simulated using bimaps or projection pairs~\citep[Sec.~2.2]{cheney_lightweight_2002}.
+However, it has been shown that \glspl{GADT} can be simulated using bimaps or projection pairs~\citep[\citesection{2.2}]{cheney_lightweight_2002}.
 Unfortunately the lack of extendability remains a problem.
 If a language construct is added, no compile time guarantee can be given that all views support it.
 
 Unfortunately the lack of extendability remains a problem.
 If a language construct is added, no compile time guarantee can be given that all views support it.
 
@@ -147,11 +145,11 @@ sub x y = \e->x e - y e
 \end{lstHaskell}
 
 Moreover, the language is type safe as it is directly typed in the host language, i.e.\ \haskellinline{lit True `plus` lit 4} is rejected.
 \end{lstHaskell}
 
 Moreover, the language is type safe as it is directly typed in the host language, i.e.\ \haskellinline{lit True `plus` lit 4} is rejected.
-Another advantage is the intimate link with the host language, allowing for a lot more linguistic reuse such as the support of implicit sharing~\cite{krishnamurthi_linguistic_2001}.
+Another advantage is the intimate link with the host language, allowing for a lot more linguistic reuse such as the support of implicit sharing \citep{krishnamurthi_linguistic_2001}.
 
 The downside of this method is extending the language with views.
 It is nearly impossible to add views to a shallowly embedded language.
 
 The downside of this method is extending the language with views.
 It is nearly impossible to add views to a shallowly embedded language.
-The only way of achieving this is by reimplementing all functions so that they run all backends at the same time or to create a single interpretation that produces a fold function~\citep{gibbons_folding_2014}.
+The only way of achieving this is by reimplementing all functions so that they run all backends at the same time or to create a single interpretation that produces a fold function \citep{gibbons_folding_2014}.
 
 \subsection{Tagless-final embedding}\label{ssec:tagless}
 By lifting the functions representing the \gls{DSL} terms to type classes, interpretations can be added.
 
 \subsection{Tagless-final embedding}\label{ssec:tagless}
 By lifting the functions representing the \gls{DSL} terms to type classes, interpretations can be added.
@@ -168,7 +166,7 @@ class DSL v where
 
 An interpretation of this view is a data type that implements the type class.
 
 
 An interpretation of this view is a data type that implements the type class.
 
-\begin{lstHaskell}[label={lst:extagless},caption={A minimal tagless-final \gls{EDSL}.}]
+\begin{lstHaskell}[label={lst:extaglessprint},caption={A pretty printer for the tagless-final \gls{EDSL}.}]
 data Print a = P {runPrint :: String}
 instance DSL Print where
        lit a = P (show a)
 data Print a = P {runPrint :: String}
 instance DSL Print where
        lit a = P (show a)
@@ -189,7 +187,7 @@ instance Sub Print where
 
 Adding an interpretation means adding a data type and providing instances for the language constructs.
 
 
 Adding an interpretation means adding a data type and providing instances for the language constructs.
 
-\begin{lstHaskell}[label={lst:extagless},caption={An evaluator interpretation of the minimal tagless-final \gls{EDSL}.}]
+\begin{lstHaskell}[label={lst:extaglesseval},caption={An evaluator interpretation of the minimal tagless-final \gls{EDSL}.}]
 data Eval a = Eval {runEval :: Env -> a}
 
 instance DSL v where
 data Eval a = Eval {runEval :: Env -> a}
 
 instance DSL v where
@@ -207,7 +205,7 @@ Both flavours have their strengths and weaknesses and both flavours can be impro
 
 \begin{table}[ht]
        \begin{threeparttable}[b]
 
 \begin{table}[ht]
        \begin{threeparttable}[b]
-               \caption{Comparison of embedding techniques, adapted from \citet[Sec.~3.6]{sun_compositional_2022}}%
+               \caption{Comparison of embedding techniques, adapted from \citet[\citesection{3.6}]{sun_compositional_2022}}%
                \label{tbl:dsl_comparison}
                \begin{tabular}{lllllll}
                        \toprule
                \label{tbl:dsl_comparison}
                \begin{tabular}{lllllll}
                        \toprule