X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mtask.control.tex;fp=mtask.control.tex;h=680e10fa009c65d0336dd20fe56d131b13c8390f;hb=6548a5ec9ce8e0df67fc4019625ab5238eb1bf71;hp=0000000000000000000000000000000000000000;hpb=f54205bc29f7dff01f97618d1d83812937333bc4;p=msc-thesis1617.git diff --git a/mtask.control.tex b/mtask.control.tex new file mode 100644 index 0000000..680e10f --- /dev/null +++ b/mtask.control.tex @@ -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}