X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=topics%2Fweek7_introducing_monads.mdwn;h=adcf0cc2d42333ff35f1311dca7d215d2aa95cb9;hp=b04f517e7b0deb57c270604befb9690b5e20b54d;hb=03bae43bc16f1f8dc98cfe2dab15264bc129beb1;hpb=a6c01f0671ccbed18f9938799f7b50eeb5bc4c50 diff --git a/topics/week7_introducing_monads.mdwn b/topics/week7_introducing_monads.mdwn index b04f517e..adcf0cc2 100644 --- a/topics/week7_introducing_monads.mdwn +++ b/topics/week7_introducing_monads.mdwn @@ -84,7 +84,7 @@ For instance, the following are Kleisli arrows: In the first, `P` has become `int` and `Q` has become `bool`. (The boxed type Q is bool). 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 +if `α list` is our box type, we can write the second type as: int -> int list @@ -107,11 +107,11 @@ Here are the types of our crucial functions, together with our pronunciation, an <=< or mcomp : (Q -> R) -> (P -> Q) -> (P -> R) ->=> or mpmoc (flip mcomp): (P -> Q) -> (Q -> R) -> (P -> R) +>=> (flip mcomp, should we call it mpmoc?): (P -> Q) -> (Q -> R) -> (P -> R) >>= or mbind : (Q) -> (Q -> R) -> (R) -=<< or mdnib (flip mbind) (Q) -> (Q -> R) -> (R) +=<< (flip mbind, should we call it mdnib?) (Q -> R) -> (Q) -> (R) join: P -> P @@ -127,7 +127,11 @@ certain useful guarantees. if there is a `map` function defined for that box type with the type given above. This has to obey the following Map Laws: - TODO LAWS + map (id : α -> α) = (id : α -> α) + map (g ○ f) = (map g) ○ (map f) + + Essentially these say that `map` is a homomorphism from `(α -> β, ○, id)` to (α -> β, ○', id'), where `○'` and `id'` are `○` and `id` restricted to arguments of type _. + * ***MapNable*** (in Haskelese, "Applicatives") A Mappable box type is *MapNable* if there are in addition `map2`, `mid`, and `mapply`. (Given either