some refinements
authorjim <jim@web>
Sun, 22 Mar 2015 12:44:03 +0000 (08:44 -0400)
committerLinux User <ikiwiki@localhost.members.linode.com>
Sun, 22 Mar 2015 12:44:03 +0000 (08:44 -0400)
topics/week7_introducing_monads.mdwn

index 0b82d25..c7f658d 100644 (file)
@@ -120,7 +120,11 @@ Here are the types of our crucial functions, together with our pronunciation, an
 
 <code>mid (/εmaidεnt@tI/): P -> <u>P</u></code>
 
-> In Haskell, this is called `Control.Monad.return` and `Control.Applicative.pure`. In other theoretical contexts it is sometimes called `unit` or `η`. In the class presentation Jim called it `𝟭`; but now we've decided that `mid` is better. (Think of it as "m" plus "identity", not as the start of "midway".) This notion is exemplified by `Just` for the box type `Maybe α` and by the singleton function for the box type `List α`.
+> This notion is exemplified by `Just` for the box type `Maybe α` and by the singleton function for the box type `List α`. It will be a way of boxing values with your box type that plays a distinguished role in the various Laws and interdefinitions we present below.
+
+> In Haskell, this is called `Control.Monad.return` and `Control.Applicative.pure`. In other theoretical contexts it is sometimes called `unit` or `η`. All of these names are somewhat unfortunate. First, it has little to do with `η`-reduction in the Lambda Calculus. Second, it has little to do with the `() : unit` value we discussed in earlier classes. Third, it has little to do with the `return` keyword in C and other languages; that's more closely related to continuations, which we'll discuss in later weeks. Finally, this doesn't perfectly align with other uses of "pure" in the literature. `mid`'d values _will_ generally be "pure" in the other senses, but other boxed values can be too.
+
+> For all these reasons, we're thinking it will be clearer in our discussion to use a different name. In the class presentation Jim called it `𝟭`; but now we've decided that `mid` is better. (Think of it as "m" plus "identity", not as the start of "midway".)
 
 <code>m$ or mapply (/εm@plai/): <u>P -> Q</u> -> <u>P</u> -> <u>Q</u></code>
 
@@ -132,27 +136,25 @@ Here are the types of our crucial functions, together with our pronunciation, an
 
 <code>&gt;=&gt; or flip mcomp : (P -> <u>Q</u>) -> (Q -> <u>R</u>) -> (P -> <u>R</u>)</code>
 
-> In Haskell, this is `Control.Monad.>=>`. In the class handout, we gave the types for `>=>` twice, and once was correct but the other was a typo. The above is the correct typing.
+> In Haskell, this is `Control.Monad.>=>`. We will move freely back and forth between using `<=<` (aka `mcomp`) and using `>=>`, which
+is just `<=<` with its arguments flipped. `<=<` has the virtue that it corresponds more
+closely to the ordinary mathematical symbol `○`. But `>=>` has the virtue
+that its types flow more naturally from left to right.
+
+> In the class handout, we gave the types for `>=>` twice, and once was correct but the other was a typo. The above is the correct typing.
 
 <code>&gt;&gt;= or mbind : (<u>Q</u>) -> (Q -> <u>R</u>) -> (<u>R</u>)</code>
 
+> Haskell uses the symbol `>>=` but calls it "bind". This is not well chosen from the perspective of formal semantics, since it's only loosely connected with what we mean by "binding." But the name is too deeply entrenched to change. We've at least preprended an "m" to the front of "bind". In some presentations this operation is called `★`.
+
 <code>=&lt;&lt; or flip mbind : (Q -> <u>R</u>) -> (<u>Q</u>) -> (<u>R</u>)</code>
 
 <code>join: <span class="box2">P</span> -> <u>P</u></code>
 
 > In Haskell, this is `Control.Monad.join`. In other theoretical contexts it is sometimes called `μ`.
 
-Haskell uses the symbol `>>=` but calls it "bind". This is not well chosen from the perspective of formal semantics, but it's too deeply entrenched to change. We've at least preprended an "m" to the front of "bind".
-
-Haskell's names "return" and "pure" for `mid` are even less well chosen, and we think it will be clearer in our discussion to use a different name. (Also, in other theoretical contexts this notion goes by other names, anyway, like `unit` or `η` --- having nothing to do with `η`-reduction in the Lambda Calculus.)
-
 The menagerie isn't quite as bewildering as you might suppose. Many of these will be interdefinable. For example, here is how `mcomp` and `mbind` are related: <code>k <=< j ≡ \a. (j a >>= k)</code>. We'll state some other interdefinitions below.
 
-We will move freely back and forth between using `>=>` and using `<=<` (aka `mcomp`), which
-is just `>=>` with its arguments flipped. `<=<` has the virtue that it corresponds more
-closely to the ordinary mathematical symbol `○`. But `>=>` has the virtue
-that its types flow more naturally from left to right.
-
 These functions come together in several systems, and have to be defined in a way that coheres with the other functions in the system:
 
 *   ***Mappable*** (in Haskelese, "Functors") At the most general level, box types are *Mappable*