correction
[lambda.git] / topics / week7_introducing_monads.mdwn
index 1dbd510..b04f517 100644 (file)
@@ -12,7 +12,8 @@ can be unhelpful. There's a backlash about the metaphors that tells people
 to instead just look at the formal definition. We'll give that to you below, but it's
 sometimes sloganized as
 [A monad is just a monoid in the category of endofunctors, what's the problem?](http://stackoverflow.com/questions/3870088).
-Without some intuitive guidance, this can also be unhelpful. We'll try to find a good balance. 
+Without some intuitive guidance, this can also be unhelpful. We'll try to find a good balance.
+
 
 The closest we will come to metaphorical talk is to suggest that
 monadic types place values inside of *boxes*, and that monads wrap
@@ -21,6 +22,13 @@ any case, our emphasis will be on starting with the abstract structure
 of monads, followed by instances of monads from the philosophical and
 linguistics literature.
 
+> <small>After you've read this once and are coming back to re-read it to try to digest the details further, the "endofunctors" that slogan is talking about are a combination of our boxes and their associated maps. Their "monoidal" character is captured in the Monad Laws, where a "monoid"---don't confuse with a mon*ad*---is a simpler algebraic notion, meaning a universe with some associative operation that has an identity. For advanced study, here are some further links on the relation between monads as we're working with them and monads as they appear in category theory:
+[1](http://en.wikipedia.org/wiki/Outline_of_category_theory)
+[2](http://lambda1.jimpryor.net/advanced_topics/monads_in_category_theory/)
+[3](http://en.wikibooks.org/wiki/Haskell/Category_theory)
+[4](https://wiki.haskell.org/Category_theory), where you should follow the further links discussing Functors, Natural Transformations, and Monads.</small>
+
+
 ## Box types: type expressions with one free type variable ##
 
 Recall that we've been using lower-case Greek letters
@@ -45,7 +53,7 @@ to specify which one of them the box is capturing. But let's keep it simple.) So
     (α, α) tree
 
 The idea is that whatever type the free type variable `α` might be instantiated to,
-we will be a "type box" of a certain sort that "contains" values of type `α`. For instance,
+we will have a "type box" of a certain sort that "contains" values of type `α`. For instance,
 if `α list` is our box type, and `α` is the type `int`, then in this context, `int list`
 is the type of a boxed integer.
 
@@ -78,7 +86,7 @@ In the first, `P` has become `int` and `Q` has become `bool`. (The boxed type <c
 Note that the left-hand schema `P` is permitted to itself be a boxed type. That is, where
 if `α list` is our box type, we can write the second arrow as
 
-<code><u>int</u> -> <u>Q</u></code>
+<code><u>int</u> -> <u>int list</u></code>
 
 As semanticists, you are no doubt familiar with the debates between those who insist that propositions are sets of worlds and those who insist they are context change potentials. We hope to show you, in coming weeks, that propositions are (certain sorts of) Kleisli arrows. But this doesn't really compete with the other proposals; it is a generalization of them. Both of the other proposed structures can be construed as specific Kleisli arrows.
 
@@ -180,7 +188,7 @@ Identity is a monad.  Here is a demonstration that the laws hold:
                       ~~> \x.j((\x.k(lx)) x)
                       ~~> \x.j(k(lx))
 
-The Identity Monad is favored by mimes.
+The Identity monad is favored by mimes.
 
 To take a slightly less trivial (and even more useful) example,
 consider the box type `α list`, with the following operations:
@@ -214,7 +222,7 @@ Contrast that to `m$` (`mapply`, which operates not on two *box-producing functi
     mapply gs xs ==> [49, 25, 14, 10]
 
 
-As we illustrated in class, there are clear patterns shared between lists and option types and trees, so perhaps you can see why people want to identify the general structures. But it probably isn't obvious yet why it would be useful to do so. To a large extent, this will only emerge over the next few classes. But we'll begin to demonstrate the usefulness of these patterns by talking through a simple example, that uses the Monadic functions of the Option/Maybe box type.
+As we illustrated in class, there are clear patterns shared between lists and option types and trees, so perhaps you can see why people want to identify the general structures. But it probably isn't obvious yet why it would be useful to do so. To a large extent, this will only emerge over the next few classes. But we'll begin to demonstrate the usefulness of these patterns by talking through a simple example, that uses the monadic functions of the Option/Maybe box type.
 
 
 ## Safe division ##
@@ -325,7 +333,7 @@ it needs to be adjusted because someone else might make trouble.
 
 But we can automate the adjustment, using the monadic machinery we introduced above.
 As we said, there needs to be different `>>=`, `map2` and so on operations for each
-Monad or box type we're working with.
+monad or box type we're working with.
 Haskell finesses this by "overloading" the single symbol `>>=`; you can just input that
 symbol and it will calculate from the context of the surrounding type constraints what
 monad you must have meant. In OCaml, the monadic operators are not pre-defined, but we will