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
59
60
61
62
63
64
65
66
67
68
69
70
/*
* SPDX-License-Identifier: MIT
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
*/
//! Opt-in `PartialEq` / `Eq` / `Debug` for [`Free`], routed through the operation functor's
//! [`EqFunctor`] / [`DebugFunctor`] capability.
//!
//! `Free<F, A>` stores its recursive child under the GAT projection `Suspend(F::Type<Box<Free<F,
//! A>>>)`. A `#[derive]` — or any impl gated on the projection bound `F::Type<Box<Free<F, A>>>:
//! PartialEq` — makes the instance conditional on that projection, so discharging it at a concrete
//! witness re-enters the trait solver and overflows (`error[E0275]`). Routing the recursion through
//! `F::eq_type` / `F::fmt_type` discharges each step against **this** impl's stable bounds
//! (`F: EqFunctor`, `A: PartialEq`) instead — it terminates exactly as a plain recursive `enum List
//! { Nil, Cons(i32, Box<List>) }` does.
//!
//! The instances are additive and opt-in: they exist only when the operation witness `F` implements
//! the capability, so `Free` over a witness that does not is unaffected.
use crate::;
use fmt;
/// Structural equality of two programs: equal leaves, or equal operation nodes compared through the
/// functor's `eq_type`. Terminates because the recursive obligation `Box<Free<F, A>>: PartialEq`
/// discharges against this impl.
/// `Eq` is the marker upgrade of the structural `PartialEq`: available when the payload is `Eq` and
/// the functor supplies a (reflexive/symmetric/transitive) `eq_type`.
/// `Debug` mirrors the derive shape (`Pure(..)` / `Suspend(..)`), formatting the operation node
/// through the functor's `fmt_type`.