1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use Category;
use Functor;
/// An endofunctor is a functor whose source and target categories coincide: F: C → C.
///
/// Mac Lane (1971), *Categories for the Working Mathematician*, Ch. II §1.
///
/// # Why it matters
///
/// Endofunctors are the foundation of monads, comonads, fixed points, and every
/// self-referential construction in category theory. A monad is "just" an endofunctor
/// with η (unit) and μ (multiplication) natural transformations satisfying coherence
/// laws (Mac Lane Ch. VI §1; Wadler, *Monads for Functional Programming*, 1992).
///
/// Declaring a functor as `Endofunctor` makes the C → C identity first-class, rather
/// than implicit in `type Source = type Target`. Downstream code can require an
/// endofunctor at the type level (e.g., monad definitions, involutions, fixed-point
/// operators) without inspecting associated types.
///
/// # Laws
///
/// Endofunctors inherit the [`Functor`] laws (identity and composition preservation).
/// There are no additional laws.
///
/// # Implementing
///
/// An `Endofunctor` impl is an explicit claim: "this functor's source and target are
/// the same category." The compiler enforces it via the `Source = Self::Category` and
/// `Target = Self::Category` constraints on the associated type.
///
/// ```text
/// impl Endofunctor for MyInvolution {
/// type Category = MyCategory;
/// }
/// ```