`mid (/εmaidεnt@tI/ aka unit, return, pure): P -> `__P__

+
+`map (/maep/): (P -> Q) -> `__P__ -> __Q__

+
+`map2 (/maep/): (P -> Q -> R) -> `__P__ -> __Q__ -> __R__

+
+`mapply (/εm@plai/): `__P -> Q__ -> __P__ -> __Q__

+
+`mcompose (aka <=<): (Q -> `__R__) -> (P -> __Q__) -> (P -> __R__)

+
+`mbind (aka >>=): ( `__Q__) -> (Q -> __R__) -> ( __R__)

+
+`mflipcompose (aka >=>): (P -> `__Q__) -> (Q -> __R__) -> (P -> __R__)

+
+`mflipbind (aka =<<) ( `__Q__) -> (Q -> __R__) -> ( __R__)

+
+`mjoin: `__P__ -> __P__

+
+Note that `mcompose` and `mbind` are interdefinable: `u >=> k â¡ \a. (ja >>= k)`

.
+
+In most cases of interest, the specific instances of these types will
+provide certain useful guarantees.
+
+* ***Mappable*** ("functors") At the most general level, some box types are *Mappable*
+if there is a `map` function defined for that boxt type with the type given above.
+
+* ***MapNable*** ("applicatives") A Mappable box type is *MapNable*
+ if there are in addition `map2`, `mid`, and `mapply`.
+
+* ***Monad*** ("composable") A MapNable box type is a *Monad* if
+ there is in addition a `mcompose` and `join`. In addition, in
+ order to qualify as a monad, `mid` must be a left and right
+ identity for mcompose, and mcompose must be associative. That
+ is, the following "laws" must hold:
+
+ mcompose mid k = k
+ mcompose k mid = k
+ mcompose (mcompose j k) l = mcompose j (mcompose k l)
+
+To take a trivial example (but still useful, as we will see), consider
+the identity box type Id: `Î± -> Î±`. In terms of the box analogy, the
+Identity box type is an invisible box. With the following definitions
+
+ mid â¡ \p.p
+ mcompose â¡ \f\g\x.f(gx)
+
+Id is a monad. Here is a demonstration that the laws hold:
+
+ mcompose mid k == (\f\g\x.f(gx)) (\p.p) k
+ ~~> \x.(\p.p)(kx)
+ ~~> \x.kx
+ ~~> k
+ mcompose k mid == (\f\g\x.f(gx)) k (\p.p)
+ ~~> \x.k((\p.p)x)
+ ~~> \x.kx
+ ~~> k
+ mcompose (mcompose j k) l == mcompose ((\f\g\x.f(gx)) j k) l
+ ~~> mcompose (\x.j(kx)) l
+ == (\f\g\x.f(gx)) (\x.j(kx)) l
+ ~~> \x.(\x.j(kx))(lx)
+ ~~> \x.j(k(lx))
+ mcompose j (mcompose k l) == mcompose j ((\f\g\x.f(gx)) k l)
+ ~~> mcompose j (\x.k(lx))
+ == (\f\g\x.f(gx)) j (\x.k(lx))
+ ~~> \x.j((\x.k(lx)) x)
+ ~~> \x.j(k(lx))
+
+Id is the favorite monad of mimes everywhere.
+
+To take a slightly less trivial example, consider the box type `Î±
+List`, with the following operations:
+
+ mcompose f g p = [r | q <- g p, r <- f q]
+
+In words, if g maps a P to a list of Qs, and f maps a Q to a list of
+Rs, then mcompose f g maps a P to a list of Rs by first feeding the P
+to g, then feeding each of the Qs delivered by g to f. For example,
+
+ let f q = [q, q+1] in
+ let g p = [p*p, p+p] in
+ mcompose f g 7 = [49, 50, 14, 15]
+
+It is easy to see that these definitions obey the monad laws (see exercises).
+
--
2.11.0