restructure files
[msc-thesis1617.git] / mtask.control.tex
diff --git a/mtask.control.tex b/mtask.control.tex
new file mode 100644 (file)
index 0000000..680e10f
--- /dev/null
@@ -0,0 +1,34 @@
+Looping of \glspl{Task} happens because \glspl{Task} are executed after waiting
+a specified amount of time or when they are launched by another \gls{Task} or
+even themselves. Therefore there is no need for loop control flow functionality
+such as \emph{while} or \emph{for} constructions. The main control flow
+operators are the sequence operator and the \emph{if} statement. Both are shown
+in Listing~\ref{lst:control}. The first class of \emph{If} statements describes
+the regular \emph{if} statement. The expressions given can have any role. The
+functional dependency on \CI{s} determines the return type of the statement.
+The listing includes examples of implementations that illustrate this
+dependency. A special \emph{If} statement --- only used for statements --- is
+also added under the name \CI{IF}, of which the \CI{?} is a conditional
+statement to execute.
+
+The sequence operator is straightforward and its only function is to tie
+two expressions together. The left expression is executed first, followed by
+the right expression.
+
+\begin{lstlisting}[%
+       label={lst:control},caption={Control flow operators}]
+class If v q r ~s where
+  If :: (v Bool p) (v t q) (v t r) -> v t s | ...
+
+class IF v where
+  IF :: (v Bool p) (v t q) (v s r) -> v () Stmt | ...
+  (?) infix 1 :: (v Bool p) (v t q) -> v () Stmt | ...
+
+instance If Code Stmt Stmt Stmt
+instance If Code e    Stmt Stmt
+instance If Code Stmt e    Stmt
+instance If Code x    y    Expr
+
+class seq v where
+  (:.) infixr 0 :: (v t p) (v u q) -> v u Stmt | ...
+\end{lstlisting}