X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=topics%2Fweek7_introducing_monads.mdwn;h=1dbd5101872f6245b30b145ae4718680900d75a6;hp=7acc77cfad44a56d1f9b2cadb4414f1631ae5fc4;hb=435a68843444ebdaa28d6f8ac83bf78f750eeae2;hpb=8be622c594f003684e8348973c5e85911161457b diff --git a/topics/week7_introducing_monads.mdwn b/topics/week7_introducing_monads.mdwn index 7acc77cf..1dbd5101 100644 --- a/topics/week7_introducing_monads.mdwn +++ b/topics/week7_introducing_monads.mdwn @@ -152,8 +152,8 @@ The name "bind" is not well chosen from our perspective, but this is too deeply To take a trivial (but, as we will see, still useful) example, consider the Identity box type: `α`. So if `α` is type `bool`, -then a boxed `α` is ... a `bool`. In terms of the box analogy, the -Identity box type is a completely invisible box. With the following +then a boxed `α` is ... a `bool`. That is, α = α. +In terms of the box analogy, the Identity box type is a completely invisible box. With the following definitions: mid ≡ \p. p @@ -161,24 +161,24 @@ definitions: Identity is a monad. Here is a demonstration that the laws hold: - mcomp mid k == (\fgx.f(gx)) (\p.p) k - ~~> \x.(\p.p)(kx) - ~~> \x.kx - ~~> k - mcomp k mid == (\fgx.f(gx)) k (\p.p) - ~~> \x.k((\p.p)x) - ~~> \x.kx - ~~> k - mcomp (mcomp j k) l == mcomp ((\fgx.f(gx)) j k) l - ~~> mcomp (\x.j(kx)) l - == (\fgx.f(gx)) (\x.j(kx)) l - ~~> \x.(\x.j(kx))(lx) - ~~> \x.j(k(lx)) - mcomp j (mcomp k l) == mcomp j ((\fgx.f(gx)) k l) - ~~> mcomp j (\x.k(lx)) - == (\fgx.f(gx)) j (\x.k(lx)) - ~~> \x.j((\x.k(lx)) x) - ~~> \x.j(k(lx)) + mcomp mid k ≡ (\fgx.f(gx)) (\p.p) k + ~~> \x.(\p.p)(kx) + ~~> \x.kx + ~~> k + mcomp k mid ≡ (\fgx.f(gx)) k (\p.p) + ~~> \x.k((\p.p)x) + ~~> \x.kx + ~~> k + mcomp (mcomp j k) l ≡ mcomp ((\fgx.f(gx)) j k) l + ~~> mcomp (\x.j(kx)) l + ≡ (\fgx.f(gx)) (\x.j(kx)) l + ~~> \x.(\x.j(kx))(lx) + ~~> \x.j(k(lx)) + mcomp j (mcomp k l) ≡ mcomp j ((\fgx.f(gx)) k l) + ~~> mcomp j (\x.k(lx)) + ≡ (\fgx.f(gx)) j (\x.k(lx)) + ~~> \x.j((\x.k(lx)) x) + ~~> \x.j(k(lx)) The Identity Monad is favored by mimes. @@ -393,5 +393,5 @@ theory of accommodation, and a theory of the situations in which material within the sentence can satisfy presuppositions for other material that otherwise would trigger a presupposition violation; but, not surprisingly, these refinements will require some more -sophisticated techniques than the super-simple Option monad.) +sophisticated techniques than the super-simple Option/Maybe monad.)