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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! `Kind` and `InferableBrand` traits for higher-kinded type simulation.
//!
//! Each [`trait_kind!`](fp_macros::trait_kind) invocation generates a pair of traits:
//!
//! 1. A **`Kind_{hash}`** trait implemented by [`Brand` types][crate::brands] to map
//! from brands to concrete types (the forward mapping).
//! 2. A **`InferableBrand_{hash}`** trait implemented by concrete types to enable
//! closure-directed brand inference in dispatch functions.
//!
//! Both traits share the same deterministic content hash derived from the signature.
//!
//! This is an implementation of the type-level defunctionalisation technique
//! to simulate higher-kinded types, based on Yallop and White's [Lightweight higher-kinded polymorphism](https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf).
//!
//! # `Kind` Traits
//!
//! Traits representing type-level application (brand -> concrete type).
//!
//! The naming convention is `Kind_{hash}` where `{hash}` is a deterministic
//! 64-bit hash of the canonical signature. The canonical signature includes:
//! * Number of lifetimes and types.
//! * Type bounds (with full path preservation and generic arguments).
//! * Output bounds on the associated types.
//!
//! This naming scheme ensures that semantically equivalent signatures always map to the
//! same `Kind` trait, regardless of parameter names or formatting.
//!
//! # `InferableBrand` Traits
//!
//! Traits providing closure-directed brand inference (concrete type -> brand marker).
//!
//! Each `InferableBrand_{hash}` trait has:
//! * An associated `type Marker` for dispatch resolution.
//! * A `#[diagnostic::on_unimplemented]` attribute for actionable error messages.
//!
//! `InferableBrand` impls are auto-generated by [`impl_kind!`](fp_macros::impl_kind)
//! for all brands (including multi-brand types).
//!
//! # Trait Name Examples
//!
//! | Hash | Signature | Used by |
//! |------|-----------|---------|
//! | `ad6c20556a82a1f0` | `type Of<A>;` | Simple type constructors |
//! | `cdc7cd43dac7585f` | `type Of<'a, A: 'a>: 'a;` | Most functor/monad types |
//! | `5b1bcedfd80bdc16` | `type Of<A, B>;` | Bifunctor brands (no lifetime) |
//! | `266801a817966495` | `type Of<'a, A: 'a, B: 'a>: 'a;` | Bifunctor brands (with lifetime) |
//!
//! For each hash, both `Kind_{hash}` and `InferableBrand_{hash}` exist. For example,
//! `OptionBrand` implements `Kind_cdc7cd43dac7585f`, and `Option<A>` implements
//! `InferableBrand_cdc7cd43dac7585f<OptionBrand, A>` with `type Marker = Val`.
use trait_kind;
trait_kind!
trait_kind!
trait_kind!
trait_kind!
trait_kind!
trait_kind!
trait_kind!
trait_kind!