7 \frametitle{Scientific Impact
}
10 \item Cited $
676$ times in $
23$ years
11 \item $
\pm 30$ cites per year
12 \item Cited as de-facto monad introducing paper
13 \item Monads in computer science: Moggi et al.\ in $
1989$
19 \frametitle{Objective \& Current state
}
20 \begin{block
}{Objective
}
22 \item First introduction to monads
28 \begin{block
}{Current state of the art
}
30 \item $
2016$: $
2$ papers citing Wadler
31 \item $
2015$: $
24$ papers citing Wadler
34 \item Introducing new monad types
35 \item Generic programming
36 \item Designing modular DSL's
37 \item Concurrency frameworks in functional languages
45 \subsection{Introduction
}
47 \frametitle{Introduction
}
49 \item Monads (Moggi et al.)
50 \item Integrate the impure in the pure
51 \item Wadler shows
\textsc{Haskell
} examples
52 \item Following samples are in
\textsc{Clean
}
56 \subsection{Naive approach
}
57 \begin{frame
}[fragile
]
58 \frametitle{Case study (
1)
}
59 \framesubtitle{Evaluator
}
61 :: Term = Con Int | Div Term Term
65 eval (Div t u) = eval t / eval u
69 answer = (Div (Div (Con
1972) (Con
2)) (Con
23))
72 error = (Div (Con
1) (Con
0))
76 \begin{frame
}[fragile
]
77 \frametitle{Case study (
2)
}
78 \framesubtitle{Exceptions
}
80 :: M a = Raise Exception | Return a
81 :: Exception :== String
84 eval (Con a) = Return a
85 eval (Div t u) = case eval t of
87 Return a = case eval u of
89 Return b = if (b ==
0)
90 (Raise "Divide by zero")
95 \begin{frame
}[fragile
]
96 \frametitle{Case study (
3)
}
97 \framesubtitle{State, count divisions
}
99 :: M a :== State -> (a, State)
102 eval :: Term -> M Int
103 eval (Con a) x = (a, x)
111 \subsection{Monadic approach
}
112 \begin{frame
}[fragile
]
113 \frametitle{Monadic (
1)
}
114 Monad is a triple: $(M, unit,
\star)$
116 \begin{block
}{Signatures
}
120 ((#$
\star$#)) :: (M a) (a -> M b) -> M b
124 \begin{block
}{Evaluator (Identity monad)
}
129 ((#$
\star$#)) :: (M a) (a -> M b) -> M b
130 ((#$
\star$#)) a k = k a
135 \begin{frame
}[fragile
]
136 \frametitle{Monadic (
2)
}
137 \framesubtitle{Exceptions
}
140 :: M a = Raise Exception | Return a
141 :: Exception :== String
148 ((#$
\star$#)) :: (M a) (a -> M b) -> M b
149 ((#$
\star$#)) m k = case m of
155 raise :: Exception -> M a
160 \begin{frame
}[fragile
]
161 \frametitle{Monadic (
3)
}
162 \framesubtitle{State
}
165 :: M a = State -> (a, State)
173 ((#$
\star$#)) :: (M a) (a -> M b) -> M b
174 ((#$
\star$#)) m k =
\x.let (a, y) = m x in
175 let (b, z) = k a y in
181 tick =
\x.(Void, x +
1)
186 \begin{frame
}[fragile
]
188 \begin{block
}{Monoid
}
192 unit a (#$
\star$#)
\b.n = n
[a/b
]
196 m (#$
\star$#)
\a.unit a = m
200 m (#$
\star$#) (
\a.n (#$
\star$#)
\b.o) = (m (#$
\star$#)
\a.n) (#$
\star$#)
\b.o
206 \subsection{Further evidence
}
207 \begin{frame
}[fragile
]
208 \frametitle{Different approach
}
209 \framesubtitle{Parsers (
1)
}
211 :: M a = State ->
[(a, State)
]
217 ((#$
\star$#)) :: (M a) (a -> M b) -> M b
218 ((#$
\star$#)) m k =
\x.
[(b, z) \\ (a, y) <- m x, (b, z) <- k a y
]
222 \begin{frame
}[fragile
]
223 \frametitle{Different approach
}
224 \framesubtitle{Parsers (
2)
}
229 ((#$
\oplus$#)) :: (M a) (M a) -> M a
230 ((#$
\oplus$#)) m n =
\x.m x ++ n x
232 ((#$
\triangleright$#)) :: (M a) (a -> Bool) -> M a
233 ((#$
\triangleright$#)) m p = m (#$
\star$#)
\a.if (p a) (unit a) zero
237 item
[a:x
] =
[(a, x)
]
241 \begin{frame
}[fragile
]
242 \frametitle{Different approach
}
243 \framesubtitle{Parsers (
3)
}
245 iterate :: M a -> M
[a
]
246 iterate m = (m (#$
\star$#)
\a.iterate m (#$
\star$#)
\x.unit
[a:x
]) (#$
\oplus$#) unit
[]
248 iterate (item (#$
\triangleright$#) isDigit) "
23 and more"
249 [(
[2,
3], " and more"), (
[2], "
3 and more"), (
[], "
23 and more")
]
253 ((#$
\oslash$#)) :: (M a) (M a) -> M a
254 ((#$
\oslash$#)) m n =
\x.if (m x <>
[]) (m x) (n x)
260 \begin{block
}{Writing style
}
261 \begin{itemize
}[<+->
]
262 \item Pleasure to read
263 \item Classical problems
268 \begin{block
}{Discussion queries
}
269 \begin{itemize
}[<+->
]
270 \item Toy implementations, bigger?
271 \item Would the last section about parsers be a paper on its own?
277 \frametitle{Questions or discussion points?
}