X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=topics%2Fweek7_introducing_monads.mdwn;h=88d49ad986f25c98e5164282e87c4c0b184e21c1;hp=4750fc6916c81249b40296f51c0e3bc6dcf3d885;hb=5f451af940e44f03c8cab0864398d2e644566787;hpb=95d3e1eb9f32752fba074f3a686783c6a4e893b6 diff --git a/topics/week7_introducing_monads.mdwn b/topics/week7_introducing_monads.mdwn index 4750fc69..88d49ad9 100644 --- a/topics/week7_introducing_monads.mdwn +++ b/topics/week7_introducing_monads.mdwn @@ -1,5 +1,4 @@ - The [[tradition in the functional programming @@ -209,7 +208,7 @@ has to obey the following Map Laws: k >=> mid == k mid >=> k == k - If you studied algebra, you'll remember that a mon*oid* is a universe with some associative operation that has an identity. For example, the natural numbers form a monoid with multiplication as the operation and `1` as the identity, or with addition as the operation and `0` as the identity. Strings form a monoid with concatenation as the operation and the empty string as the identity. (This example shows that the operation need not be commutative.) Monads are a kind of generalization of this notion, and that's why they're named as they are. The key difference is that for monads, the values being operated on need not be of the same type. They *can* be, if they're all Kleisli arrows of a single type P -> P. But they needn't be. Their types only need to "cohere" in certain ways. + If you studied algebra, you'll remember that a mon*oid* is a universe with some associative operation that has an identity. For example, the natural numbers form a monoid with multiplication as the operation and `1` as the identity, or with addition as the operation and `0` as the identity. Strings form a monoid with concatenation as the operation and the empty string as the identity. (This example shows that the operation need not be commutative.) Monads are a kind of generalization of this notion, and that's why they're named as they are. The key difference is that for monads, the values being operated on need not be of the same type. They *can* be, if they're all Kleisli arrows of a single type P -> P. But they needn't be. Their types only need to "cohere" in the sense that the output type of the one arrow is a boxing of the input type of the next. In the Haskell manuals, they express the Monad Laws using `>>=` instead of the composition operators `>=>` or `<=<`. This looks similar, but doesn't have the same symmetry: @@ -438,7 +437,9 @@ As we mentioned above, the notions of Monads have their origin in Category Theor [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. +[4](https://wiki.haskell.org/Category_theory) (where you should follow the further links discussing Functors, Natural Transformations, and Monads) +[5](http://www.stephendiehl.com/posts/monads.html) + Here are some papers that introduced Monads into functional programming: