+\begin{lstClean}[numbers=left,caption={The code for entering a person in \gls{ITASK}.},label={lst:enter_person}]
+:: Person = { name :: String, gender :: Gender, dateOfBirth :: Date }[+\label{lst:dt_fro}+]
+:: Gender = Male | Female | Other String[+\label{lst:dt_to}+]
+
+derive class iTask Person, Gender[+\label{lst:dt_derive}+]
+
+enterPerson :: Task Person
+enterPerson
+ = Hint "Enter a person:" @>> enterInformation [][+\label{lst:task_ui}+]
+ >>! \result->Hint "You Entered:" @>> viewInformation [] result[+\label{lst:task_comb}+]
+\end{lstClean}
+
+\subsection{\texorpdfstring{\Gls{MTASK}}{MTask}}
+\Gls{ITASK} seems an obvious candidate at first glance for extending \gls{TOP} to \gls{IOT} edge devices.
+However, \gls{IOT} edge devices are in general not powerful enough to run or interpret \gls{CLEAN}\slash\gls{ABC} code, they just lack the processor speed and the memory.
+To bridge this gap, \gls{MTASK} was developed, a \gls{TOP} system for \gls{IOT} edge devices that is integrated in \gls{ITASK} \citep{koopman_task-based_2018}.
+\Gls{ITASK} abstracts away from details such as user interfaces, data storage, client-side platforms, and persistent workflows.
+On the other hand, \gls{MTASK} offers abstractions for edge layer-specific details such as the heterogeneity of architectures, platforms, and frameworks; peripheral access; (multi) task scheduling; and lowering energy consumption.
+The \gls{MTASK} language is written in \gls{CLEAN} as a multi-view \gls{EDSL} and hence there are multiple interpretations possible.
+The byte code compiler is the most relevant for this thesis.
+From an \gls{MTASK} task constructed at runtime, a compact binary representation of the work that needs to be done is compiled.
+This byte code is then sent to a device that running the \gls{MTASK} \gls{RTS}.
+This feather-light domain-specific \gls{OS} is written in portable \gls{C} with a minimal device specific interface and functions as a \gls{TOP} engine.
+\Gls{MTASK} is seamlessly integrated with \gls{ITASK}: \gls{MTASK} tasks are integrated in such a way that they function as \gls{ITASK} tasks, and \glspl{SDS} in on the device can tether an \gls{ITASK} \gls{SDS}.
+Using \gls{MTASK}, the programmer can define all layers of an \gls{IOT} system as a single declarative specification.
+
+\Cref{lst:intro_blink} shows an interactive \gls{MTASK}\slash{}\gls{ITASK} application for blinking \pgls{LED} on the microcontroller every user-specified interval.
+\Crefrange{lst:intro:itask_fro}{lst:intro:itask_to} show the \gls{ITASK} part.
+First \pgls{SDS} is defined to communicate the blinking interval, then the \gls{MTASK} is connected using \cleaninline{withDevice}.
+Once connected, the \cleaninline{intBlink} task is sent to the device (\cref{lst:intro_liftmtask}) and, in parallel, an editor is shown that updates the value of the interval \gls{SDS} (\cref{lst:intro_editor}).
+The \cleaninline{intBlink} task (\crefrange{lst:intro:mtask_fro}{lst:intro:mtask_to}) is the \gls{MTASK} part of the application.
+It has its own tasks, \glspl{SDS}, and \gls{UOD}.
+This task first defines \gls{GPIO} pin 13 to be of the output type (\cref{lst:intro:declarePin}), followed by lifting the \gls{ITASK} \gls{SDS} to an \gls{MTASK} \gls{SDS} (\cref{lst:intro:liftsds}).
+The main expression of the program calls the \cleaninline{blink} function with an initial state.
+This function on \crefrange{lst:intro:blink_fro}{lst:intro:blink_to} first reads the interval \gls{SDS}, waits the specified delay, writes the state to the \gls{GPIO} pin and calls itself recursively using the inverse of the state.
+
+\begin{lstClean}[numbers=left,caption={\Gls{MTASK}\slash{}\gls{ITASK} interactive blinking.},label={lst:intro_blink}]
+interactiveBlink :: Task Int[+\label{lst:intro:itask_fro}+]
+interactiveBlink =
+ withShared 500 \iInterval->[+\label{lst:intro_withshared}+]
+ withDevice {TCPSettings | host = ..., port = ...} \dev->
+ liftmTask (intBlink iInterval) dev[+\label{lst:intro_liftmtask}+]
+ -|| Hint "Interval (ms)" @>> updateSharedInformation [] iInterval[+\label{lst:intro_editor}+][+\label{lst:intro:itask_to}+]
+
+intBlink :: Shared sds Int -> MTask v Int | mtask, liftsds v & RWShared sds[+\label{lst:intro:mtask_fro}+]
+intBlink iInterval =
+ declarePin D13 PMOutput \d13->[+\label{lst:intro:declarePin}+]
+ liftsds \mInterval=iInterval[+\label{lst:intro:liftsds}+]
+ In fun \blink=(\st->[+\label{lst:intro:blink_fro}+]
+ getSds mInterval >>=. \i->delay i
+ >>|. writeD d13 st >>|. blink (Not st))[+\label{lst:intro:blink_to}+]
+ In {main = blink true}[+\label{lst:intro:mtask_to}+]
+\end{lstClean}
+
+\todo{Zal ik hier nog een soort conclusie maken van \gls{MTASK}.}
+
+\subsection{Other \texorpdfstring{\glsxtrshort{TOP}}{TOP} languages}
+While \gls{ITASK} conceived \gls{TOP}, it is not the only \gls{TOP} system.
+Some \gls{TOP} systems arose from Master's and Bachelor's thesis projects.
+For example, \textmu{}Task \citep{piers_task-oriented_2016}, a \gls{TOP} language for modelling non-interruptible embedded systems in \gls{HASKELL}, and LTasks \citep{van_gemert_task_2022}, a \gls{TOP} language written in the dynamically typed programming language {LUA}.
+Some \gls{TOP} languages were created to solve a practical problem.Toppyt \citep{lijnse_toppyt_2022} is a general purpose \gls{TOP} language written in \gls{PYTHON} used to host frameworks for modelling C2 systems, and hTask \citep{lubbers_htask_2022}, a vessel for experimenting with asynchronous \glspl{SDS}.
+Finally there are \gls{TOP} languages with strong academic foundations.
+\Gls{TOPHAT} is a fully formally specified \gls{TOP} language designed to capture the essence of \gls{TOP} formally \citep{steenvoorden_tophat_2019}.
+Such a formal specification allows for symbolic execution, hint generation, but also the translation to \gls{ITASK} for actually performing the work \citep{steenvoorden_tophat_2022}.
+
+\section{Contributions}%
+\label{sec:contributions}
+\todo{Dit heb ik sterk ingekort. Ok\'e?}
+This section provides a thorough overview of the relation between the scientific publications and the episodes and chapters.
+
+\subsection{\Fullref{prt:dsl}}
+The \gls{MTASK} system is a heterogeneous \gls{EDSL} and during the development of it, several novel basal techniques for embedding \glspl{DSL} in \gls{FP} languages have been found.
+This episode is paper based.
+
+\Cref{chp:classy_deep_embedding} is based on the paper \emph{Deep Embedding with Class} \citep{lubbers_deep_2022}.
+It shows a novel deep embedding technique for \glspl{DSL} where the resulting language is extendible both in constructs and in interpretation just using type classes and existential data types\footnotemark.
+\footnotetext{%
+The related work section is updated with the research found after publication.
+\Cref{sec:classy_reprise} was added after publication and contains a (yet) unpublished extension of the embedding technique for reducing the required boilerplate at the cost of requiring some advanced type system extensions.
+}
+
+\Cref{chp:first-class_datatypes} is based on the paper \emph{First-Class Data Types in Shallow Embedded Domain-Specific Languages} \citep{lubbers_first-class_2022}.
+It shows how to inherit data types from the host language in \glspl{EDSL} using metaprogramming by providing a proof-of-concept implementation using \gls{HASKELL}'s metaprogramming system: \glsxtrlong{TH}.
+Besides showing the result, the paper also serves as a gentle introduction to, and contains a thorough literature study on \glsxtrlong{TH}.
+%The research in this paper and writing the paper was performed by me, though there were weekly meetings with Pieter Koopman and Rinus Plasmeijer in which we discussed and refined the ideas.
+
+\subsection{\Fullref{prt:top}}
+There were many papers and revised lecture notes published on the design, implementation and usage of \gls{MTASK}.
+This episode is a monograph compiled from the following publications and shows all aspects of the \gls{MTASK} system and \gls{TOP} for the \gls{IOT}.
+\todo{Hier een over\-zicht van de chapters geven?}