Commits

John Kodumal committed 79c190d

More on monadtrans

Comments (0)

Files changed (1)

 	<h3>...all the way down</h3>
 </section>
 
+<section class="slide">
+	<h2>They see me composin'... they hatin'</h2>
+	<p>Life would be easier of monads <em>composed</em>. Given monads <code>M[_]</code> and <code>N[_]</code>, is <code>M[N[_]]</code> a monad? </p>
+	<div class="slide">
+		<p>We can work this out for functors:</p>
+<pre class="scala">
+implicit val ComposedFunctor[M: Functor, N: Functor] = new Functor[...] {
+	def map[A, B](fa: M[N[A]])(f: A => B) : M[N[B]] = fa.map(_.map(f(_)))
+}
+</pre>
+	</div>
+	<div class="slide">
+		<p>It's ironic (like rain on your wedding day), but in general, monads don't compose. Try it:
+<pre class="scala">
+implicit val ComposedMonad[M: Monad, N: Monad] = new Monad[...] {
+	def >>=[A, B](fa: M[N[A]])(f: A => B) : M[N[B]] = ???
+}
+</pre>
+	</div>
+	<div class="slide">
+		<p>Time for a new typeclass:</p>
+<pre class="scala">
+trait MonadTrans {
+	def liftM
+}
+</pre>
+	</div>
+</section>
+
 </body>
 </html>