\subsection{EDSLs}
\begin{frame}
	\frametitle{Embedded Domain Specific Language}
	\framesubtitle{What is are EDSL}
	\begin{itemize}
		\item DSL:\ language for a specific domain
		\item E.g., PostScript, VimScript, HTML, \ldots
		\pause{}
		\item EDSL:\ Embedded DSL
		\item Language in a language
		\item Use the properties of the host
		\item E.g., Ivory, \ldots\pause{} and iTasks
	\end{itemize}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Deep embedding}
	\begin{columns}[t]
		\column{.49\textwidth}
		\begin{block}{What is deep embedding}
			\begin{itemize}
				\item The EDSL as an ADT
				\item A view is a function transforming the ADT
			\end{itemize}
		\end{block}
		\column{.49\textwidth}
		\pause{}
		\begin{lstlisting}
:: DSL = LitI  Int     | LitB  Bool
       | Var   String  | Plus  DSL DSL
       | Minus DSL DSL | And   DSL DSL
       | Eq    DSL

eval   :: DSL Env -> Env
pprint :: DSL -> String
		\end{lstlisting}
	\end{columns}
	\pause{}
	\begin{block}{Properties}
		\begin{itemize}
			\item Easy to add views
			\item Hard to extend
			\item Not type safe
			\pause\item GADT
		\end{itemize}
	\end{block}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Shallow embedding}
	\begin{columns}[t]
		\column{.49\textwidth}
		\begin{block}{What is shallow embedding}
			\begin{itemize}
				\item The EDSL as a function
				\item The view is embedded in the function
			\end{itemize}
		\end{block}
		\pause{}
		\column{.49\textwidth}
		\begin{lstlisting}
:: Env   = ...
:: DSL a = DSL (Env -> a)

Lit :: a -> DSL a
Lit x = \e -> x

Var :: String -> DSL Int
Var i = \e -> retrEnv e i

Plus :: (DSL Int) (DSL Int) -> DSL Int
Plus x y = \e -> x e + y e
		\end{lstlisting}
	\end{columns}
	\pause{}
	\begin{block}{Properties}
		\begin{itemize}
			\item Difficult to add views
			\item Easy to extend
			\item Type safe
		\end{itemize}
	\end{block}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Class based shallow embedding}
	\begin{columns}[t]
		\column{.49\textwidth}
		\onslide<1->{
			\begin{block}{The best of both worlds}
				\begin{itemize}
					\item The EDSL is a collection of classes
					\item Views are types implementing a subset
				\end{itemize}
			\end{block}
		}
		\onslide<3->{
			\begin{block}{Properties}
				\begin{itemize}
					\item Extendable
					\item Type safe
					\item Easy to add views
				\end{itemize}
			\end{block}
		}
		\column{.49\textwidth}
		\begin{onlyenv}<2->
			\begin{lstlisting}
:: Env   = ...
:: Evaluator a = Evaluator (Env -> a)
:: PrettyPrinter a = PP String

class intArith where
	lit   :: t -> v t | toString t
	add   :: (v t) (v t) -> (v t) | + t
	minus :: (v t) (v t) -> (v t) | - t

class boolArith where ...

instance intArith Evaluator where
	lit x   = Evaluator \e->x
	add x y = Evaluator ...
	...

instance intArith PrettyPrinter where
	lit x   = PP $ toString x
	add x y = PP $ x +++ "+" +++ y
	...
			\end{lstlisting}
		\end{onlyenv}
	\end{columns}
\end{frame}

\subsection{mTask}
\begin{frame}
	\frametitle{mTask}
	\pause{}
	\begin{block}{What is mTask}
		\begin{itemize}
			\item EDSL
			\item Arduino C++ generation, iTasks simulation
		\end{itemize}
	\end{block}

	\begin{block}{Considerations}
		\begin{itemize}
			\item Type safe
			\item Embedded in Clean
			\item Extendable
			\item \ldots\pause{} but\ldots
			\item No interaction
			\item Compilation requires reprogramming
		\end{itemize}
	\end{block}
\end{frame}
