all:
./build
+
+clean:
+ ./build clean
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
\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
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
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}
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
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
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)
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)
\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}
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}
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
...
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}
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;
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}
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
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
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
\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}
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
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)
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
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)
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
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
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)
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 = ...
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 | ...
\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
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
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
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}
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) | ...
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
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 =
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
\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])
\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)]
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
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
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
\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)
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)
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
\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
//[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)
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}
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)) | ...
\begin{frame}[fragile]
\frametitle{Task Oriented Programming}
\framesubtitle{Example}
- \begin{lstlisting}
+ \begin{lstlisting}[language=Clean]
:: Name = { firstname :: String, lastname :: String }
derive class iTask 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
\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
\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
\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
\end{block}
\pause{}
\column{.49\textwidth}
- \begin{lstlisting}
+ \begin{lstlisting}[language=Clean]
:: Env = ...
:: DSL a = DSL (Env -> a)
}
\column{.49\textwidth}
\begin{onlyenv}<2->
- \begin{lstlisting}
+ \begin{lstlisting}[language=Clean]
:: Env = ...
:: Evaluator a = Evaluator (Env -> a)
:: PrettyPrinter a = PP String
\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
\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 | ...
\begin{frame}[fragile]
\frametitle{Assignment and Input/Output}
- \begin{lstlisting}
+ \begin{lstlisting}[language=Clean]
:: DigitalPin = D0 | D1 | D2 ...
:: AnalogPin = A0 | A1 | A2 ...
\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}
\begin{frame}[fragile]
\frametitle{Examples}
- \begin{lstlisting}
+ \begin{lstlisting}[language=Clean]
blink = task \blink=(\x.
IF (x ==. lit True)
(ledOn LED1)
\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
\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])
\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
\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}
\item How to handle termination
\end{itemize}
\pause{}
- \begin{lstlisting}
+ \begin{lstlisting}[language=Clean]
class retrn v where
retrn :: v () Expr
\end{lstlisting}
literate=%
% Basic Clean constructs
{\\}{{$\lambda\:$}}1
+ {->}{{$\rightarrow\:$}}1
{A.}{{$\forall\;\,$}}1
{E.}{{$\exists\;\,$}}1
{*}{{$^*$}}1
showstringspaces=false,
showtabs=false,
tabsize=4,
- frame=L,
- language=Clean
+ frame=L
}
\author[M. Lubbers]{
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
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
\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
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
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