Merge branch 'master' of git.martlubbers.net:msc-thesis1617
[msc-thesis1617.git] / top.itasks.tex
1 \gls{TOP} is a novel programming paradigm implemented as
2 \gls{iTasks}~\cite{achten_introduction_2015} in the pure lazy functional
3 language \gls{Clean}~\cite{brus_cleanlanguage_1987}. \gls{iTasks} is an
4 \gls{EDSL} to model workflow tasks in the broadest sense. A \gls{Task} is just
5 a function that --- given some state --- returns the observable \CI{TaskValue}.
6 The \CI{TaskValue} of a \CI{Task} can have different states. Not all state
7 transitions are possible as shown in Figure~\ref{fig:taskvalue}. Once a value
8 is stable it can never become unstable again. Stability is often reached by
9 pressing a confirmation button. \glspl{Task} yielding a constant value are
10 immediately stable.
11
12 A simple \gls{iTasks} example illustrating the route to stability of a
13 \gls{Task} in which the user has to enter a full name is shown in
14 Listing~\ref{lst:taskex}. The code is accompanied by screenshots showing the
15 user interface in Figure~\ref{fig:taskex1},~\ref{fig:taskex2}
16 and~\ref{fig:taskex3}. The \CI{TaskValue} of the \gls{Task} is in the first
17 image in the \CI{NoValue} state, the second image does not have all the fields
18 filled in and therefore the \CI{TaskValue} remains \CI{NoValue}. In the third
19 image all fields are entered and the \CI{TaskValue} transitions to the
20 \CI{Unstable} state. When the user presses \emph{Continue} the value becomes
21 \CI{Stable} and cannot be changed any further.
22
23 \begin{figure}[H]
24 \centering
25 \includegraphics[width=.5\linewidth]{fig-taskvalue}
26 \caption{The states of a \CI{TaskValue}}\label{fig:taskvalue}
27 \end{figure}
28
29 \begin{lstlisting}[language=Clean,label={lst:taskex},%
30 caption={An example \gls{Task} for entering a name}]
31 :: Name = { firstname :: String
32 , lastname :: String
33 }
34
35 derive class iTask Name
36
37 enterInformation :: String [EnterOption m] -> (Task m) | iTask m
38
39 enterName :: Task Name
40 enterName = enterInformation "Enter your name" []
41 \end{lstlisting}
42
43 \begin{figure}[H]
44 \centering
45 \begin{subfigure}{.25\textwidth}
46 \centering
47 \includegraphics[width=.9\linewidth]{taskex1}
48 \caption{Initial interface}\label{fig:taskex1}
49 \end{subfigure}
50 \begin{subfigure}{.25\textwidth}
51 \centering
52 \includegraphics[width=.9\linewidth]{taskex2}
53 \caption{Incomplete entrance}\label{fig:taskex2}
54 \end{subfigure}
55 \begin{subfigure}{.25\textwidth}
56 \centering
57 \includegraphics[width=.9\linewidth]{taskex3}
58 \caption{Complete entry}\label{fig:taskex3}
59 \end{subfigure}
60 \caption{Example of a generated user interface}
61 \end{figure}
62
63 For a type to be suitable, it must have instances for a collection of generic
64 functions that is captured in the class \CI{iTask}. Basic types have
65 specialization instances for these functions and show an interface accordingly.
66 Derived interfaces can be modified with decoration operators or specializations
67 can be created.
68