X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=topics%2F_week7_monads.mdwn;h=3f2955e9f1fb6ebe476c4eee917a49d877652e1e;hp=21ac2f59d098db062ed50f14ada225764fa211f5;hb=cb9c6590ec969e34555d9c9f56758c3e6c252ce5;hpb=5186270ce99d2ebe9e761defb1fbf63bd002d679
diff --git a/topics/_week7_monads.mdwn b/topics/_week7_monads.mdwn
index 21ac2f59..3f2955e9 100644
--- a/topics/_week7_monads.mdwn
+++ b/topics/_week7_monads.mdwn
@@ -1,3 +1,5 @@
+
+
Monads
======
@@ -8,10 +10,65 @@ monsters, monads are burritos. We're part of the backlash that
prefers to say that monads are monads.
The closest we will come to metaphorical talk is to suggest that
-monadic types place objects inside of boxes, and that monads wrap and
-unwrap boxes to expose or enclose the objects inside of them. In any
-case, the emphasis will be on starting with the abstract structure of
-monads, followed by instances of monads from the philosophical and
+monadic types place objects inside of *boxes*, and that monads wrap
+and unwrap boxes to expose or enclose the objects inside of them. In
+any case, the emphasis will be on starting with the abstract structure
+of monads, followed by instances of monads from the philosophical and
linguistics literature.
-To
+### Boxes: type expressions with one free type variable
+
+Recall that we've been using lower-case Greek letters
+α, β, γ, ...
to represent types. We'll
+use `P`, `Q`, `R`, and `S` as metavariables over type schemas, where a
+type schema is a type expression that may or may not contain unbound
+type variables. For instance, we might have
+
+ P â¡ Int
+ P ⡠α -> α
+ P â¡ âα. α -> α
+ P â¡ âα. α -> β
+
+etc.
+
+A box type will be a type expression that contains exactly one free
+type variable. Some examples (using OCaml's type conventions):
+
+ α Maybe
+ α List
+ (α, P) Tree (assuming P contains no free type variables)
+ (α, α) Tree
+
+The idea is that whatever type the free type variable α might be,
+the boxed type will be a box that "contains" an object of type α.
+For instance, if `α List` is our box type, and α is the basic type
+Int, then in this context, `Int List` is the type of a boxed integer.
+
+We'll often write box types as a box containing the value of the free
+type variable. So if our box type is `α List`, and `α == Int`, we
+would write
+
+
+
+for the type of a boxed Int.
+
+At the most general level, we'll talk about *Kleisli arrows*:
+
+P ->
+
+A Kleisli arrow is the type of a function from objects of type P to
+objects of type box Q, for some choice of type expressions P and Q.
+For instance, the following are arrows:
+
+Int ->
+
+Int List ->
+
+Note that the left-hand schema can itself be a boxed type. That is,
+if `α List` is our box type, we can write the second arrow as
+
+
+->
+
+