+\subsection{Introduction}
+\begin{frame}
+ \frametitle{Introduction}
+ \begin{itemize}
+ \item Monads (Moggi et al.)
+ \item Integrate the impure in the pure
+ \item Wadler shows \textsc{Haskell} examples
+ \item Following samples are in \textsc{Clean}
+ \end{itemize}
+\end{frame}
+
+\subsection{Naive approach}
+\begin{frame}[fragile]
+ \frametitle{Case study (1)}
+ \framesubtitle{Evaluator}
+ \begin{CleanCode}
+:: Term = Con Int | Div Term Term
+
+eval :: Term -> Int
+eval (Con a) = a
+eval (Div t u) = eval t / eval u
+
+//Examples
+answer :: Term
+answer = (Div (Div (Con 1972) (Con 2)) (Con 23))
+
+error :: Term
+error = (Div (Con 1) (Con 0))
+ \end{CleanCode}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Case study (2)}
+ \framesubtitle{Exceptions}
+ \begin{CleanCode}
+:: M a = Raise Exception | Return a
+:: Exception :== String
+
+eval :: Term -> M Int
+eval (Con a) = Return a
+eval (Div t u) = case eval t of
+ Raise e = Raise e
+ Return a = case eval u of
+ Raise e = Raise e
+ Return b = if (b == 0)
+ (Raise "Divide by zero")
+ (Return (a / b))
+ \end{CleanCode}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Case study (3)}
+ \framesubtitle{State, count divisions}
+ \begin{CleanCode}
+:: M a :== State -> (a, State)
+:: State :== Int
+
+eval :: Term -> M Int
+eval (Con a) x = (a, x)
+eval (Div t u)
+# (a, y) = eval t x
+# (b, z) = eval u y
+= (a/b, z+1)
+ \end{CleanCode}
+\end{frame}
+
+\subsection{Monadic approach}
+\begin{frame}[fragile]
+ \frametitle{Monadic (1)}
+ Monad is a triple: $(M, unit, \star)$
+ \pause%
+ \begin{block}{Signatures}
+ \begin{CleanCode}
+:: M a = ...
+unit :: a -> M a
+((#$\star$#)) :: (M a) (a -> M b) -> M b
+ \end{CleanCode}
+ \end{block}
+ \pause%
+ \begin{block}{Evaluator (Identity monad)}
+ \begin{CleanCode}
+:: M a :== a
+unit :: a -> I a
+unit a = a
+((#$\star$#)) :: (M a) (a -> M b) -> M b
+a (#$\star$#) k = k a
+ \end{CleanCode}
+ \end{block}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Monadic (2)}
+ \framesubtitle{Exceptions}
+ \pause%
+ \begin{CleanCode}
+:: M a = Raise Exception | Return a
+:: Exception :== String
+ \end{CleanCode}
+ \pause%
+ \begin{CleanCode}
+unit :: a -> M a
+unit a = Return a
+
+((#$\star$#)) :: (M a) (a -> M b) -> M b
+m (#$\star$#) k = case m of
+ Raise e = Raise e
+ Return a = k a
+ \end{CleanCode}
+ \pause%
+ \begin{CleanCode}
+raise :: Exception -> M a
+raise e = Raise e
+ \end{CleanCode}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Monadic (3)}
+ \framesubtitle{State}
+ \pause%
+ \begin{CleanCode}
+:: M a = State -> (a, State)
+:: State :== Int
+ \end{CleanCode}
+ \pause%
+ \begin{CleanCode}
+unit :: a -> M a
+unit a = \x.(a, x)
+
+((#$\star$#)) :: (M a) (a -> M b) -> M b
+m (#$\star$#) k = \x.let (a, y) = m x in
+ let (b, z) = k a y in
+ (b, z)
+ \end{CleanCode}
+ \pause%
+ \begin{CleanCode}
+tick :: M Void
+tick = \x.(Void, x + 1)
+ \end{CleanCode}
+\end{frame}
+
+\subsection{Laws}
+\begin{frame}[fragile]
+ \frametitle{Laws}
+ \begin{block}{Monoid}
+ \begin{itemize}
+ \item Left unit:
+ \begin{CleanCode}
+unit a (#$\star$#) \b.n = n[a/b]
+ \end{CleanCode}
+ \item Right unit
+ \begin{CleanCode}
+m (#$\star$#) \a.unit a = m
+ \end{CleanCode}
+ \item Associativity
+ \begin{CleanCode}
+m (#$\star$#) (\a.n (#$\star$#) \b.o) = (m (#$\star$#) \a.n) (#$\star$#) \b.o
+ \end{CleanCode}
+ \end{itemize}
+ \end{block}
+\end{frame}
+
+\subsection{Further evidence}
+\begin{frame}[fragile]
+ \frametitle{Further examples}
+ \begin{itemize}[<+->]
+ \item Array %TODO
+ \end{itemize}
+\end{frame}