\subsection{Overview}
\begin{frame}
	\frametitle{Current state of mTask}
	\begin{itemize}
		\item Suits our needs as an EDSL
		\item It all seems perfect
		\item \ldots\pause{} but\ldots
		\pause{}
		\item No interaction
		\item Compilation requires reprogramming
		\item Entire system is created and fixed
	\end{itemize}
\end{frame}

\begin{frame}
	\frametitle{Solution}
	\begin{itemize}[<+->]
		\item Reuse mTask
		\item New bytecode backend for mTask
		\item Interpreter on client
		\item Server in iTasks with integration
		\item No taskserver generation, onetime programming
		\item Dynamic task sending
	\end{itemize}
\end{frame}

\subsection{Extending mTask}
\begin{frame}[fragile]
	\frametitle{Adding a View}
	\begin{lstlisting}[language=Clean]
:: ByteCode a p = BC (RWS () [BC] BCState ())
:: BC           = BCNop | BCPush BCValue | ...
:: BCValue      = E.e: BCValue e              & mTaskType, TC e
:: BCShare      = { sdsi   :: Int, sdsval :: BCValue, sdsname :: String    }
:: BCState      = { freshl :: Int, freshs :: Int,     sdss    :: [BCShare] }

instance ByteCode arith, boolExpr, ...
	\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Implementation}
	\begin{itemize}
		\item Writing instruction
		\item Carrying state
		\item Hand-crafted helpers
	\end{itemize}
	\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])

tell2 :: [BC] -> (ByteCode a p)
tell2 x = BC (tell x)

instance arith ByteCode where
	lit x = tell2 [BCPush (BCValue x)]
	(+.) x y = op2 x y BCAdd
	...
	\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Control flow}
	\begin{itemize}
		\item Use labels
		\item Label resolving
		\pause{}
		\item Thus no reuse
	\end{itemize}
	\pause{}
	\begin{lstlisting}[language=Clean]
:: BC = ... | BCLab Int | ...

freshlabel = get >>= \st=:{freshl}->put {st & freshl=freshl+1} >>| pure freshl

instance If ByteCode Stmt Stmt Stmt where If b t e = BCIfStmt b t e
...
BCIfStmt (BC b) (BC t) (BC e) = BC (
	freshlabel >>= \else->freshlabel >>= \endif->
	b >>| tell [BCJmpF else] >>|
	t >>| tell [BCJmp endif, BCLab else] >>|
	e >>| tell [BCLab endif]
	)
	\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Assignment and SDSs}
	\begin{lstlisting}[language=Clean]
instance sds ByteCode where
	sds f = {main = BC (freshshare
			>>= \sdsi->pure {BCShare|sdsname="",sdsi=sdsi,sdsval=BCValue 0}
			>>= \sds->pure (f (tell2 [BCSdsFetch sds]))
			>>= \(v In bdy)->modify (addSDS sds v)
			>>| unBC (unMain bdy))
		}

instance assign ByteCode where
	(=.) (BC v) (BC e) = BC (e >>| censor makeStore v)

instance sdspub ByteCode where
	pub (BC x) = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x)

makeStore [BCSdsFetch i]    = [BCSdsStore i]
makeStore [BCDigitalRead i] = [BCDigitalWrite i]
makeStore [...]             = [...]
	\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Bandwidth is scarce}
	Publish SDS explicitly
	\pause{}
	\begin{lstlisting}
class sdspub v where
	pub :: (v t Upd) -> (v () Stmt)
instance sdspub ByteCode where
	pub (BC x) = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x)
	\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Task scheduling}
	\begin{block}{Old}
		\begin{itemize}
			\item Task server
			\item Tasks start other tasks
		\end{itemize}
	\end{block}
	\pause{}
	\begin{block}{New}
		\begin{itemize}
			\item Old system, taskserver, tasks start tasks
			\item New system, task+strategy
				\pause{}
				\begin{itemize}
					\item \CI{OnShot}
					\item \CI{OnInterval}
					\item \CI{OnInterrupt}
				\end{itemize}
			\pause{}
			\item How to handle termination
		\end{itemize}
		\pause{}
		\begin{lstlisting}[language=Clean]
class retrn v where
	retrn :: v () Expr
		\end{lstlisting}
	\end{block}
\end{frame}

\subsection{Interpretation}
\begin{frame}[fragile]
	\frametitle{mTask implementation}
	%TODO
\end{frame}

\subsection{Devices}
\begin{frame}
	\frametitle{Devices}
	\begin{itemize}
		\item Standard C
		\item Implement some classes in interface
		\pause{}
		\item How to handle termination
	\end{itemize}
\end{frame}

\subsection{Server}
\begin{frame}[fragile]
	\frametitle{SDS (2)}
	\framesubtitle{Parametric Lenses}
	\begin{block}{What is the \CI{p} for in \CI{RWShared p r w}}
		\pause{}
		\begin{itemize}
			\item Parameter fixed when writing
			\item Used for notifications
			\item On write the SDS returns \CI{p -> Bool}
		\end{itemize}
	\end{block}
%
%	\begin{lstlisting}
%sdsFocus :: p1 (RWShared p1 r w) -> RWShared p2 r w | iTask p
%
%:: SDSNotifyPred p :== p -> Bool
%:: SDSLensRead p r rs     = SDSRead        (p -> rs -> MaybeError TaskException r)
%                          | SDSReadConst   (p -> r)
%:: SDSLensWrite p w rs ws = SDSWrite       (p -> rs -> w -> MaybeError TaskException (Maybe ws))
%                          | SDSWriteConst  (p -> w -> MaybeError TaskException (Maybe ws))
%:: SDSLensNotify p w rs   = SDSNotify      (p -> rs -> w -> SDSNotifyPred p)
%                          | SDSNotifyConst (p -> w -> SDSNotifyPred p)
%
%sdsLens :: String (p -> ps) (SDSLensRead p r rs) (SDSLensWrite p w rs ws)
%	(SDSLensNotify p w rs) (RWShared ps rs ws) -> RWShared p r w | iTask ps
%	\end{lstlisting}
\end{frame}
\subsection{Examples}
