\subsection{IoT}
\begin{frame}
	\frametitle{What is Internet of Things (IoT)}
	\begin{block}{History}
		\begin{itemize} \item 1999: \pause{} RFID
			\item Device to device communication
			\pause{}
			\item ESP8266
			\item Estimated 30 billion in 2020
		\end{itemize}
	\end{block}
	\pause{}
	\begin{block}{Tasks performed by IoT}
		\begin{itemize}
			\item Monitoring (Temperature, Electricity, Humidity, Heartbeat)
			\item Acting (Servo's, Motors)
			\item Tracking (GPS, WiFi tracking)
			\item Communication (SMS, Whatsapp)
			\pause{}
			\item Combinations: e.g. Thermostat, Smart Clothing, Smart Watches
		\end{itemize}
	\end{block}
\end{frame}

\begin{frame}
	\frametitle{Problems with IoT}
	\begin{itemize}
		\item Device $\rightarrow$ Server $\rightarrow$ Application
		\pause{}
		\item Myriads of devices: Arduino, ESP8266, Raspberry pi\ldots
		\pause{}
		\item Tons of languages: C++, Lua, C, python\ldots
		\pause{}
		\item Heaps of communication methods: LoRa (Sigfox, KPN, TTN), BTLE, WiFi, ZigBee\ldots
		\pause{}
		\item Separated logic
		\item Integration problems
	\end{itemize}
\end{frame}

\begin{frame}
	\frametitle{And there is TOP/iTasks}
	\begin{block}{iTasks}
		\begin{itemize}[<+->]
			\item Tasks are basic blocks
			\item Generated web interface
			\item Type driven
			\item EDSL
		\end{itemize}
	\end{block}
	\pause{}
	\begin{block}{Tasks}
		\begin{itemize}[<+->]
			\item Filling in forms
			\item Looking at data (Monitoring, Maps)
			\item Act on data changes
		\end{itemize}
	\end{block}
\end{frame}

\begin{frame}
	\frametitle{IoT and TOP}
	\begin{block}{Overlap}
		\begin{itemize}[<+->]
			\item Tasks often involve humans
			\item Tasks can be performed by IoT
		\end{itemize}
	\end{block}
	\pause{}
	\begin{block}{But how to integrate}
		\begin{itemize}[<+->]
			\item Distributed iTasks
			\item SDS
			\item Swat two flies at once
		\end{itemize}
	\end{block}
\end{frame}

\begin{frame}
	\frametitle{Solution}
	\begin{itemize}[<+->]
		\item Add IoT to iTasks
		\item Solve the integration problem
		\item Extend the reach of iTasks
		\item iTasks server
		\item IoT device client
		\item EDSL to make IoT tasks
		\item Internalship
	\end{itemize}
\end{frame}

\begin{frame}
	\frametitle{Problems overcome}
	\begin{itemize}[<+->]
		\item Way to express IoT Tasks
		\item Write client software
		\item Write server software
		\item Connect them up
		\item But first some theory
		\item Reprogramming, write cycles
	\end{itemize}
\end{frame}

\subsection{iTasks}
\begin{frame}[fragile]
	\frametitle{Task Oriented Programming}
	\framesubtitle{\ldots and iTasks}
	\begin{block}{iTasks}
		\begin{itemize}[<+->]
			\item Basic blocks
			\item Generated web interface
			\item Type driven
		\end{itemize}
	\end{block}
	\pause{}
	\begin{columns}[c]
		\column{.49\linewidth}
			\begin{block}{Tasks}
				\begin{itemize}[<+->]
					\item Observables
					\item Given the state, a \CI{TaskValue} is observed.
					\item Continuous execution
					\item Generics
				\end{itemize}
			\end{block}
		\pause{}
		\column{.49\linewidth}
			\begin{figure}[ht]
				\centering
				\includegraphics[width=\linewidth]{fig-taskvalue}
				\caption{The states of a \CI{TaskValue}}
			\end{figure}
	\end{columns}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Task Oriented Programming}
	\framesubtitle{Example}
	\begin{lstlisting}
:: Name = { firstname :: String, lastname :: String }
derive class iTask Name

enterInformation :: String [EnterOption m] -> Task m | iTask m
enterName :: Task Name
enterName = enterInformation "Enter your name" []
	\end{lstlisting}

	\begin{figure}[H]
		\centering
		\begin{subfigure}{.30\textwidth}
			\centering
			\includegraphics[width=.9\linewidth]{taskex1}
			\caption{Initial interface\\~}\label{fig:taskex1}
		\end{subfigure}
		\begin{subfigure}{.30\textwidth}
			\centering
			\includegraphics[width=.9\linewidth]{taskex2}
			\caption{Incomplete entrance}\label{fig:taskex2}
		\end{subfigure}
		\begin{subfigure}{.30\textwidth}
			\centering
			\includegraphics[width=.9\linewidth]{taskex3}
			\caption{Complete entry\\~}\label{fig:taskex3}
		\end{subfigure}
		\caption{Example of a generated user interface}
	\end{figure}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Task Oriented Programming (3)}
	\framesubtitle{Combinators}
	\begin{block}{Sequence}
		\begin{lstlisting}
(>>=)  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
	=     OnValue             ((TaskValue a)  -> Maybe b)
	|     OnAction    Action  ((TaskValue a)  -> Maybe b)
	| E.e: OnException         (e              -> b)         & iTask e
	|     OnAllExceptions     (String         -> b)
:: Action = Action String
		\end{lstlisting}
	\end{block}

	\begin{block}{Parallel}
		\begin{lstlisting}
(-||-) 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
(-&&-) infixr 4 :: (Task a) (Task b) -> Task (a,b) | iTask a & iTask b
		\end{lstlisting}
	\end{block}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Shared Data Sources (SDS)}
	\begin{block}{What is an SDS}
		\begin{itemize}[<+->]
			\item Read function
			\item Write function
			\item Both have access to the world
		\end{itemize}
	\end{block}

	\begin{lstlisting}
:: RWShared p r w = ... 
:: ReadWriteShared r w :== RWShared () r w
:: Shared r :== ReadWriteShared r r

get ::          (ReadWriteShared r w)           -> Task r | iTask r
set :: w        (ReadWriteShared r w)           -> Task w | iTask w
upd :: (r -> w) (ReadWriteShared r w)           -> Task w | iTask r & iTask w

sharedStore :: String a -> Shared a | JSONEncode{|*|}, JSONDecode{|*|}

wait :: String (r -> Bool) (ReadWriteShared r w) -> Task r
	\end{lstlisting}
\end{frame}

\begin{frame}
	\frametitle{But not all Tasks or SDSs are suitable for microcontrollers\ldots}
	\pause\centering\Large EDSLs to the rescue
\end{frame}
