From 0ea729c9667ddd36e834d1056750c467c88df79c Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Sat, 8 Jul 2017 19:47:55 +0200 Subject: [PATCH] fix listings, process comments --- Makefile | 3 ++ arch.communication.tex | 10 ++--- arch.example.tex | 91 +++++++++++++++++++++++++-------------- arch.itasks.tex | 28 ++++++------ conclusion.discussion.tex | 3 +- edsl.class.tex | 2 +- edsl.deep.tex | 4 +- edsl.shallow.tex | 2 +- mtask.class.tex | 2 +- mtask.control.tex | 2 +- mtask.examples.tex | 2 +- mtask.expr.tex | 2 +- mtask.io.tex | 4 +- mtask.scheduling.tex | 2 +- mtask.tex | 2 +- mtaskext.bytecode.tex | 18 ++++---- mtaskext.examples.tex | 6 +-- mtaskext.sdsprop.tex | 4 +- pres.intro.tex | 8 ++-- pres.mtask.tex | 16 +++---- pres.system.tex | 10 ++--- presentation.pre | 4 +- todo.txt | 5 --- top.combinators.tex | 2 +- top.itasks.tex | 2 +- top.sds.tex | 4 +- 26 files changed, 134 insertions(+), 104 deletions(-) diff --git a/Makefile b/Makefile index c0fb0a0..eb8469c 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,5 @@ all: ./build + +clean: + ./build clean diff --git a/arch.communication.tex b/arch.communication.tex index 0dcd83b..916b780 100644 --- a/arch.communication.tex +++ b/arch.communication.tex @@ -8,7 +8,7 @@ Appendix~\ref{app:communication-protocol}. The type holding the messages is shown in Listing~\ref{lst:avmsg}. Detailed explanation about the message types and according actions will be given in the following subsections. -\begin{lstlisting}[label={lst:avmsg},caption={Available messages}] +\begin{lstlisting}[language=Clean,label={lst:avmsg},caption={Available messages}] :: MTaskId :== Int :: MSDSId :== Int :: MTaskFreeBytes :== Int @@ -38,7 +38,7 @@ peripheral availability, the memory available for storing \glspl{Task} and \glspl{SDS} and the size of the stack. Not all peripheral flags are shown for brevity. -\begin{lstlisting}[label={lst:devicespec}, +\begin{lstlisting}[language=Clean,label={lst:devicespec}, caption={Device specification for \gls{mTask}-\glspl{Task}}] :: MTaskDeviceSpec = { haveLed :: Bool @@ -110,7 +110,7 @@ generates an \gls{SDS} for a specific device. This allows giving an old device record to the function and still update the latest instance. Listing~\ref{lst:connectDevice} shows the connection function. -\begin{lstlisting}[label={lst:connectDevice},% +\begin{lstlisting}[language=Clean,label={lst:connectDevice},% caption={Connect a device}] process :: MTaskDevice (Shared Channels) -> Task () process device ch = forever $ wait "process" (not o isEmpty o fst3) ch @@ -182,7 +182,7 @@ not yet acknowledged. Finally the device itself is updated with the new state and with the new \gls{Task}. After waiting for the acknowledgement the device is updated again and the \gls{Task} returns. -\begin{lstlisting}[label={lst:sendtask},% +\begin{lstlisting}[language=Clean,label={lst:sendtask},% caption={Sending a \gls{Task} to a device}] makeTask :: String Int -> Task MTaskTask makeTask name ident = get currentDateTime @ \dt->{MTaskTask | name=name, ident=ident, dateAdded=dt} @@ -221,7 +221,7 @@ residing in the \gls{SDS} must be cleaned up. It might be the case that they contain \glspl{Task}, \glspl{SDS} or errors that are no longer applicable in this run. A user or programmer can later choose to reconnect to some devices. -\begin{lstlisting}[caption={Starting up the devices},% +\begin{lstlisting}[language=Clean,caption={Starting up the devices},% label={lst:startupdevs}] startupDevices :: Task [MTaskDevice] startupDevices = upd (map reset) deviceStoreNP diff --git a/arch.example.tex b/arch.example.tex index c905ead..2d28698 100644 --- a/arch.example.tex +++ b/arch.example.tex @@ -32,7 +32,7 @@ framework. Note that a little bit of type twiddling is required to fully use the result from the \gls{SDS}. This approach is still type safe due to the type safety of \CI{Dynamic}s. -\begin{lstlisting}[caption={Thermostat example}] +\begin{lstlisting}[language=Clean,caption={Thermostat example}] thermos :: Task () thermos = makeDevice "nodeM" nodeMCU >>= connectDevice >>= \nod-> makeDevice "stm32" stm32 >>= connectDevice @@ -62,7 +62,7 @@ an \gls{iTasks}-\gls{Task}. The function is called with a name, \gls{mTask}, device and interval specification and it will return a \gls{Task} that finishes if and only if the \gls{mTask} has returned. -\begin{lstlisting}[caption={Lifting \gls{mTask}-\glspl{Task} to \gls{iTasks}}] +\begin{lstlisting}[language=Clean,caption={Lifting \gls{mTask}-\glspl{Task} to \gls{iTasks}}] liftmTask :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task [MTaskShare] liftmTask wta mTask c=:(dev, _)= sendTaskToDevice wta mTask c >>= \(t, shs)->wait "Waiting for mTask to return" (taskRemoved t) (deviceShare dev) @@ -74,7 +74,7 @@ where The factorial function example from Chapter~\ref{chp:mtaskcont} can then be lifted to a real \gls{iTasks}-\gls{Task} with the following code: -\begin{lstlisting}[caption={Lifting the factorial \gls{Task} to \gls{iTasks}}] +\begin{lstlisting}[language=Clean,caption={Lifting the factorial \gls{Task} to \gls{iTasks}}] factorial :: MTaskDevice -> Task BCValue factorial dev = enterInformation "Factorial of ?" [] >>= \fac->liftmTask "fact" (fact fac) (dev, OnInterval 100) @@ -102,24 +102,32 @@ The current implementation runs on \gls{mbed} supported devices. \subsubsection{\gls{mTask} Classes} First, a class has to be devised to store the functionality of the sensor. The heartbeat sensor updates four values continuously, namely the heartbeat, the -oxygen saturation and the validity of the two. For every value a function is -added to the new \CI{hb} class. Moreover, the introduced datatype housing the -values should implement the \CI{mTaskType} classes. The definition is as -follows: +oxygen saturation and the validity of the two. The real value and the validity +are combined in an \gls{ADT} and functions are added for both of them in the +new \CI{hb} class. The values are combined in such a way that they fit in a 16 +bit integer with the last bit representing the validity of the reading. The +introduced datatype housing the values should implement the \CI{mTaskType} +classes. The definition is as follows: + +\begin{lstlisting}[language=Clean,% + caption={The \texttt{hb} class and class implementations}] +:: Heartbeat = HB Int Bool +:: SP02 = SP02 Int Bool + +instance toByteCode Heartbeat + where toByteCode (HB i b) = "h" +++ (to16bit $ (i << 1) bitand (if b 1 0)) +instance toByteCode SP02 where ... + +instance fromByteCode Heartbeat + where fromByteCode s = let i = fromByteCode s //The Int from bytecode + in HB (i >> 1) (i bitand 1 > 0) +instance fromByteCode SP02 where ... -\begin{lstlisting}[caption={The \texttt{hb} class}] -:: Heartbeat = HB Int -:: SP02 = SP02 Int - -instance toByteCode Heartbeat, SP02 -instance fromByteCode Heartbeat, SP02 derive class iTask Heartbeat, SP02 class hb v where getHb :: (v Heartbeat Expr) - validHb :: (v Bool Expr) getSp02 :: (v SP02 Expr) - validSp02 :: (v Bool Expr) \end{lstlisting} \subsubsection{Bytecode Implementation} @@ -129,20 +137,16 @@ single values and no assignment is possible. The following code shows the implementation. Dedicated bytecode instructions have been added to support the functionality. -\begin{lstlisting}[caption={The \texttt{hb} bytecode instance}] +\begin{lstlisting}[language=Clean,caption={The \texttt{hb} bytecode instance}] :: BC = BCNop | ... | BCGetHB - | BCValidHB | BCGetSP02 - | BCValidSP02 instance hb ByteCode where getHb = tell` [BCGetHB] - validHb = tell` [BCValidHB] getSp02 = tell` [BCGetSP02] - validSp02 = tell` [BCValidSP02] \end{lstlisting} \subsubsection{Device Interface} @@ -155,14 +159,12 @@ number if added correctly. The peripheral byte in the device specification by default shows a negative flag for every peripheral. Only the peripherals added will be flagged positive. -\begin{lstlisting}[caption={Adding the device interface}] +\begin{lstlisting}[language=Clean,caption={Adding the device interface}] // interface.h ... #if HAVEHB == 1 uint16_t get_hb(); -bool valid_hb(); uint16_t get_spo2(); -bool valid_spo2(); #endif ... @@ -174,15 +176,9 @@ bool valid_spo2(); case BCGETHB: stack[sp++] = get_hb(); break; - case BCVALIDHB: - stack[sp++] = valid_hb(); - break; case BCGETSP02: stack[sp++] = get_spo2(); break; - case BCVALIDSP02: - stack[sp++] = valid_spo2(); - break; #endif ... \end{lstlisting} @@ -192,10 +188,13 @@ The device client software always executes the \CI{real\_setup} in which the client software can setup the connection and peripherals. In the case of the heartbeat peripheral it starts a thread running the calculations. The thread started in the setup will set the global heartbeat and oxygen level variables -so that the interface functions for it can access it. The code is then as -follows: +so that the interface functions for it can access it. This is listed in +Listing~\ref{lst:hbding}. If interrupts were implemented, the \glspl{Task} +using the heartbeat sensor could be executed on interrupt. The heartbeat thread +can fire an interrupt everytime it calculated a new heartbeat. -\begin{lstlisting}[language=C,caption={}] +\begin{lstlisting}[label={lst:hbding},language=C,% + caption={Heartbeat code in the client}] Serial pc; Thread thread; @@ -208,3 +207,31 @@ void real_setup(void) { thread.start(heartbeat_thread); } \end{lstlisting} + +\subsubsection{Example} +The following code shows a complete example of a \gls{Task} controlling an +\emph{STM} microcontroller containing a heartbeat sensor. The web application +belonging to the server shows the heartbeat value and starts an alert +\gls{Task} when it exceeds the value given or is no longer valid. +This example also shows how named \gls{SDS} are handled. + +\begin{lstlisting}[language=Clean,caption={Heartbeat example}] +hbwatch :: (Task a) Int -> Task () +hbwatch alert lim + = makeDevice "stm32" stm32 + >>= connectDevice + >>= \stm ->sendTaskToDevice "monitor" monitor (stm, OnInterval 200) + >>= \(t, sh)->mon (fromJust $ find (\x->x.name == "hb") sh) + >>* [OnAction (Action "Shutdown") $ always $ deleteDevice stm >>| shutDown 0] +where + mon :: (Shared BCValue) -> Task () + mon b = whileUnchanged (mapRead dynHB b) + \hb=:(HB i valid)->if (not valid || i > lim) + alert (viewInformation "HB Okay" [] hb) + + dynHB :: Dynamic -> HeartBeat + dynHB (a :: HeartBeat) = a + + monitor = namedsds \hb=(0 Named hb) In + {main= hb = getHB :. pub hb } +\end{lstlisting} diff --git a/arch.itasks.tex b/arch.itasks.tex index 1b3384f..5168510 100644 --- a/arch.itasks.tex +++ b/arch.itasks.tex @@ -1,9 +1,13 @@ The server part of the system is written in \gls{iTasks}. Functions for -managing devices, \glspl{Task} and \glspl{SDS} are available. Furthermore, an +managing are added. This includes functionality for adding, removing and +updating devices. Functions for sending \glspl{Task} and \glspl{SDS} to devices +and functionality to remove them. +Furthermore, an interactive web application has been created that provides an interactive -management console for the \gls{mTask} system. This interface provides -functionality to list \glspl{SDS}, add and remove \glspl{Task}, administrate -devices and view the state of the system. +management console for these manageming tasks. This interface provides +functionality to show \glspl{Task} and \glspl{SDS} and their according status. +It also provides the user with a library of example \gls{mTask}-\glspl{Task} +that can be sent interactively to the device. \subsection{Device Storage} Everything that a device encompasses is stored in the \CI{MTaskDevice} record @@ -14,11 +18,11 @@ necessary classes and sub types. Devices added to the system must be reachable asynchronously. This implies that the programmer only needs to keep hold of the reference to the device and not the actual device record. -\begin{lstlisting}[caption={Device type},label={lst:mtaskdevice}] +\begin{lstlisting}[language=Clean,caption={Device type},label={lst:mtaskdevice}] :: Channels :== ([MTaskMSGRecv], [MTaskMSGSend], Bool) -:: MTaskDeviceSpec = ... // Also explained in later sections -:: MTaskMSGRecv = ... // Message format, explained in later sections -:: MTaskMSGSend = ... // Also explained in later sections +:: MTaskDeviceSpec = ... // Explained in a later section +:: MTaskMSGRecv = ... // Message format, explained in a later section +:: MTaskMSGSend = ... // Also explained in a later section :: MTaskResource = TCPDevice TCPSettings | SerialDevice TTYSettings @@ -153,7 +157,7 @@ can determine whether the second argument --- the reader --- needs to be notified. In practice, the reader only needs to be notified when the parameters are exactly the same. -\begin{lstlisting}[label={lst:actualdev},% +\begin{lstlisting}[language=Clean,label={lst:actualdev},% caption={Device \gls{SDS}}] ($<) :: a (f a) -> (f b) ($<) a fb = fmap (const a) fb @@ -188,7 +192,7 @@ Accessing the global \gls{SDS} is just a matter of focussing the \gls{SDS} will only be notified if a device is added or removed. The actual code is as follows: -\begin{lstlisting}[caption={Global \gls{SDS}}] +\begin{lstlisting}[language=Clean,caption={Global \gls{SDS}}] deviceStoreNP :: Shared [MTaskDevice] deviceStoreNP = sdsFocus Nothing deviceStore \end{lstlisting} @@ -201,7 +205,7 @@ channels and is unique throughout the system. This type of \gls{SDS} will only be notified if the device itself changed. It will not be notified when only a single \gls{SDS} on the device changes. The implementation is as follows: -\begin{lstlisting}[caption={Local \gls{SDS}}] +\begin{lstlisting}[language=Clean,caption={Local \gls{SDS}}] deviceShare :: MTaskDevice -> Shared MTaskDevice deviceShare d = mapReadWriteError ( \ds->case find ((==)d) ds of @@ -222,7 +226,7 @@ the local \gls{SDS} only treating it as references. It uses the a \gls{Task} writes to this \gls{SDS}, the global \gls{SDS} will know this through the parameter and propagate the value to the device. -\begin{lstlisting}[caption={Local \gls{SDS}}] +\begin{lstlisting}[language=Clean,caption={Local \gls{SDS}}] shareShare :: MTaskDevice MTaskShare -> Shared BCValue shareShare dev share = sdsFocus () $ mapReadWriteError (read, write) diff --git a/conclusion.discussion.tex b/conclusion.discussion.tex index e5b10af..90a91d3 100644 --- a/conclusion.discussion.tex +++ b/conclusion.discussion.tex @@ -78,7 +78,8 @@ Adding this functionality to the bytecode-view allows greater flexibility, easier programming and less communication resources. Adding this type of scheduling requires modifications to the client software and extensions to the communication protocol since relations between \glspl{Task} also need to be -encoded and communicated. +encoded and communicated. A similar technique as used with \glspl{SDS} has to +be used to overcome the scoping problem. The \gls{SDS} functionality in the current system is bare. There is no easy way of reusing an \gls{SDS} for another \gls{Task} on the same device or on another diff --git a/edsl.class.tex b/edsl.class.tex index a2456d9..8da1d27 100644 --- a/edsl.class.tex +++ b/edsl.class.tex @@ -20,7 +20,7 @@ choose to implement only parts of the collection of classes. In contrast to deep embedding, it is very well possible to have multiple views applied on the same expression. This is also shown in the following listing. -\begin{lstlisting}[label={lst:exclassshallow},% +\begin{lstlisting}[language=Clean,label={lst:exclassshallow},% caption={A minimal class based shallow \gls{EDSL}}] :: Env = ... // Some environment :: Evaluator a = Evaluator (Env -> a) diff --git a/edsl.deep.tex b/edsl.deep.tex index fa9d380..bd2389d 100644 --- a/edsl.deep.tex +++ b/edsl.deep.tex @@ -3,7 +3,7 @@ functions that transform something to the datatype or the other way around. As an example, take the simple arithmetic \gls{EDSL} shown in Listing~\ref{lst:exdeep}. -\begin{lstlisting}[label={lst:exdeep},% +\begin{lstlisting}[language=Clean,label={lst:exdeep},% caption={A minimal deep \gls{EDSL}}] :: DSL = LitI Int @@ -31,7 +31,7 @@ using bimaps or projection pairs~\cite{cheney_lightweight_2002}. Unfortunately the lack of extendability remains a problem. If a language construct is added, no compile time guarantee is given that all views support it. -\begin{lstlisting}[label={lst:exdeepgadt},% +\begin{lstlisting}[language=Clean,label={lst:exdeepgadt},% caption={A minimal deep \gls{EDSL} using \glspl{GADT}}] :: DSL a = LitI Int -> DSL Int diff --git a/edsl.shallow.tex b/edsl.shallow.tex index b7616b6..472c639 100644 --- a/edsl.shallow.tex +++ b/edsl.shallow.tex @@ -3,7 +3,7 @@ the host language. An evaluator view for the example language then can be implemented as the code shown in Listing~\ref{lst:exshallow}. Note that much of the internals of the language can be hidden using monads. -\begin{lstlisting}[label={lst:exshallow},% +\begin{lstlisting}[language=Clean,label={lst:exshallow},% caption={A minimal shallow \gls{EDSL}}] :: Env = ... // Some environment :: DSL a = DSL (Env -> a) diff --git a/mtask.class.tex b/mtask.class.tex index 684e67d..3d8029a 100644 --- a/mtask.class.tex +++ b/mtask.class.tex @@ -7,7 +7,7 @@ class with the same functions. As an example, Listing~\ref{lst:lcd} shows parts of the \gls{LCD} class as an \gls{mTask} class functions and as Listing~\ref{lst:lcdc} shown the corresponding \emph{Arduino} class functions. -\begin{lstlisting}[label={lst:lcd},% +\begin{lstlisting}[language=Clean,label={lst:lcd},% caption={Adding the \gls{LCD} to the \gls{mTask} language}] :: LCD = ... diff --git a/mtask.control.tex b/mtask.control.tex index 1bf3900..f578245 100644 --- a/mtask.control.tex +++ b/mtask.control.tex @@ -15,7 +15,7 @@ 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}[% +\begin{lstlisting}[language=Clean,% label={lst:control},caption={Control flow operators}] class IF v where IF :: (v Bool p) (v t q) (v s r) -> v () Stmt | ... diff --git a/mtask.examples.tex b/mtask.examples.tex index 9369eec..c502ee6 100644 --- a/mtask.examples.tex +++ b/mtask.examples.tex @@ -10,7 +10,7 @@ The main program code can also just consist of the contents of the root \CI{main} itself. Finally a thermostat example is shown that also displays the temperature on its \gls{LCD} while regulating the temperature. -\begin{lstlisting}[% +\begin{lstlisting}[language=Clean,% label={lst:exmtask},caption={Some example \gls{mTask}-\glspl{Task}}] a0 = aIO A0 d0 = dIO D0 diff --git a/mtask.expr.tex b/mtask.expr.tex index 62e9502..ce572dc 100644 --- a/mtask.expr.tex +++ b/mtask.expr.tex @@ -7,7 +7,7 @@ brevity. Moreover, the class restrictions are only shown in the first functions and are omitted in subsequent functions. Both the boolean expression and arithmetic expression classes are shown in Listing~\ref{lst:arithbool}. -\begin{lstlisting}[label={lst:arithbool}, +\begin{lstlisting}[language=Clean,label={lst:arithbool}, caption={Basic classes for expressions}] class arith v where lit :: t -> v t Expr diff --git a/mtask.io.tex b/mtask.io.tex index 2fc83fb..a0aec0a 100644 --- a/mtask.io.tex +++ b/mtask.io.tex @@ -5,7 +5,7 @@ extensions can be created for specific peripherals such as built-in Listing~\ref{lst:sdsio}. In this way the assignment is the same for every assignable entity. -\begin{lstlisting}[% +\begin{lstlisting}[language=Clean,% label={lst:sdsio},caption={Input/Output classes}] :: DigitalPin = D0 | D1 | D2 | D3 | D4 | D5 |D6 | D7 | D8 | D9 | D10 | D11 | D12 | D13 :: AnalogPin = A0 | A1 | A2 | A3 | A4 | A5 @@ -38,7 +38,7 @@ Listing~\ref{lst:sdsclass}. The \CI{Main} type is introduced to box an and decorations such as \glspl{SDS}. The type signature is complex and uses infix type constructors and therefore, an implementation example is also given. -\begin{lstlisting}[% +\begin{lstlisting}[language=Clean,% label={lst:sdsclass},caption={\glspl{SDS} in \gls{mTask}}] :: In a b = In infix 0 a b :: Main a = {main :: a} diff --git a/mtask.scheduling.tex b/mtask.scheduling.tex index 168b6c6..42dc7cc 100644 --- a/mtask.scheduling.tex +++ b/mtask.scheduling.tex @@ -48,7 +48,7 @@ complex and therefore an example is given. The aforementioned Listing shows a simple specification containing one \gls{Task} that increments a value indefinitely every one seconds. -\begin{lstlisting}[label={lst:taskclass},% +\begin{lstlisting}[language=Clean,label={lst:taskclass},% caption={The classes for defining \glspl{Task}}] class mtask v a where task :: (((v delay r) a->v MTask Expr)->In (a->v u p) (Main (v t q))) -> Main (v t q) | ... diff --git a/mtask.tex b/mtask.tex index 38cd7aa..397511d 100644 --- a/mtask.tex +++ b/mtask.tex @@ -26,7 +26,7 @@ restriction describes updatable expressions such as \gls{GPIO} pins and without the roles for \CI{Upd}. Assignment would be possible to a non-assignable expression such as a literal integer. -\begin{lstlisting}[% +\begin{lstlisting}[language=Clean,% label={lst:exprhier},caption={Expression role hierarchy}] :: Upd = Upd :: Expr = Expr diff --git a/mtaskext.bytecode.tex b/mtaskext.bytecode.tex index 1a365be..e0da38a 100644 --- a/mtaskext.bytecode.tex +++ b/mtaskext.bytecode.tex @@ -29,7 +29,7 @@ quantified type variables and therefore it is not possible to derive class instances such as \CI{iTasks}. Tailor-made instances for these functions have been made. -\begin{lstlisting}[label={lst:bcview},caption={Bytecode view}] +\begin{lstlisting}[language=Clean,label={lst:bcview},caption={Bytecode view}] :: ByteCode a p = BC (RWS () [BC] BCState ()) :: BCValue = E.e: BCValue e & mTaskType, TC e :: BCShare = @@ -66,7 +66,7 @@ However, this is not a real instruction and the labels are resolved to actual program memory addresses in the final step of compilation to save instructions and avoid label lookups at runtime. -\begin{lstlisting}[label={bc:instr},% +\begin{lstlisting}[language=Clean,label={bc:instr},% caption={Bytecode instruction set}] :: BC = BCNop | BCLab Int | BCPush BCValue | BCPop @@ -108,7 +108,7 @@ to make operators that pop one or two values off the stack respectively. The \CI{tell`} function is a wrapper around the \gls{RWST} function \CI{tell} that appends the argument to the \emph{Writer} value. -\begin{lstlisting}[label={lst:helpers},caption={Some helper functions}] +\begin{lstlisting}[language=Clean,label={lst:helpers},caption={Some helper functions}] op2 :: (ByteCode a p1) (ByteCode a p2) BC -> ByteCode b Expr op2 (BC x) (BC y) bc = BC (x >>| y >>| tell [bc]) @@ -128,7 +128,7 @@ functions. Listing~\ref{lst:arithview} shows some implementations. The \CI{boolExpr} class and the classes for the peripherals are implemented using the same strategy. -\begin{lstlisting}[label={lst:arithview},caption={% +\begin{lstlisting}[language=Clean,label={lst:arithview},caption={% Bytecode view implementation for arithmetic and peripheral classes}] instance arith ByteCode where lit x = tell` [BCPush (BCValue x)] @@ -149,7 +149,7 @@ they are placed in the correct order in the bytecode sequence. It can happen that multiple labels appear consecutively in the code. This is not a problem since the labels are resolved to real addresses later on anyway. -\begin{lstlisting}[label={lst:controlflow},% +\begin{lstlisting}[language=Clean,label={lst:controlflow},% caption={Bytecode view for the \texttt{IF} class}] freshlabel = get >>= \st=:{freshl}->put {st & freshl=freshl+1} >>| tell freshl @@ -178,7 +178,7 @@ It just writes a single instruction so that the interpreter knows to stop execution. Listing~\ref{lst:return} shows the classes and implementation for the return expression. -\begin{lstlisting}[label={lst:return},% +\begin{lstlisting}[language=Clean,label={lst:return},% caption={Bytecode view for the return instruction}] class retrn v where retrn :: v () Expr @@ -197,7 +197,7 @@ implementation is shown in Listing~\ref{lst:shareview}. The implementation for the \CI{namedsds} class is exactly the same other than that it stores the given name in the \CI{BCShare} structure as well. -\begin{lstlisting}[label={lst:shareview},% +\begin{lstlisting}[language=Clean,label={lst:shareview},% caption={Bytecode view for \texttt{arith}}] freshshare = get >>= \st=:{freshs}->put {st & freshs=freshs+1} >>| pure freshs @@ -225,7 +225,7 @@ instruction(s) will be rewritten accordingly. This results in a %chktex 36 \CI{BCSdsStore} or \CI{BCAnalogWrite} instruction respectively. The implementation for this is given in Listing~\ref{lst:assignmentview}. -\begin{lstlisting}[label={lst:assignmentview},% +\begin{lstlisting}[language=Clean,label={lst:assignmentview},% caption={Bytecode view implementation for assignment.}] instance assign ByteCode where (=.) (BC v) (BC e) = BC (e >>| censor makeStore v) @@ -257,7 +257,7 @@ one to find new instantiated \glspl{SDS}. The compilation concludes with converting the bytecode and \glspl{SDS} to actual messages ready to send to the client. -\begin{lstlisting}[label={lst:compilation},% +\begin{lstlisting}[language=Clean,label={lst:compilation},% caption={Actual compilation.}] bclength :: BC -> Int bclength (BCPush s) = 1 + size (toByteCode s) diff --git a/mtaskext.examples.tex b/mtaskext.examples.tex index 431677e..d680072 100644 --- a/mtaskext.examples.tex +++ b/mtaskext.examples.tex @@ -6,7 +6,7 @@ problem since this is included in the stopping condition of the interpreter. When the program counter exceeds the length of the program, the task terminates. -\begin{lstlisting}[caption={Thermostat bytecode},language=c] +\begin{lstlisting}[language=Clean,caption={Thermostat bytecode},language=c] 0-1 : BCAnalogRead (Analog A0) 2-5 : BCPush (Int 50) 6 : BCGre @@ -26,7 +26,7 @@ factorial after which is will return. The following listings shows the actual \gls{mTask} and the generated messages followed by the actual bytecode in a readable form. -\begin{lstlisting}[caption={Factorial as an \gls{mTask}-\gls{Task}}] +\begin{lstlisting}[language=Clean,caption={Factorial as an \gls{mTask}-\gls{Task}}] factorial :: Int -> Main (ByteCode () Stmt) factorial i = sds \y=i In namedsds \x=1 Named "result" In @@ -44,7 +44,7 @@ Start = fst $ toMessages (OnInterval 500) (factorial 5) zero //[MTSds 2 (BCValue 5), MTSds 1 (BCValue 1), MTTask (OnInterval 500) ...] \end{lstlisting} -\begin{lstlisting}[label={lst:actualbc},% +\begin{lstlisting}[language=Clean,label={lst:actualbc},% caption={The resulting bytecode for the factorial function},language=C] 0-2 : BCSdsFetch 1 3-6 : BCPush (Int 1) diff --git a/mtaskext.sdsprop.tex b/mtaskext.sdsprop.tex index 029f9a0..00f14ad 100644 --- a/mtaskext.sdsprop.tex +++ b/mtaskext.sdsprop.tex @@ -20,7 +20,7 @@ class. Therefore, an extra class is added that contains the extra functionality. Programmers can choose to implement it for existing views in the future but are not obliged to. The publication function has the following signature: -\begin{lstlisting}[caption={The \texttt{sdspub} class}] +\begin{lstlisting}[language=Clean,caption={The \texttt{sdspub} class}] class sdspub v where pub :: (v t Upd) -> v t Expr | type t \end{lstlisting} @@ -42,7 +42,7 @@ Listing~\ref{lst:namedsds}. Again, an example is added for illustration. Retrieving the \gls{SDS} after compilation is shown in Section~\ref{sec:archexamples}. -\begin{lstlisting}[label={lst:namedsds},% +\begin{lstlisting}[language=Clean,label={lst:namedsds},% caption={The \texttt{namedsds} class}] class namedsds v where namedsds :: ((v t Upd) -> In (Named t String) (Main (v c s))) -> (Main (v c s)) | ... diff --git a/pres.intro.tex b/pres.intro.tex index c4f90bf..83a2dc6 100644 --- a/pres.intro.tex +++ b/pres.intro.tex @@ -136,7 +136,7 @@ \begin{frame}[fragile] \frametitle{Task Oriented Programming} \framesubtitle{Example} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] :: Name = { firstname :: String, lastname :: String } derive class iTask Name @@ -170,7 +170,7 @@ enterName = enterInformation "Enter your name" [] \frametitle{Task Oriented Programming (3)} \framesubtitle{Combinators} \begin{block}{Sequence} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] (>>=) infixl 1 :: (Task a) (a -> Task b) -> Task b | iTask a & iTask b (>>*) infixl 1 :: (Task a) [TaskCont a (Task b)] -> Task b | iTask a & iTask b :: TaskCont a b @@ -183,7 +183,7 @@ enterName = enterInformation "Enter your name" [] \end{block} \begin{block}{Parallel} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] (-||-) infixr 3 :: (Task a) (Task a) -> Task a | iTask a ( ||-) infixr 3 :: (Task a) (Task b) -> Task b | iTask a & iTask b (-|| ) infixl 3 :: (Task a) (Task b) -> Task a | iTask a & iTask b @@ -202,7 +202,7 @@ enterName = enterInformation "Enter your name" [] \end{itemize} \end{block} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] :: RWShared p r w = ... :: ReadWriteShared r w :== RWShared () r w :: Shared r :== ReadWriteShared r r diff --git a/pres.mtask.tex b/pres.mtask.tex index ec40ae4..3d602b3 100644 --- a/pres.mtask.tex +++ b/pres.mtask.tex @@ -27,7 +27,7 @@ \end{block} \column{.49\textwidth} \pause{} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] :: DSL = LitI Int | LitB Bool | Var String | Plus DSL DSL | Minus DSL DSL | And DSL DSL @@ -60,7 +60,7 @@ pprint :: DSL -> String \end{block} \pause{} \column{.49\textwidth} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] :: Env = ... :: DSL a = DSL (Env -> a) @@ -107,7 +107,7 @@ Plus x y = \e -> x e + y e } \column{.49\textwidth} \begin{onlyenv}<2-> - \begin{lstlisting} + \begin{lstlisting}[language=Clean] :: Env = ... :: Evaluator a = Evaluator (Env -> a) :: PrettyPrinter a = PP String @@ -163,7 +163,7 @@ instance intArith PrettyPrinter where \end{itemize} \end{block} \pause{} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] class arith v where lit :: t -> v t Expr (+.) infixl 6 :: (v t p) (v t q) -> v t Expr | +, zero t & isExpr p & isExpr q @@ -179,7 +179,7 @@ class boolExpr v where \begin{frame}[fragile] \frametitle{Control flow} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] 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 | ... @@ -191,7 +191,7 @@ class seq v where \begin{frame}[fragile] \frametitle{Assignment and Input/Output} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] :: DigitalPin = D0 | D1 | D2 ... :: AnalogPin = A0 | A1 | A2 ... @@ -210,7 +210,7 @@ class digitalRead v where \begin{frame}[fragile] \frametitle{Shared Data Sources and Assignment} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] :: In a b = In infix 0 a b :: Main a = {main :: a} @@ -224,7 +224,7 @@ class assign v where \begin{frame}[fragile] \frametitle{Examples} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] blink = task \blink=(\x. IF (x ==. lit True) (ledOn LED1) diff --git a/pres.system.tex b/pres.system.tex index b4a1504..1dd21c3 100644 --- a/pres.system.tex +++ b/pres.system.tex @@ -26,7 +26,7 @@ \subsection{Extending mTask} \begin{frame}[fragile] \frametitle{Adding a View} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] :: ByteCode a p = BC (RWS () [BC] BCState ()) :: BC = BCNop | BCPush BCValue | ... :: BCValue = E.e: BCValue e & mTaskType, TC e @@ -44,7 +44,7 @@ instance ByteCode arith, boolExpr, ... \item Carrying state \item Hand-crafted helpers \end{itemize} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] op2 :: (ByteCode a p1) (ByteCode a p2) BC -> ByteCode b Expr op2 (BC x) (BC y) bc = BC (x >>| y >>| tell [bc]) @@ -67,7 +67,7 @@ instance arith ByteCode where \item Thus no reuse \end{itemize} \pause{} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] :: BC = ... | BCLab Int | ... freshlabel = get >>= \st=:{freshl}->put {st & freshl=freshl+1} >>| pure freshl @@ -106,7 +106,7 @@ BCIfStmt (BC b) (BC t) (BC e) = BC ( \begin{frame}[fragile] \frametitle{Assignment} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] instance sds ByteCode where sds f = {main = BC (freshshare >>= \sdsi->pure {BCShare|sdsname="",sdsi=sdsi,sdsval=BCValue 0} @@ -150,7 +150,7 @@ makeStore [...] = [...] \item How to handle termination \end{itemize} \pause{} - \begin{lstlisting} + \begin{lstlisting}[language=Clean] class retrn v where retrn :: v () Expr \end{lstlisting} diff --git a/presentation.pre b/presentation.pre index 4c9df64..35ade65 100644 --- a/presentation.pre +++ b/presentation.pre @@ -41,6 +41,7 @@ literate=% % Basic Clean constructs {\\}{{$\lambda\:$}}1 + {->}{{$\rightarrow\:$}}1 {A.}{{$\forall\;\,$}}1 {E.}{{$\exists\;\,$}}1 {*}{{$^*$}}1 @@ -63,8 +64,7 @@ showstringspaces=false, showtabs=false, tabsize=4, - frame=L, - language=Clean + frame=L } \author[M. Lubbers]{ diff --git a/todo.txt b/todo.txt index de9b7a4..59754de 100644 --- a/todo.txt +++ b/todo.txt @@ -1,7 +1,2 @@ intro: Problem statement en introductie uitwijden -emtsk: examples, factorial vervangen -devcs: waarom kunnen taken geen andere taken starten -iTaks: duidelijker maken wat "managing devices" betekend -hbexm: Voorbeeld met de heartbeat sensor -hbexm: Instructies van de heartbeat sensor verkleinen concl: Uitleggen hoe/of de probleemstelling opgelost is diff --git a/top.combinators.tex b/top.combinators.tex index 8b39db9..a60dab0 100644 --- a/top.combinators.tex +++ b/top.combinators.tex @@ -5,7 +5,7 @@ combinators are derived from the basic combinators. Type signatures of simplified versions of the basic combinators and their derivations are given in Listing~\ref{lst:combinators} -\begin{lstlisting}[% +\begin{lstlisting}[language=Clean,% caption={\Gls{Task}-combinators},label={lst:combinators}] //Step combinator (>>=) infixl 1 :: (Task a) (a -> Task b) -> Task b | iTask a & iTask b diff --git a/top.itasks.tex b/top.itasks.tex index 891fd96..d528d55 100644 --- a/top.itasks.tex +++ b/top.itasks.tex @@ -26,7 +26,7 @@ image all fields are entered and the \CI{TaskValue} transitions to the \caption{The states of a \CI{TaskValue}}\label{fig:taskvalue} \end{figure} -\begin{lstlisting}[label={lst:taskex},% +\begin{lstlisting}[language=Clean,label={lst:taskex},% caption={An example \gls{Task} for entering a name}] :: Name = { firstname :: String , lastname :: String diff --git a/top.sds.tex b/top.sds.tex index 95b3ace..72b44c8 100644 --- a/top.sds.tex +++ b/top.sds.tex @@ -20,7 +20,7 @@ on an \gls{SDS} to change are notified when needed. This results in low resource usage because \glspl{Task} are never constantly inspecting \gls{SDS} values but are notified. -\begin{lstlisting}[% +\begin{lstlisting}[language=Clean,% label={lst:shares},caption={\Gls{SDS} functions}] :: RWShared p r w = ... :: ReadWriteShared r w :== RWShared () r w @@ -65,7 +65,7 @@ programmer to fix a parametric lens value. \CI{sdsLens} is a kind of the creation of, for example, \glspl{SDS} that only read and write to parts of the original \gls{SDS}. -\begin{lstlisting}[label={lst:focus}, +\begin{lstlisting}[language=Clean,label={lst:focus}, caption={Parametric lens functions}] sdsFocus :: p (RWShared p r w) -> RWShared p` r w | iTask p -- 2.20.1