unit :: a -> I a
unit a = a
((#$\star$#)) :: (M a) (a -> M b) -> M b
-a (#$\star$#) k = k a
+((#$\star$#)) a k = k a
\end{CleanCode}
\end{block}
\end{frame}
unit a = Return a
((#$\star$#)) :: (M a) (a -> M b) -> M b
-m (#$\star$#) k = case m of
+((#$\star$#)) m k = case m of
Raise e = Raise e
Return a = k a
\end{CleanCode}
unit a = \x.(a, x)
((#$\star$#)) :: (M a) (a -> M b) -> M b
-m (#$\star$#) k = \x.let (a, y) = m x in
+((#$\star$#)) m k = \x.let (a, y) = m x in
let (b, z) = k a y in
(b, z)
\end{CleanCode}
\subsection{Further evidence}
\begin{frame}[fragile]
- \frametitle{Further examples}
- \begin{itemize}[<+->]
- \item Array %TODO
- \end{itemize}
+ \frametitle{Different approach}
+ \framesubtitle{Parsers (1)}
+ \begin{CleanCode}
+:: M a = State -> [(a, State)]
+:: State :== [Char]
+
+unit :: a -> M a
+unit a = \x.[(a, x)]
+
+((#$\star$#)) :: (M a) (a -> M b) -> M b
+((#$\star$#)) m k = \x.[(b, z) \\ (a, y) <- m x, (b, z) <- k a y]
+ \end{CleanCode}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Different approach}
+ \framesubtitle{Parsers (2)}
+ \begin{CleanCode}
+zero :: M a
+zero = \x.[]
+
+((#$\oplus$#)) :: (M a) (M a) -> M a
+((#$\oplus$#)) m n = \x.m x ++ n x
+
+((#$\triangleright$#)) :: (M a) (a -> Bool) -> M a
+((#$\triangleright$#)) m p = m (#$\star$#) \a.if (p a) (unit a) zero
+
+item :: M Char
+item [] = []
+item [a:x] = [(a, x)]
+ \end{CleanCode}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Different approach}
+ \framesubtitle{Parsers (3)}
+ \begin{CleanCode}
+iterate :: M a -> M [a]
+iterate m = (m (#$\star$#) \a.iterate m (#$\star$#) \x.unit [a:x]) (#$\oplus$#) unit []
+
+iterate (item (#$\triangleright$#) isDigit) "23 and more"
+[([2,3], " and more"), ([2], "3 and more"), ([], "23 and more")]
+ \end{CleanCode}
+ \pause
+ \begin{CleanCode}
+((#$\oslash$#)) :: (M a) (M a) -> M a
+((#$\oslash$#)) m n = \x.if (m x <> []) (m x) (n x)
+ \end{CleanCode}
\end{frame}
\section{Discussion}
\begin{frame}
+ \begin{block}{Writing style}
+ \begin{itemize}[<+->]
+ \item Pleasure to read
+ \item Classical problems
+ \item Fancy words
+ \end{itemize}
+ \end{block}
+ \pause
+ \begin{block}{Discussion queries}
+ \begin{itemize}[<+->]
+ \item Toy implementations, bigger?
+ \item Would the last section about parsers be a paper on its own?
+ \end{itemize}
+ \end{block}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Questions or discussion points?}
\end{frame}
\end{document}