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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* SPDX-License-Identifier: MIT
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
*/
//! Natural transformations between HKT functors.
//!
//! A [`NaturalTransformation`] `F ⇒ G` is a family of maps `transform: F<A> → G<A>`, one per object
//! `A`, that commutes with mapping — the **naturality square**
//! `transform ∘ fmap f = fmap f ∘ transform`. It is the morphism between functors, and the shape a
//! monad morphism takes when it relates the targets of two Kleisli
//! [interpreters](crate::ArrowCore::interpret_kleisli): transporting an interpretation along
//! `F ⇒ G` commutes with the interpreter exactly when this square holds.
//!
//! The law is a *property* of the component (Rust cannot enforce it in the trait); it is checked for
//! [`OptionToVec`] in `deep_causality_haft/tests/formalization_lean/interpreter_tests.rs` and proved
//! in `lean/DeepCausalityFormal/Haft/Interpreter.lean` (`haft.interpreter.naturality`).
use crate::;
/// A natural transformation `F ⇒ G` between two [`HKT`] functors.
///
/// The single component [`transform`](NaturalTransformation::transform) maps `F<A>` to `G<A>`
/// uniformly in `A`. Lawful instances additionally satisfy naturality:
/// `transform(fmap(fa, f)) == fmap(transform(fa), f)` for every `f`.