Signed-off-by: Jim Pryor <profjim@jimpryor.net>
-The standard category-theory presentation of the monad laws
------------------------------------------------------------
+Getting to the standard category-theory presentation of the monad laws
+----------------------------------------------------------------------
In category theory, the monad laws are usually stated in terms of `unit` and `join` instead of `unit` and `<=<`.
<!--
In category theory, the monad laws are usually stated in terms of `unit` and `join` instead of `unit` and `<=<`.
<!--
Next, let <code>γ</code> be a transformation from `G` to `MG'`, and
consider the composite transformation <code>((join MG') -v- (MM γ))</code>.
Next, let <code>γ</code> be a transformation from `G` to `MG'`, and
consider the composite transformation <code>((join MG') -v- (MM γ))</code>.
-* <code>γ</code> assigns elements `C1` in <b>C</b> a morphism <code>γ\*: G(C1) → MG'(C1)</code>. <code>(MM γ)</code> is a transformation that instead assigns `C1` the morphism <code>MM(γ\*)</code>.
+* <code>γ</code> assigns elements `C1` in <b>C</b> a morphism <code>γ\*:G(C1) → MG'(C1)</code>. <code>(MM γ)</code> is a transformation that instead assigns `C1` the morphism <code>MM(γ\*)</code>.
* `(join MG')` is a transformation from `MM(MG')` to `M(MG')` that assigns `C1` the morphism `join[MG'(C1)]`.
* `(join MG')` is a transformation from `MM(MG')` to `M(MG')` that assigns `C1` the morphism `join[MG'(C1)]`.
(2) ((join MG') -v- (MM γ)) assigns to C1 the morphism join[MG'(C1)] ∘ MM(γ*).
</pre>
(2) ((join MG') -v- (MM γ)) assigns to C1 the morphism join[MG'(C1)] ∘ MM(γ*).
</pre>
+Next, consider the composite transformation <code>((M γ) -v- (join G))</code>:
- (3) Consider the composite transformation <code>((M γ) -v- (join G))</code>. This assigns to C1 the morphism M(γ*) ∘ join[G(C1)].
+ (3) ((M γ) -v- (join G)) assigns to C1 the morphism M(γ*) ∘ join[G(C1)].
</pre>
So for every element `C1` of <b>C</b>:
</pre>
So for every element `C1` of <b>C</b>:
(4) unit[C2] ∘ f = M(f) ∘ unit[C1]
</pre>
(4) unit[C2] ∘ f = M(f) ∘ unit[C1]
</pre>
+Next, consider the composite transformation <code>((M γ) -v- (unit G))</code>:
- (5) Consider the composite transformation ((M γ) -v- (unit G)). This assigns to C1 the morphism M(γ*) ∘ unit[G(C1)].
+ (5) ((M γ) -v- (unit G)) assigns to C1 the morphism M(γ*) ∘ unit[G(C1)].
+Next, consider the composite transformation <code>((unit MG') -v- γ)</code>:
- (6) Consider the composite transformation ((unit MG') -v- γ). This assigns to C1 the morphism unit[MG'(C1)] ∘ γ*.
+ (6) ((unit MG') -v- γ) assigns to C1 the morphism unit[MG'(C1)] ∘ γ*.
</pre>
So for every element C1 of <b>C</b>:
</pre>
So for every element C1 of <b>C</b>:
-7. The functional programming presentation of the monad laws
-------------------------------------------------------------
+Getting to the functional programming presentation of the monad laws
+--------------------------------------------------------------------
In functional programming, unit is usually called "return" and the monad laws are usually stated in terms of return and an operation called "bind" which is interdefinable with <=< or with join.
Additionally, whereas in category-theory one works "monomorphically", in functional programming one usually works with "polymorphic" functions.
In functional programming, unit is usually called "return" and the monad laws are usually stated in terms of return and an operation called "bind" which is interdefinable with <=< or with join.
Additionally, whereas in category-theory one works "monomorphically", in functional programming one usually works with "polymorphic" functions.