From 27d1d51bf3f3acc08c002a5d58af6a4f4332e3f8 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Thu, 19 Jan 2023 20:14:54 +0100 Subject: [PATCH] up --- appx/bytecode.tex | 193 +++++++++++++++++++------------------ appx/c4hp.tex | 35 ++++--- appx/lst/generic_eq.icl | 3 +- appx/lst/generic_print.icl | 12 ++- appx/mtask_aux.tex | 3 + concl/concl.tex | 3 +- dsl/class.tex | 4 +- front/motto.tex | 4 +- intro/intro.tex | 107 ++++++++++---------- intro/iot-layers.tex | 1 - other.bib | 9 ++ thesis.tex | 7 +- top/green.tex | 5 +- top/imp.tex | 7 +- top/int.tex | 2 +- 15 files changed, 216 insertions(+), 179 deletions(-) diff --git a/appx/bytecode.tex b/appx/bytecode.tex index 594e630..6884e53 100644 --- a/appx/bytecode.tex +++ b/appx/bytecode.tex @@ -2,105 +2,110 @@ \input{subfilepreamble} +\setcounter{chapter}{2} + \begin{document} \input{subfileprefix} +\ifSubfilesClassLoaded{\appendix}{} \chapter{Bytecode instruction set}% \label{chp:bytecode_instruction_set}% -\todo[inline]{formatting} - -\begin{tabular}{ll} - $l$ & label\\ - $w_r$ & return width\\ - $w_a$ & argument width\\ - $fp$ & frame pointer\\ - $sp$ & stack pointer\\ - $pc$ & program counter\\ -\end{tabular} +This appendix describeds the semantics of the byte code instruction set. +The byte code instructions are of variable length and automatically encoded and decoded using generic programming (see \todo{ref naar c\-co\-de\-gen}). +\Cref{tbl:bc_notation} shows the notation convention. -Bytecode is byte encoded, stack has 16-bit cells. -Longs and reals are stored with the MSB first. +\begin{table}[ht!] + \caption{Notation for the byte code semantics}% + \label{tbl:bc_notation} + \centering + \begin{tabular}{lll} + \toprule + variable & meaning & \textnumero{}bytes\\ + \midrule + $l$ & label & 2\\ + $w_r$ & return width & 1\\ + $w_a$ & argument width & 1\\ + $i$ & \gls{SDS} or sensor id & 1\\ + $fp$ & frame pointer & 2\\ + $sp$ & stack pointer & 2\\ + $pc$ & program counter & 2\\ + \bottomrule + \end{tabular} +\end{table} -\footnotesize -%\begin{longtable}{lllll} -% \caption{\normalsize Semantics for the bytecode instructions\label{tbl:instr_task}} -% \endfirsthead% -% \caption{\normalsize Semantics for the bytecode instructions (cont.)} -% \endhead% -% \endfoot% -% \endlastfoot% -% \toprule -% Instr. & Args & Semantics & sp & pc\\ -% -% \midrule -% \texttt{return} & $w_r~w_a$ & $st[fp\shortminus{}w_a\shortminus{}3+i] = st[fp+1]$ & $st[fp\shortminus{}w_a\shortminus{}3+w_r]$ & $st[fp\shortminus{}w_a\shortminus{}1]$\\ -% & & {\bf for all} $i\in\{0..w_r\}$\\ -% & & $fp = st[fp\shortminus{}w_a\shortminus{}2]$\\ -% \texttt{jumpF} & $l$ & & $sp\shortminus{}1$ & $\left\{\begin{array}{ll} pc+1 & \textrm{\bf if } st[sp\shortminus{}1]\\l & \textrm{\bf otherwise}\end{array}\right.$\\ -% \texttt{jump} & $l$ & & $sp\shortminus{}1$ & $l$\\ -% \texttt{jumpSR} & $w_a~l$ & $st[sp\shortminus{}w_a\shortminus{}1]=pc+2$ & & $l$\\ -% \texttt{tailCall} & $w_{a_1}~w_{a_2}~l$ & $rotate\:(w_{a_1}+3+w_{a_2},w_{a_2})$ & $fp$ & $jl$\\ -% & & $fp = fp-w_{a_1}+w_{a_2}$\\ -% & & \multicolumn{3}{p{.75\textwidth}}{{\bf where} $w_{a_1}$ is the width of the current function and $w_{a_2}$ the width of the called function}\\ -% \texttt{arg} & $i$ & $st[sp] = st[fp-1-i]$ & $sp+1$\\ -% \texttt{push} & $n~b_0\ldots b_n$ & $st[sp+i] = s[i]$ & $sp+n$ & $pc+2+n$\\ -% & & {\bf for all} $i\in\{0..n\}$\\ -%% \midrule -% \texttt{pop} & $n$ & & $sp-n$ & $pc+2$\\ -%% \midrule -% \texttt{rot} & $d~n$ & $rotate\:(d, n)$ & $sp$ & $pc+3$\\ -%% \midrule -% \texttt{dup} & & $st[sp] = st[sp-1]$ & $sp+1$ & $pc+1$\\ -%% \midrule -% \texttt{pushPtrs} & & $st[sp] = sp$ & $sp+3$ & $pc+1$\\ -% & & $st[sp+1] = fp$\\ -% & & $st[sp+2] = 0$\\ -%% \midrule -% \texttt{unOp} & & $st[sp-1] = \diamond{}st[sp-1]$ & $sp$ & $pc+1$\\ -% & & \multicolumn{3}{l}{{\bf for all} $\diamond\in\{\neg\}$}\\ -%% \midrule -% \texttt{binOp} & & $st[sp-2] = st[sp-2] \mathbin{\oplus} st[sp-1]$ & $sp-1$ & $pc+1$\\ -% & & \multicolumn{3}{l}{{\bf for all} $\oplus\in\{+, -, *, /, \wedge, \vee, \equiv, \not\equiv, \leq, \geq, <, >\}$}\\ -%% \midrule -% \texttt{mkTask} & \texttt{Stable\textsubscript{n}} & $st[sp-n-1] = node (stable,$ & $sp-n+1$ & $pc+2$\\ -% & & $\qquad\qquad st[sp-1], \ldots, st[sp-n-1])$\\ -% \texttt{mkTask} & \texttt{Unstable\textsubscript{n}} & $st[sp-n-1] = node (unstable,$ & $sp-n+1$ & $pc+2$\\ -% & & $\qquad\qquad st[sp-1], \ldots, st[sp-n-1])$\\ -%% \midrule -%% & \multicolumn{3}{l}{Unstable\textsubscript{n}} & st[sp-n-1] = node (unstable, & sp-n+1 & pc+2\\ -%% & \multicolumn{3}{l}{} & \qquad\qquad st[sp-1], \textrm{\ldots}, st[sp-n-1])\\ -%% \midrule -%% -%% & \multicolumn{3}{l}{ReadD } & st[sp-1] \ \ = node (readd, st[sp-1]) & & pc+2\\ -%% \midrule -%% & \multicolumn{3}{l}{ReadA } & st[sp-1] \ \ = node (reada, st[sp-1]) & & pc+2\\ -%% \midrule -%% & \multicolumn{3}{l}{Repeat } & st[sp-1] \ \ = node (repeat, st[sp-1]) & & pc+2\\ -%% \midrule -%% & \multicolumn{3}{l}{Delay } & st[sp-1] \ \ = node (delay, st[sp-1]) & & pc+2\\ -%% \midrule -%% -%% & \multicolumn{3}{l}{WriteD } & st[sp-2] \ \ = node (writed, st[sp-1], st[sp-2]) & sp-1 & pc+2\\ -%% \midrule -%% & \multicolumn{3}{l}{WriteA } & st[sp-2] \ \ = node (writea, st[sp-1], st[sp-2]) & sp-1 & pc+2\\ -%% \midrule -%% & \multicolumn{3}{l}{And } & st[sp-2] \ \ = node (and, st[sp-1], st[sp-2]) & sp-1 & pc+2\\ -%% \midrule -%% & \multicolumn{3}{l}{Or } & st[sp-2] \ \ = node (or, st[sp-1], st[sp-2]) & sp-1 & pc+2\\ -%% \midrule -%% -%% & \multicolumn{3}{l}{SdsSet i } & st[sp-1] \ \ = node (sdsset,i, st[sp-1]) & & pc+3\\ -%% \midrule -%% -%% & \multicolumn{3}{l}{SdsGet i } & st[sp]\ \ \ \ \ = node (sdsget, i) & sp+1 & pc+3\\ -%% \midrule -%% & \multicolumn{3}{l}{DHTTemp i } & st[sp-1] \ \ = node (dhttemp, i) & sp+1 & pc+3\\ -%% \midrule -%% & \multicolumn{3}{l}{DHTHumid i } & st[sp-1] \ \ = node (dhthumid, i) & sp+1 & pc+3\\ -%% \midrule -%% -%% & \multicolumn{3}{l}{Step aw jl } & st[sp-1] \ \ = node (step, aw, jl, st[sp-1]) & sp-1 & pc+5\\ -% \bottomrule -%\end{longtable} +\begin{landscape} + \begin{longtable}[c]{lllll} + \caption{Semantics for the bytecode instructions\label{tbl:instr_task}}\\ + \toprule + Instruction & Arguments & Semantics & $sp$ & $pc$\\ + \midrule + \endfirsthead% + \caption{Semantics for the bytecode instructions (cont.)}\\ + \toprule + Instruction & Arguments & Semantics & $sp$ & $pc$\\ + \midrule + \endhead% + \bottomrule + \endfoot% + \bottomrule + \endlastfoot% + \texttt{push} & $n~b_0\ldots b_n$ & $st[sp+i] = s[i]$ & $sp+n$ & $pc+2+n$\\ + & & {\bf for all} $i\in\{0..n\}$\\ + \texttt{pop} & $n$ & & $sp\shortminus{}n$ & $pc+2$\\ + \texttt{rot} & $d~n$ & $rotate\:(d, n)$ & $sp$ & $pc+3$\\ + \texttt{dup} & & $st[sp] = st[sp\shortminus{}1]$ & $sp+1$ & $pc+1$\\ + \midrule + \texttt{jumpF} & $l$ & & $sp\shortminus{}1$ & $\left\{\begin{array}{ll} pc+1 & \textrm{\bf if } st[sp\shortminus{}1]\\l & \textrm{\bf otherwise}\end{array}\right.$\\ + \texttt{jump} & $l$ & & $sp\shortminus{}1$ & $l$\\ + \texttt{jumpSR} & $w_a~l$ & $st[sp\shortminus{}w_a\shortminus{}1]=pc+2$ & & $l$\\ + \texttt{tailCall} & $w_{a_1}~w_{a_2}~l$ & $rotate\:(w_{a_1}+3+w_{a_2},w_{a_2})$ & $fp$ & $jl$\\ + & & $fp = fp\shortminus{}w_{a_1}+w_{a_2}$\\ + & & \multicolumn{3}{p{.75\textwidth}}{{\bf where} $w_{a_1}$ is the width of the current function and $w_{a_2}$ the width of the called function}\\ + \texttt{arg} & $i$ & $st[sp] = st[fp\shortminus{}1\shortminus{}i]$ & $sp+1$\\ + \texttt{return} & $w_r~w_a$ & $st[fp\shortminus{}w_a\shortminus{}3+i] = st[fp+1]$ & $st[fp\shortminus{}w_a\shortminus{}3+w_r]$ & $st[fp\shortminus{}w_a\shortminus{}1]$\\ + & & {\bf for all} $i\in\{0..w_r\}$\\ + & & $fp = st[fp\shortminus{}w_a\shortminus{}2]$\\ + \texttt{pushPtrs} & & $st[sp] = sp$ & $sp+3$ & $pc+1$\\ + & & $st[sp+1] = fp$\\ + & & $st[sp+2] = 0$\\ + \midrule + \texttt{unOp} & & $st[sp\shortminus{}1] = \diamond{}st[sp\shortminus{}1]$ & $sp$ & $pc+1$\\ + & & \multicolumn{3}{l}{{\bf for all} $\diamond\in\{\neg\}$}\\ + \texttt{binOp} & & $st[sp\shortminus{}2] = st[sp\shortminus{}2] \mathbin{\oplus} st[sp\shortminus{}1]$ & $sp\shortminus{}1$ & $pc+1$\\ + & & \multicolumn{3}{l}{{\bf for all} $\oplus\in\{+, \shortminus{}, *, /, \wedge, \vee, \equiv, \not\equiv, \leq, \geq, <, >\}$}\\ + & & \multicolumn{3}{l}{similar for Real and Long variants}\\ + \texttt{cast}\textsubscript{f-t} & & $st[sp\shortminus{}1] = cast_{f-t} (st[sp\shortminus{}1])$ & $sp$ & $pc+1$\\ + & & \multicolumn{3}{l}{{\bf for all} $f,t\in\{Int, Real, Long\}$}\\ + \pagebreak + \texttt{mkTask} & \texttt{Stable\textsubscript{n}} & $st[sp\shortminus{}n\shortminus{}1] = node (stable,$ & $sp\shortminus{}n+1$ & $pc+2$\\ + & & $\qquad\qquad st[sp\shortminus{}1], \ldots, st[sp\shortminus{}n\shortminus{}1])$\\ + & \texttt{Unstable\textsubscript{n}} & $st[sp\shortminus{}n\shortminus{}1] = node (unstable,$ & $sp\shortminus{}n+1$ & $pc+2$\\ + & & $\qquad\qquad st[sp\shortminus{}1], \ldots, st[sp\shortminus{}n\shortminus{}1])$\\ + \midrule + & \texttt{ReadD} & $st[sp\shortminus{}1] = node (readd, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + & \texttt{ReadA} & $st[sp\shortminus{}1] = node (reada, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + & \texttt{WriteD} & $st[sp\shortminus{}2] = node (writed, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + & \texttt{WriteA} & $st[sp\shortminus{}2] = node (writea, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + & \texttt{WriteD} & $st[sp\shortminus{}2] = node (writed, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + & \texttt{PinMode} & $st[sp\shortminus{}2] = node (pinmode, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \midrule + & \texttt{Repeat} & $st[sp] = node (repeat, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + & \texttt{Delay} & $st[sp] = node (delay, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + & \texttt{And} & $st[sp\shortminus{}1] = node (and, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + & \texttt{Or} & $st[sp\shortminus{}1] = node (and, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + & \texttt{Step} $f$ $w_a$ & $st[sp] = node (step, st[sp\shortminus{}1], f, w)$ & $sp$ & $pc+5$\\ + \midrule + & \texttt{SdsGet} $i$ & $st[sp+1] = node (sdsget, i)$ & $sp+1$ & $pc+3$\\ + & \texttt{SdsSet} $i$ & $st[sp\shortminus{}1] = node (sdsset, st[sp\shortminus{}1], i)$ & $sp$ & $pc+3$\\ + & \texttt{SdsUpd} $i$ $l$ & $st[sp+1] = node (sdsset, i, l)$ & $sp+1$ & $pc+5$\\ + \midrule + & \texttt{Interrupt} & $st[sp\shortminus{}2] = node (interrupt, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + & \texttt{RateLimit} & $st[sp\shortminus{}1] = node (ratelimit, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + & \texttt{TuneRate} & $st[sp\shortminus{}1] = node (tunerate, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \midrule + & \texttt{DHTTemp} $i$ & $st[sp+1] = node (dhttemp, i)$ & $sp+1$ & $pc+3$\\ + & \texttt{DHTHumid} $i$ & $st[sp+1] = node (dhthumid, i)$ & $sp+1$ & $pc+3$\\ + \end{longtable} +\end{landscape} \input{subfilepostamble} -\end{document} +\end{document}%chktex 16 diff --git a/appx/c4hp.tex b/appx/c4hp.tex index bbe1858..5f8875c 100644 --- a/appx/c4hp.tex +++ b/appx/c4hp.tex @@ -2,8 +2,11 @@ \input{subfilepreamble} +\setcounter{chapter}{0} + \begin{document} \input{subfileprefix} +\ifSubfilesClassLoaded{\appendix}{} \chapter{\texorpdfstring{\glsentrytext{CLEAN}}{Clean} for \texorpdfstring{\glsentrytext{HASKELL}}{Haskell} Programmers}% \label{chp:clean_for_haskell_programmers} @@ -18,15 +21,15 @@ While \gls{CLEAN} and \gls{HASKELL} were both conceived around 1987 and have sim This section describes some of the history of \gls{CLEAN} and provides a crash course in \gls{CLEAN} pecularities written for \gls{HASKELL} programmers. It is based on the -\Gls{CLEAN}---acronym for Clean \glsxtrlong{LEAN}~\citep{barendregt_towards_1987}---, was originally designed as a \gls{GRS} core language but quickly served as an intermediate language for other functional languages~\citep{brus_clean_1987}. -In the early days it has also been called \emph{Concurrent} \gls{CLEAN}~\citep{nocker_concurrent_1991} but these days the language has no support for this anymore. -Fast forward thirty years, \gls{CLEAN} is now a robust language with state-of-the-art features and is actually used in industry as well as academia---albeit in select areas of the world~\citep{plasmeijer_clean_2021}. +\Gls{CLEAN}---acronym for Clean \glsxtrlong{LEAN} \citep{barendregt_towards_1987}---, was originally designed as a \gls{GRS} core language but quickly served as an intermediate language for other functional languages \citep{brus_clean_1987}. +In the early days it has also been called \emph{Concurrent} \gls{CLEAN} \citep{nocker_concurrent_1991} but these days the language has no support for this anymore. +Fast forward thirty years, \gls{CLEAN} is now a robust language with state-of-the-art features and is actually used in industry as well as academia---albeit in select areas of the world \citep{plasmeijer_clean_2021}. Initially, when it was used mostly as an intermediate language, it had a fairly spartan syntax. However, over the years, the syntax got friendlier and it currently it looks a lot like \gls{HASKELL}. -In the past, a \emph{double-edged} fronted even existed that allowed \gls{CLEAN} to be extended with \gls{HASKELL98} syntax and vice versa, however this frontend is no longer maintained~\citep{van_groningen_exchanging_2010}. -This chapter therefore gives a brief syntactical and functional comparison, a complete specification of the \gls{CLEAN} language can be found in the latest language report~\citep{plasmeijer_clean_2021}. -Many of this is based on work by Achten although that was based on \gls{CLEAN} 2.1 and \gls{HASKELL98}~\citep{achten_clean_2007}. +In the past, a \emph{double-edged} fronted even existed that allowed \gls{CLEAN} to be extended with \gls{HASKELL98} syntax and vice versa, however this frontend is no longer maintained \citep{van_groningen_exchanging_2010}. +This chapter therefore gives a brief syntactical and functional comparison, a complete specification of the \gls{CLEAN} language can be found in the latest language report \citep{plasmeijer_clean_2021}. +Many of this is based on work by Achten although that was based on \gls{CLEAN} 2.1 and \gls{HASKELL98} \citep{achten_clean_2007}. When \gls{HASKELL} is mentioned we actually mean \gls{GHC}'s \gls{HASKELL}\footnote{If an extension is enabled, a footnote is added stating that \GHCmod{SomeExtension} is required.} this is denoted and by \gls{CLEAN} we mean \gls{CLEAN} 3.1's compiler with the \gls{ITASK} extensions. \section{Features} @@ -45,12 +48,12 @@ In \gls{HASKELL}, in patterns, strictness can be enforced using \haskellinline{! Within functions the strict let (\cleaninline{#!}) can be used to force evaluate an expression, in \gls{HASKELL} \haskellinline{seq} or \haskellinline{\$!} is used for this. \subsection{Uniqueness typing} -Types in \gls{CLEAN} may be \emph{unique}, which means that they may not be shared~\citep{barendsen_uniqueness_1996}. +Types in \gls{CLEAN} may be \emph{unique}, which means that they may not be shared \citep{barendsen_uniqueness_1996}. The uniqueness type system allows the compiler to generate efficient code because unique data structures can be destructively updated. -Furthermore, uniqueness typing serves as a model for side effects as well~\citep{achten_high_1993,achten_ins_1995}. -\Gls{CLEAN} uses the \emph{world-as-value} paradigm where \cleaninline{World} represents the external environment and is always unique~\citep{backus_introduction_1990}. +Furthermore, uniqueness typing serves as a model for side effects as well \citep{achten_high_1993,achten_ins_1995}. +\Gls{CLEAN} uses the \emph{world-as-value} paradigm where \cleaninline{World} represents the external environment and is always unique \citep{backus_introduction_1990}. A program with side effects is characterised by a \cleaninline{Start :: *World -> *World} start function. -In \gls{HASKELL}, interaction with the world is done using the \haskellinline{IO} monad~\citep{peyton_jones_imperative_1993}. +In \gls{HASKELL}, interaction with the world is done using the \haskellinline{IO} monad \citep{peyton_jones_imperative_1993}. The \haskellinline{IO} monad could very well be---and actually is---implemented in \gls{CLEAN} using a state monad with the \cleaninline{World} as a state. Besides marking types as unique, it is also possible to mark them with uniqueness attributes variables \cleaninline{u:} and define constraints on them. For example, to make sure that an argument of a function is at least as unique as another argument. @@ -68,7 +71,7 @@ f :: v:a u:b -> u:b, [v<=u] // f works when a is less unique than b %:: T = T (Int -> *(*World -> *World)) // Writing :: T = T (Int *World -> *World) won't work \subsection{Expressions} -Patterns in \gls{CLEAN} can be used as predicates as well~\citep[\citesection{3.4.3}]{plasmeijer_clean_2021}. +Patterns in \gls{CLEAN} can be used as predicates as well \citep[\citesection{3.4.3}]{plasmeijer_clean_2021}. Using the \cleaninline{=:} operator, a value can be tested against a pattern. Variable names are not allowed but wildcard patterns \cleaninline{\_} are. @@ -84,7 +87,7 @@ ifAB x ifa ifb = if (x =: (A _)) ifa ifb Due to the nature of uniqueness typing, many functions in \gls{CLEAN} are state transition functions with possibly unique states. The \emph{let before} construct allows the programmer to specify sequential actions without having to invent unique names for the different versions of the state. -\Cref{lst:let_before} shows an example of the usage of the \emph{let before} construct (adapted from~\citep[\citesection{3.5.4}]{plasmeijer_clean_2021}). +\Cref{lst:let_before} shows an example of the usage of the \emph{let before} construct (adapted from \citep[\citesection{3.5.4}]{plasmeijer_clean_2021}). \begin{lstClean}[label={lst:let_before},caption={Let before expression example.}] readChars :: *File -> ([Char], *File) @@ -96,8 +99,8 @@ readChars file \end{lstClean} \subsection{Generics} -Polytypic functions~\citep{jeuring_polytypic_1996}---also known as generic or kind-indexed fuctions---are built into \gls{CLEAN}~\citep[\citesection{7.1}]{plasmeijer_clean_2021}\citep{alimarine_generic_2005} whereas in \gls{HASKELL} they are implemented as a library~\citep[\citesection{6.19.1}]{ghc_team_ghc_2021}. -The implementation of generics in \gls{CLEAN} is very similar to that of Generic H$\forall$skell~\citep{hinze_generic_2003}. +Polytypic functions \citep{jeuring_polytypic_1996}---also known as generic or kind-indexed fuctions---are built into \gls{CLEAN} \citep[\citesection{7.1}]{plasmeijer_clean_2021}\citep{alimarine_generic_2005} whereas in \gls{HASKELL} they are implemented as a library \citep[\citesection{6.19.1}]{ghc_team_ghc_2021}. +The implementation of generics in \gls{CLEAN} is very similar to that of Generic H$\forall$skell \citep{hinze_generic_2003}. %When calling a generic function, the kind must always be specified and depending on the kind, the function may require more arguments. For example, defining a generic equality is done as in \cref{lst:generic_eq}. @@ -107,8 +110,8 @@ Metadata about the types is available using the \cleaninline{of} syntax that giv \cleaninputlisting[language=Clean,firstline=4,label={lst:generic_print},caption={Generic print function in \gls{CLEAN}.}]{lst/generic_print.icl} \subsection{\texorpdfstring{\glsentrytext{GADT}}{GADT}s} -\Glspl{GADT} are enriched data types that allow the type instantiation of the constructor to be explicitly defined~\citep{cheney_first-class_2003,hinze_fun_2003}. -While \glspl{GADT} are not natively supported in \gls{CLEAN}, they can be simulated using embedding-projection pairs or equivalence types~\citep[\citesection{2.2}]{cheney_lightweight_2002}. +\Glspl{GADT} are enriched data types that allow the type instantiation of the constructor to be explicitly defined \citep{cheney_first-class_2003,hinze_fun_2003}. +While \glspl{GADT} are not natively supported in \gls{CLEAN}, they can be simulated using embedding-projection pairs or equivalence types \citep[\citesection{2.2}]{cheney_lightweight_2002}. To illustrate this, \cref{lst:gadt_clean} shows an example \gls{GADT} that would be implemented in \gls{HASKELL} as done in \cref{lst:gadt_haskell}\requiresGHCmod{GADTs}. \cleaninputlisting[firstline=4,lastline=24,label={lst:gadt_clean},caption={Expression \gls{GADT} using equivalence types.}]{lst/expr_gadt.icl} diff --git a/appx/lst/generic_eq.icl b/appx/lst/generic_eq.icl index 7f0a6c9..f3ef2b6 100644 --- a/appx/lst/generic_eq.icl +++ b/appx/lst/generic_eq.icl @@ -20,5 +20,6 @@ gEq{|EITHER|} _ _ _ _ = False :: T = C1 Int ([Char], ?Bool) | C2 derive gEq [], T, (,), ? -Start = (gEq{|*|} C2 (C1 42 ([], ?Just True)), gEq{|*->*|} (<) [1,2,3] [2,3,4]) +Start = (gEq{|*|} C2 (C1 42 ([], ?Just True)) + , gEq{|*->*|} (<) [1,2,3] [2,3,4]) // (False, True) diff --git a/appx/lst/generic_print.icl b/appx/lst/generic_print.icl index ef13640..a802d99 100644 --- a/appx/lst/generic_print.icl +++ b/appx/lst/generic_print.icl @@ -13,11 +13,13 @@ gPrint{|EITHER|} fl _ (LEFT x) acc = fl x acc gPrint{|EITHER|} _ fr (RIGHT x) acc = fr x acc gPrint{|OBJECT|} f (OBJECT x) acc = f x acc -gPrint{|CONS of gcd|} f (CONS x) acc = ["(", gcd.gcd_name, " ":f x [")":acc]] -gPrint{|RECORD of grd|} f (RECORD x) acc = ["{", grd.grd_name, " | ":f x ["}":acc]] -gPrint{|FIELD of gfd|} f (FIELD x) acc = [pre, gfd.gfd_name, "=":f x acc] -where - pre = if (gfd.gfd_index == 0) "" ", " +gPrint{|CONS of gcd|} f (CONS x) acc + = ["(", gcd.gcd_name, " ":f x [")":acc]] +gPrint{|RECORD of grd|} f (RECORD x) acc + = ["{", grd.grd_name, " | ":f x ["}":acc]] +gPrint{|FIELD of gfd|} f (FIELD x) acc + = [pre, gfd.gfd_name, "=":f x acc] +where pre = if (gfd.gfd_index == 0) "" ", " :: T = {f1 :: Int, f2 :: (Real, [?Int])} derive gPrint (,), [], ?, T diff --git a/appx/mtask_aux.tex b/appx/mtask_aux.tex index 4f1945f..74273a4 100644 --- a/appx/mtask_aux.tex +++ b/appx/mtask_aux.tex @@ -2,8 +2,11 @@ \input{subfilepreamble} +\setcounter{chapter}{1} + \begin{document} \input{subfileprefix} +\ifSubfilesClassLoaded{\appendix}{} \chapter{Auxiliary \texorpdfstring{\glsentrytext{MTASK}}{mTask} type classes}% \label{chp:mtask_aux} \lstset{basicstyle=\tt\footnotesize} diff --git a/concl/concl.tex b/concl/concl.tex index df584ca..2e7038e 100644 --- a/concl/concl.tex +++ b/concl/concl.tex @@ -7,12 +7,13 @@ \begin{document} \input{subfileprefix} \chapter{Coda}% -\label{chp:conclusion} +\label{chp:conclusion}% \begin{chapterabstract} This chapter concludes the dissertation and reflects on the work. \end{chapterabstract} \section{Reflections} While the term \gls{IOT} has already been known for almost thirty years, the exponential growth of the number of \gls{IOT} edge devices is really ramping up recently. +\todo{chap\-ter\-ab\-stract weg?} Programming layered systems such as \gls{IOT} systems is very complex because on each layer of the system, different computers, hardware architectures, programming languages, programming paradigms, and abstraction levels are required. This generates a lot of semantic friction. Furthermore, \gls{IOT} systems are very convoluted because they are dynamic, multi-tiered, multi-user, multitasking, interactive, distributed, and collaborative. diff --git a/dsl/class.tex b/dsl/class.tex index 78a2474..89cf263 100644 --- a/dsl/class.tex +++ b/dsl/class.tex @@ -685,7 +685,7 @@ In classy deep embedding, there is either a bit more scaffolding and boilerplate Little boilerplate denotes the amount of scaffolding and boilerplate required. For example, hybrid embedding requires a transcoding step between the deep syntax and the shallow core language. -\begin{table}[ht] +\begin{table} \begin{threeparttable}[b] \small \caption{Comparison of embedding techniques, extended from \citet[\citesection{3.6}]{sun_compositional_2022}.}% @@ -848,7 +848,7 @@ e1 = neg (neg (Lit 42 `Add` (Lit 38 `subt` Lit 4))) Finally, using the \GHCmod{TypeFamilies} extension, type families can be created for bundling \haskelllhstexinline{`In`} constraints (\haskelllhstexinline{UsingExt}) and \haskelllhstexinline{CreateRecord} constraints \mbox{(\haskelllhstexinline{DependsOn})}, making the syntax even more descriptive. E.g.\ \mbox{\haskelllhstexinline{UsingExt '[A, B, C] c}} expands to\newline\haskelllhstexinline{(CreateRecord (A c) c, CreateRecord (B c) c, CreateRecord (C c) c)}. -Similarly, \haskelllhstexinline{DependsOn '[A, B, C] s} expands to \haskelllhstexinline{(A `In` s, B `In` s, C `In` s)}. +\hspace{-1.42284pt} Similarly, \haskelllhstexinline{DependsOn '[A, B, C] s} expands to \haskelllhstexinline{(A `In` s, B `In` s, C `In` s)}. \begin{lstHaskellLhstex} type family UsingExt cs c :: Constraint where diff --git a/front/motto.tex b/front/motto.tex index 3f12574..b3d6c74 100644 --- a/front/motto.tex +++ b/front/motto.tex @@ -13,8 +13,8 @@ H.P. (Howard) Lovecraft } \epigraph{% - \selectlanguage{russian}Рукописи не горят\\ - \selectlanguage{british} (Manuscripts don't burn) + \selectlanguage{russian}Рукописи не горят.\\ + \selectlanguage{british} (Manuscripts don't burn.) }{% \selectlanguage{russian}М.А.\ (Mихаил) Булгаков\\ \selectlanguage{british} (M.A.\ (Mikhail) Bulgakov) diff --git a/intro/intro.tex b/intro/intro.tex index 5e1453c..0997df7 100644 --- a/intro/intro.tex +++ b/intro/intro.tex @@ -17,31 +17,32 @@ \end{itemize} \end{chapterabstract} -There are at least 13.4 billion devices connected to the internet at the time of writing\footnote{\refurl{https://transformainsights.com/research/tam/market}{\formatdate{13}{10}{2022}}}. -Each of these senses, acts, or otherwise interacts with people, other computers, and the environment surrounding us. +There are at least 13.4 billion devices connected to the internet at the time of writing \citep{transformation_insights_current_2023}.%\footnote{\refurl{https://transformainsights.com/research/forecast/highlights}{\formatdate{19}{01}{2023}}}. +Each of these sense, act, or otherwise interact with people, other computers, and the environment surrounding us. Despite their immense diversity, they are all computers. And as computers, they require software to operate. An increasing amount of these connected devices are so-called \emph{edge devices} that operate in the \gls{IOT}. -Edge devices are the leafs of the \gls{IOT} systems, they perform the interaction with the physical world and are physically embedded in the fabric. +Edge devices are the leafs of the \gls{IOT} systems, they perform the interaction with the physical world and are often physically embedded in the fabric. They usually reside in hard-to-reach places such as light bulbs, smart electricity meters, or even farm animals. -Equipped with a lot of connectivity for integrating peripherals such as sensors and actuators, makes them very suitable to interact with their surroundings. +Microcontrollers are equipped with a lot of connectivity for integrating peripherals such as sensors and actuators. +The connectivity makes them very suitable to interact with their surroundings. Typically, these edge devices are powered by microcontrollers. These miniature computers contain integrated circuits that accommodate a microprocessor designed for use in embedded applications. -Hence, microcontrollers are therefore cheap; tiny; have little memory; and contain a slow, but energy-efficient processor. +Hence, microcontrollers are cheap; tiny; have little memory; and contain a slow, but energy-efficient processor. -Unlike the conductor in the orchestra waving their baton to instruct the ensemble of instruments, in the universe of software there is room for little error. -Moreover, in dynamic \gls{IOT} applications, often there is not even a conductor or coordinator. +Unlike the conductor in an orchestra waving their baton to instruct the ensemble of instruments, in the universe of software there is room for little error. +Moreover, in dynamic \gls{IOT} applications, often there is not even a coordinating conductor. Even though edge devices—the instruments—come and go, perform their own pieces, or are instructed to perform a certain piece, they operate without a central authority. In the traditional setting, an \gls{IOT} engineer has to program each device and their interoperation using different programming paradigms, programming languages, and abstraction levels. -Thus resulting in semantic friction, making programming and maintaining \gls{IOT} systems is a complex and error-prone process. +Thus resulting in semantic friction, which makes programming and maintaining \gls{IOT} systems a complex and error-prone process. This dissertation describes the research carried out around orchestrating these complex \gls{IOT} systems using \gls{TOP}. \Gls{TOP} is an innovative tierless programming paradigm for interactive multi-layered systems. -By utilising advanced compiler technologies, much of the internals, communications, and interoperation between the tiers\slash{}layers of the applications is automatically generated. +By utilising advanced compiler technologies, much of the internals, communication, and interoperation between the tiers or layers of the applications is automatically generated. From a single declarative specification of the work required, the compiler makes a ready-for-work application consisting of interconnected components for all tiers. -For example, the \gls{TOP} system \gls{ITASK} can be used to program all layers of a multi-user distributed web applications from a single source specification. -It is implemented in \gls{CLEAN}, executes also in \gls{CLEAN}'s general-purpose run time, and requires relatively powerful hardware. +For example, the \gls{TOP} system \gls{ITASK} is used to program all layers of multi-user distributed web applications from a single source specification. +It is implemented in \gls{CLEAN}, executes in \gls{CLEAN}'s general-purpose run time, and therefore requires relatively powerful hardware. The high hardware requirements are no problem for regular computers but impractical for the average edge device. This is where \glspl{DSL} must be brought into play. @@ -51,8 +52,8 @@ Consequently, jargon does not have to be expressed in the language itself, but t Furthermore, the \gls{DSL} can eschew language or system features that are irrelevant for the domain. To incorporate the plethora of edge devices in the orchestra of a \gls{TOP} system, the \gls{MTASK} system is used. -\Gls{MTASK} is a novel programming language for programming \gls{IOT} edge devices using \gls{TOP}. -Where \gls{ITASK} abstracts away from the gritty details of multi-tier web applications, \gls{MTASK} has domain-specific abstractions for \gls{IOT} edge devices, maintaining the high abstraction level that \gls{TOP} generally offers. +The \gls{MTASK} language is a novel programming language for programming \gls{IOT} edge devices using \gls{TOP}. +Where \gls{ITASK} abstracts away from the gritty details of multi-tier web applications, \gls{MTASK} has domain-specific abstractions for \gls{IOT} edge devices, maintaining the high abstraction level that \gls{TOP} offers. As it is integrated with \gls{ITASK}, it allows for all layers of an \gls{IOT} application to be programmed from a single source. \section{Reading guide}% @@ -66,8 +67,8 @@ This dissertation consists of three episodes. \Cref{prt:dsl} is a paper-based---otherwise known as cumulative---episode containing chapters that provide insight in advanced \gls{DSL} embedding techniques for \gls{FP} languages. The chapters are readable independently. \Cref{prt:top} is a monograph showing \gls{MTASK}, a \gls{TOP} \gls{DSL} for the \gls{IOT}. -Hence, the chapters are best read in order. -It introduces \gls{IOT} edge device programming, shows the complete \gls{MTASK} language, provides details on how \gls{MTASK} is integrated with \gls{ITASK}, shows how the byte code compiler is implemented, with a guide for green computing with \gls{ITASK} and ends with a conclusion and overview of future and related work. +Hence, the chapters in this episode are best read in order. +It introduces \gls{IOT} edge device programming, shows the complete \gls{MTASK} language, provides details on how \gls{MTASK} is integrated with \gls{ITASK}, shows how the byte code compiler is implemented, presents a guide for green computing with \gls{ITASK}, and ends with a conclusion and overview of future and related work. \Cref{prt:tvt} is a single chapter based on a journal article in which traditional tiered \gls{IOT} programming is qualitatively and quantitatively compared to tierless programming using a real-world application. The chapter is readable independently. @@ -97,38 +98,38 @@ For the intents and purposes of this thesis, the layered architecture as shown i \label{fig:iot-layers} \end{figure} -To explain the tiers, an example \gls{IOT} application---home automation---is dissected accordingly. -Closest to the end-user is the presentation layer, it provides the interface between the user and \gls{IOT} systems. -In home automation this may be a web interface, or an app used on a phone or wall-mounted tablet to interact with edge devices and view sensor data. +To explain the tiers, an example \gls{IOT} application---home automation---is dissected. +Closest to the end-user is the presentation layer, it provides the interface between the user and the \gls{IOT} systems. +In home automation this may be a web interface, an app used on a phone, or wall-mounted tablet to interact with edge devices and view sensor data. -The application layer provides the \glspl{API}, data interfaces, data processing, and data storage of \gls{IOT} systems. +The application layer provides the \glspl{API}, data interfaces, data storage processing, and data processing of \gls{IOT} systems. A cloud server or local server provides this layer in a typical home automation application. The perception layer---also called edge layer---collects the data and interacts with the environment. It consists of edge devices such as microcontrollers equipped with various sensors and actuators. -In home automation this layer consists of all the devices hosting sensors and actuators such as smart light bulbs, actuators to open doors, or temperature and humidity sensors. +In home automation this layer consists of all devices hosting sensors and actuators such as smart light bulbs, actuators to open doors, or temperature and humidity sensors. All layers are connected using the network layer. In some applications this is implemented using conventional networking techniques such as Wi-Fi or Ethernet. -However, network technology that is tailored to the needs of the specific interconnection between the two layers have become increasingly popular. +However, network technology that is tailored to the needs of the specific interconnection between the two layers are increasingly popular. Examples of this are BLE, LoRa, ZigBee, and LTE-M as a communication protocol for connecting the perception layer to the application layer using \gls{IOT} transport protocols such as \gls{MQTT}. -Protocols such as HTTP, AJAX, and WebSocket connecting the presentation layer to the application layer that are designed for the use in web applications. +Protocols such as HTTP, AJAX, and WebSocket connecting the presentation layer to the application layer that are designed for the use in web applications. Across the layers, the devices are a large heterogeneous collection of different platforms, protocols, paradigms, and programming languages often resulting in impedance problems or semantic friction between layers when programming \citep{ireland_classification_2009}. Even more so, the perception layer itself is often a heterogeneous collection of microcontrollers in itself, each having their own peculiarities, language of choice, and hardware interfaces. -As edge hardware needs to be cheap, small-scale, and energy efficient, the microcontrollers used to power them do not have a lot of computational power, only a soup\c{c}on of memory, and little communication bandwidth. +As edge hardware needs to be cheap, small scale, and energy efficient, the microcontrollers used to power them do not have a lot of computational power, only a soup\c{c}on of memory, and little communication bandwidth. Typically, these devices are unable to run a full-fledged general-purpose \gls{OS}. Rather they employ compiled firmware written in imperative languages that combines all tasks on the device in a single program. While devices are getting a bit faster, smaller, and cheaper, they keep these properties to an extent. -For example, more powerful microcontrollers are capable of running \gls{RTOS}, but this still requires many resources and fixes the programs at compile time. -As a consequence, the flexibility is greatly reduced for dynamic systems in which tasks are created on the fly, executed on demand, or require parallel execution. +For example, more powerful microcontrollers are capable of running \glspl{RTOS}, but this still requires a lot of resources and fixes the programs at compile time. +As a consequence, the flexibility is greatly reduced for dynamic systems in which tasks are created on the fly, executed on demand, require parallel execution, or have dynamic scheduling behaviour. As program memory is mostly flash-based and only lasts a couple of thousands of writes before it wears out, it is not suitable for repeated reconfiguring and reprogramming. These problems can be mitigated by dynamically sending code to be interpreted to the microcontroller. With interpretation, a specialized interpreter is flashed in the program memory once it receives the program code to execute at run time. Therefore, as the programs are not stored in the flash memory, it does not wear out. It is challenging to create interpreters for small edge devices due to the severe hardware restrictions. -This dissertation describes a \gls{DSL} that encompasses the high-level programming concepts of \gls{TOP}, while it can be executed on edge devices with very limited requirements. +This dissertation describes a \gls{DSL} that includes the high-level programming concepts of \gls{TOP}, while it can be executed on edge devices with very limited hardware requirements. It does so by compiling the \gls{DSL} to byte code that is executed in a feather-light domain-specific \gls{OS}. \section{\texorpdfstring{\Glsxtrlongpl{DSL}}{Domain-specific languages}}% @@ -136,11 +137,11 @@ It does so by compiling the \gls{DSL} to byte code that is executed in a feather % General Programming languages can be divided up into two categories: \glspl{DSL} and \glspl{GPL} \citep{fowler_domain_2010}. Where \glspl{GPL} are not made with a demarcated area in mind, \glspl{DSL} are tailor-made for a specific domain. -Writing idiomatic domain-specific code in a \gls{DSL} is easier and requires less background knowledge about a \gls{GPL}. +Writing idiomatic domain-specific code in a \gls{DSL} is easier and requires less background knowledge. This does come at the cost of the \gls{DSL} being sometimes less expressive to an extent that it may not even be Turing complete. \Glspl{DSL} come in two main flavours: standalone and embedded (\cref{sec:standalone_embedded})\footnote{Standalone and embedded are also called external and internal respectively.}. Standalone languages are languages for which the complete toolchain has been developed, just as for any other \gls{GPL}. -Embedded languages piggyback on an existing \gls{GPL}, they are defined in terms of their host language. +Embedded languages piggyback on an existing language, they are defined in terms of their host language. \Glspl{EDSL} can further be classified into heterogeneous and homogeneous languages (\cref{sec:hetero_homo}). In homogeneous languages all components are integrated whereas in heterogeneous \glspl{DSL}, some parts are agnostic of the other systems, e.g.\ a \gls{DSL} that generates code for execution on a totally different system. This hyponymy is shown in \cref{fig:hyponymy_of_dsls}. @@ -148,7 +149,7 @@ This hyponymy is shown in \cref{fig:hyponymy_of_dsls}. \begin{figure} \centering \includestandalone{hyponymy_of_dsls} - \caption{A hyponymy of \glspl{DSL} (adapted from \citet[\citepage{2}]{mernik_extensible_2013})}% + \caption{A hyponymy of \glspl{DSL} (adapted from \citet[\citepage{2}]{mernik_extensible_2013}).}% \label{fig:hyponymy_of_dsls} \end{figure} @@ -157,16 +158,16 @@ This hyponymy is shown in \cref{fig:hyponymy_of_dsls}. \glspl{DSL} where historically created as standalone languages, meaning that all machinery is developed solely for the language. The advantage of this approach is that the language designer is free to define the syntax and type system of the language as they wish, not being restricted by any constraint. Unfortunately it also means that they need to develop a compiler or interpreter, and all the scaffolding for the language, making standalone \glspl{DSL} costly to create. -Examples of standalone \glspl{DSL} are \TeX, \LaTeX, make, yacc, XML, SQL, \etc. +Examples of standalone \glspl{DSL} are \TeX, make, yacc, XML, SQL, \etc. -The dichotomous approach is embedding the \gls{DSL} in a host language, i.e.\ \glspl{EDSL} \citep{hudak_modular_1998}. +The dichotomous approach to standalone \glspl{DSL} is embedding the \gls{DSL} in a host language, i.e.\ \glspl{EDSL} \citep{hudak_modular_1998}. By defining the language as constructs in the host language, much of the machinery is inherited \citep{krishnamurthi_linguistic_2001}. -This greatly reduces the cost of creating embedded languages and shields the user from having to learn a general-purpose language and toolchain. +This greatly reduces the cost of creating embedded languages and shields the user from having to learn the host language and toolchain. However, there are two sides to this coin. -If the syntax of the host language is not very flexible, the syntax of the \gls{DSL} may become clumsy. +If the syntax of the host language is not very flexible, the syntax of the \gls{DSL} could become clumsy. Furthermore, \gls{DSL} errors shown to the programmer may be larded with host language errors, making it difficult for a non-expert of the host language to work with the \gls{DSL}. \Gls{FP} languages are especially suitable for hosting embedded \glspl{DSL}. -They offer tooling for building abstraction levels by a strong and versatile type systems, minimal but flexible syntax, and offer referential transparency. +They offer tooling for building abstraction levels by a strong and versatile type systems, minimal but flexible syntax, and referential transparency. \subsection{Heterogeneity and homogeneity}% \label{sec:hetero_homo} @@ -177,18 +178,18 @@ They offer tooling for building abstraction levels by a strong and versatile typ } \end{quote} -Homogeneous \glspl{EDSL} are therefore languages that are solely defined as an extension to their host language. +Homogeneous \glspl{EDSL} are languages that are solely defined as an extension to their host language. They often restrict features of the host language to provide a safer interface or capture an idiomatic pattern in the host language for reuse. The difference between a library and a homogeneous \glspl{EDSL} is not always clear. Examples of homogeneous \glspl{EDSL} are libraries such as ones for sets, regions, but also more complex tasks such as \glspl{GUI}. On the other hand, heterogeneous \glspl{EDSL} are languages that are not executed in the host language. For example, \citet{elliott_compiling_2003} describe the language Pan, for which the final representation in the host language is a compiler that will, when executed, generate code for a completely different target platform. -In fact, \gls{ITASK} and \gls{MTASK} are embedded \glspl{DSL}. -Programs written in \gls{ITASK} run in the host language, and is a homogeneous \gls{DSL}. +In fact, both \gls{ITASK} and \gls{MTASK} are \glspl{EDSL}. +Programs written in \gls{ITASK} run in the host language, and it is a homogeneous \gls{DSL}. Tasks written using \gls{MTASK} are dynamically compiled to byte code for an edge device, making it a heterogeneous \gls{DSL}. The interpreter running on the edge device has no knowledge of the higher level task specification. -It just interprets the byte code it was sent, rewrites the tasks and publishes task values and \gls{SDS} updates. +It just interprets the byte code it was sent and takes care of the communication. \section{\texorpdfstring{\Glsxtrlong{TOP}}{Task-oriented programming}}% \label{sec:back_top} @@ -231,23 +232,24 @@ This approach to software development is called \gls{TOSD} \citep{wang_maintaini The \gls{UOD} is explicitly and separately modelled by the relations that exist in the functions of the host language. \end{description} -\Cref{fig:tosd} differs from the presented \gls{IOT} architecture because they represent separate concepts. -The \gls{IOT} architecture from \cref{fig:iot-layers} describes an execution architecture whereas the \gls{TOSD} figure describes a software development model. -E.g.\ from a software development perspective, a task is a task, whether it is executed on a microcontroller, a server or a client. -Only once a task is executed, the location of the execution becomes important, but this is taken care of by the system. +\Cref{fig:tosd} differs from the presented \gls{IOT} architecture shown in \cref{fig:iot-layers} because they represent different concepts. +The \gls{IOT} architecture is an execution architecture whereas \gls{TOSD} is a software development model. +E.g.\ from a software development perspective, a task is a task, whether it is executed on a microcontroller, a server, or a client. +Only when a task is executed, the location of the execution becomes important, but this is taken care of by the system. Some concepts from the \gls{TOSD} model can be mapped upon the \gls{IOT} architecture though. Applying the concepts of \gls{TOSD} to \gls{IOT} systems can be done in two ways. Firstly, edge devices can be seen as simple resources, thus accessed through \glspl{SDS}. The second view is that edge devices contain miniature \gls{TOP} systems in itself. The individual components in the miniature systems, the tasks, the \glspl{SDS}, are, in the eventual execution, connected to the main system. -\subsection{\texorpdfstring{\Gls{ITASK}}{ITask}} +\subsection{The \texorpdfstring{\gls{ITASK}}{iTask} system} The concept of \gls{TOP} originated from the \gls{ITASK} framework, a declarative language and \gls{TOP} engine for defining interactive multi-user distributed web applications. -\Gls{ITASK} is implemented as an \gls{EDSL} in the lazy pure \gls{FP} language \gls{CLEAN} \citep{plasmeijer_itasks:_2007,plasmeijer_task-oriented_2012}. +The \gls{ITASK} system is implemented as an \gls{EDSL} in the lazy pure \gls{FP} language \gls{CLEAN}\footnotemark{} \citep{plasmeijer_itasks:_2007,plasmeijer_task-oriented_2012}. +\footnotetext{\Cref{chp:clean_for_haskell_programmers} contains a guide for \gls{CLEAN} tailored to \gls{HASKELL} programmers.} From the structural properties of the data types and the current status of the work to be done, the entire \gls{UI} is automatically generated. Browsers are powering \gls{ITASK}'s presentation layer. The framework is built on top of standard web techniques such as JavaScript, HTML, and {CSS}. -\Gls{ITASK} code running in the browser relies on an interpreter that operates on \gls{CLEAN}'s intermediate language \gls{ABC} \citep{staps_lazy_2019}. +The browser runs the actual \gls{ITASK} code using an interpreter that operates on \gls{CLEAN}'s intermediate language \gls{ABC} \citep{staps_lazy_2019}. Tasks in \gls{ITASK} have either \emph{no value}, an \emph{unstable} or a \emph{stable} task value. For example, an editor for filling in a form initially has no value. @@ -263,19 +265,20 @@ The allowed task value transitions are shown in \cref{fig:taskvalue}. \end{figure} As an example, \cref{lst:todo,fig:todo} show the code and \gls{UI} for an interactive to-do list application. -The user can modify a shared to-do list through an editor directly or using some predefined actions. +The user modifies a shared to-do list through an editor directly or using some predefined actions. Furthermore, in parallel, the length of the list is shown to demonstrate \glspl{SDS}. Using \gls{ITASK}, complex collaborations of users and tasks can be described on a high level. From the data type definitions (\cref{lst:todo_dt}), using generic programming (\cref{lst:todo_derive}), the \glspl{UI} for the data types are automatically generated. -Then, using the parallel task combinator (\cleaninline{-\|\|}) that uses the left-hand side's result the task for updating the to-dos (\cref{lst:todo_update}) and the task for viewing the length are combined (\cref{lst:todo_length}). +Then, using the parallel task combinator (\cleaninline{-\|\|}) the task for updating the to-dos (\cref{lst:todo_update}) and the task for viewing the length are combined (\cref{lst:todo_length}). +This particular parallel combinator uses the result of the left-hand side task. Both tasks operate on the to-do \gls{SDS} (\cref{lst:todo_sds}). -The task for updating the to-do list is just an editor (\cref{lst:todo_editor}) combined using a step combinator (\crefrange{lst:todo_contfro}{lst:todo_contto}). -The actions either change the value, sorting or clearing it, or terminates the task by returning the current value of the \gls{SDS}. +The task for updating the to-do list is an editor (\cref{lst:todo_editor}) combined using a step combinator (\crefrange{lst:todo_contfro}{lst:todo_contto}). +The actions either change the value, sorting or clearing it, or terminate the task by returning the current value of the \gls{SDS}. Special combinators (e.g.\ \cleaninline{@>>} at \cref{lst:todo_ui}) are used to tweak the \gls{UI} to display informative labels. -\cleaninputlisting[float=,firstline=6,lastline=22,tabsize=3,numbers=left,caption={The code for the shared to-do list in \gls{ITASK}\footnotemark.},label={lst:todo}]{lst/sharedlist.icl} -\footnotetext{\Cref{chp:clean_for_haskell_programmers} contains a guide for \gls{CLEAN} tailored to \gls{HASKELL} programmers.} +\cleaninputlisting[float=,firstline=6,lastline=22,tabsize=3,numbers=left,caption={The code for the shared to-do list in \gls{ITASK}.},label={lst:todo}]{lst/sharedlist.icl} + \begin{figure} \centering \includegraphics[width=.75\linewidth]{todo0g} @@ -386,7 +389,7 @@ It is compiled from the following publications: \item \emph{A Task-Based \glsxtrshort{DSL} for Microcomputers} \citep{koopman_task-based_2018} is the initial \gls{TOP}\slash{}\gls{MTASK} paper. It provides an overview of the initial \gls{TOP} \gls{MTASK} language and shows first versions of some interpretations. - \item \emph{Task Oriented Programming for the Internet of Things} \citep{lubbers_task_2018}\footnotetext{This work is an extension of my Master's thesis \citeyearpar{lubbers_task_2017}.} + \item \emph{Task Oriented Programming for the Internet of Things} \citep{lubbers_task_2018}\footnotetext{This work is an extension of my Master's thesis \citep{lubbers_task_2017}.} shows how a simple imperative variant of \gls{MTASK} was integrated with \gls{ITASK}. While the language was a lot different from later versions, the integration mechanism is still used in \gls{MTASK} today. % \paragraph{Contribution} diff --git a/intro/iot-layers.tex b/intro/iot-layers.tex index b4ed3ab..5ece800 100644 --- a/intro/iot-layers.tex +++ b/intro/iot-layers.tex @@ -26,6 +26,5 @@ -- ([yshift=2em,xshift=1em]3.north east) -- ([yshift=-2em,xshift=1em]1.south east) -- cycle; - ; \end{tikzpicture} \end{document} diff --git a/other.bib b/other.bib index 0263c33..9f565ba 100644 --- a/other.bib +++ b/other.bib @@ -2173,3 +2173,12 @@ Publisher: Association for Computing Machinery}, keywords = {design principles, Internet of Things, non functional requirements, notation, software design tools, software engineering}, file = {Alhirabi et al. - 2021 - Security and Privacy Requirements for the Internet.pdf:/home/mrl/.local/share/zotero/storage/7UN4IF62/Alhirabi et al. - 2021 - Security and Privacy Requirements for the Internet.pdf:text/html}, } + +@techreport{transformation_insights_current_2023, + title = {Current {IoT} {Forecast} {Highlights}}, + url = {https://transformainsights.com/research/forecast/highlights}, + author = {Transformation Insights}, + month = jan, + year = {2023}, + note = {accessed-on: 2023-01-19}, +} diff --git a/thesis.tex b/thesis.tex index 5cc3f42..c8aebcf 100644 --- a/thesis.tex +++ b/thesis.tex @@ -8,7 +8,12 @@ \input{preamble} % To show hboxes even when in non-draft mode -\overfullrule=1pt +%\overfullrule=1pt +\showboxdepth=\maxdimen% +\showboxbreadth=\maxdimen% +% \showboxdepth=5 +% \showboxbreadth=5 +\setlength{\overfullrule}{20pt} % Just for the todonotes, can go when it's finished \usepackage{todonotes} diff --git a/top/green.tex b/top/green.tex index 2ba1ffd..45e2e0c 100644 --- a/top/green.tex +++ b/top/green.tex @@ -193,7 +193,7 @@ Evaluating a task earlier should not change its result but just consumes more en \end{equ} \subsubsection{Sequential combinators} -For the step combinator (\cref{R:step})---and all other derived sequential combinators---the refresh rate of the left-hand side task is taken since that is the only task that is rewritten. +For the step combinator (\cref{R:step})---and all other derived sequential combinators\nobreak---\nobreak\hskip0ptthe refresh rate of the left-hand side task is taken since that is the only task that is rewritten. Only after stepping, the combinator rewrites to the right-hand side. \subsubsection{Repeating combinators} @@ -585,5 +585,8 @@ Evaluating interrupt task node in the task tree is trivial because all of the wo The task emits the status of the pin as a stable value if the information in the task shows that it was triggered. Otherwise, no value is emitted. +\section{Conclusion} +\todo[inline]{Conclusion} + \input{subfilepostamble} \end{document} diff --git a/top/imp.tex b/top/imp.tex index 1efd361..5264796 100644 --- a/top/imp.tex +++ b/top/imp.tex @@ -204,7 +204,7 @@ instance expr BCInterpret where e >>| tell` [BCLabel endiflabel] \end{lstClean} -\subsection{Functions} +\subsection{Functions}\label{ssec:functions} Compiling functions occurs in $\mathcal{F}$, which generates bytecode for the complete program by iterating over the functions and ending with the main expression. When compiling the body of the function, the arguments of the function are added to the context so that the addresses can be determined when referencing arguments. The main expression is a special case of $\mathcal{F}$ since it neither has arguments nor something to continue. @@ -293,7 +293,7 @@ callFunction :: JumpLabel UInt8 [BCInterpret b] -> BCInterpret c | ... liftFunction :: JumpLabel UInt8 (BCInterpret a) (?UInt8) -> BCInterpret () \end{lstClean} -\subsection{Tasks} +\subsection{Tasks}\label{ssec:scheme_tasks} Task trees are created with the \cleaninline{BCMkTask} instruction that allocates a node and pushes it to the stack. It pops arguments from the stack according to the given task type. The following extension of $\mathcal{E}$ shows this compilation scheme (except for the step combinator, explained in \cref{ssec:step}). @@ -529,5 +529,8 @@ If a task is to be removed, tasks with higher memory addresses are moved down. For task trees---stored in the heap---the \gls{RTS} already marks tasks and task trees as trash during rewriting so the heap can be compacted in a single pass. This is possible because there is no sharing or cycles in task trees and nodes contain pointers pointers to their parent. +\section{Conclusion} +\todo[inline]{conclusion} + \input{subfilepostamble} \end{document} diff --git a/top/int.tex b/top/int.tex index da20690..6b4d574 100644 --- a/top/int.tex +++ b/top/int.tex @@ -163,7 +163,7 @@ This boolean represents the state of the light. The \gls{MTASK} task uses this \gls{SDS} to turn on or off the light. An \gls{ITASK} task that runs in parallel allows interactive updating of this state. -\todo{dit voorbeeld aanhouden of alleen die grote gebruiken} +\todo{dit voor\-beeld aan\-hou\-den of al\-leen die gro\-te ge\-brui\-ken} \begin{lstClean}[label={lst:mtask_liftsds_ex},caption={Interactive light switch program.}] lightswitch dev = withShared False \sh-> -- 2.20.1