@@ -12,36 +12,47 @@ use crate::{HKT, HKT3, HKT4, HKT5};
1212/// Effect3: The Bridge Trait for Arity 3 Type Constructors.
1313///
1414/// This trait is implemented by a user-defined **System Witness** (e.g., `MyEffect`)
15- /// to partially apply (fix) two of the three generic parameters of the HKT3 type.
15+ /// to partially apply (fix) two of the three generic parameters of an `HKT3` type.
16+ /// It serves as a crucial component in building type-encoded effect systems,
17+ /// allowing for the explicit tracking and handling of two fixed effect types
18+ /// (e.g., Error and Warning) while keeping the primary value type generic.
1619pub trait Effect3 {
17- /// The fixed type for the first parameter (e.g., the Error type E).
20+ /// The fixed type for the first parameter of the `HKT3` type.
21+ /// In many effect systems, this represents the Error type (e.g., `String`, `MyErrorStruct`).
1822 type Fixed1 ;
1923
20- /// The fixed type for the second parameter (e.g., the Warning/Log type W).
24+ /// The fixed type for the second parameter of the `HKT3` type.
25+ /// This often represents a Warning or Log type (e.g., `String`, `Vec<String>`).
2126 type Fixed2 ;
2227
23- /// The concrete witness type that implements HKT3 with the two fixed types.
24- /// It MUST implement HKT so we can pass it to Functor/Monad functions.
28+ /// The concrete witness type that implements `HKT3` with the two fixed types (`Fixed1`, `Fixed2`).
29+ /// This witness type *MUST* also implement `HKT` to be compatible with `Functor` and `Monad` traits.
30+ /// It acts as a token to refer to the partially applied type constructor.
2531 type HktWitness : HKT3 < Self :: Fixed1 , Self :: Fixed2 > + HKT ;
2632}
2733
2834// ----------------------------------------------------
2935// Effect Traits (Arity 4)
3036// ----------------------------------------------------
3137
32- /// Effect4: The Bridge Trait for Arity 4 Type Constructors.I
38+ /// Effect4: The Bridge Trait for Arity 4 Type Constructors.
39+ ///
40+ /// Similar to `Effect3`, this trait is implemented by a user-defined **System Witness**
41+ /// to partially apply (fix) three of the four generic parameters of an `HKT4` type.
42+ /// It is used for effect systems that need to track three distinct fixed effect types
43+ /// (e.g., Error, Warning, and a Counter) alongside the primary value type.
3344pub trait Effect4 {
34- /// The fixed type for the first parameter.
45+ /// The fixed type for the first parameter of the `HKT4` type (e.g., an Error type) .
3546 type Fixed1 ;
3647
37- /// The fixed type for the second parameter.
48+ /// The fixed type for the second parameter of the `HKT4` type (e.g., a Log type) .
3849 type Fixed2 ;
3950
40- /// The fixed type for the third parameter.
51+ /// The fixed type for the third parameter of the `HKT4` type (e.g., a Counter type) .
4152 type Fixed3 ;
4253
43- /// The concrete witness type that implements HKT4 with the three fixed types.
44- /// It MUST implement HKT so we can pass it to Functor/ Monad functions .
54+ /// The concrete witness type that implements ` HKT4` with the three fixed types (`Fixed1`, `Fixed2`, `Fixed3`) .
55+ /// This witness type * MUST* also implement ` HKT` to be compatible with `Functor` and ` Monad` traits .
4556 type HktWitness : HKT4 < Self :: Fixed1 , Self :: Fixed2 , Self :: Fixed3 > + HKT ;
4657}
4758
@@ -50,12 +61,25 @@ pub trait Effect4 {
5061// ----------------------------------------------------
5162
5263/// Effect5: The Bridge Trait for Arity 5 Type Constructors.
64+ ///
65+ /// This trait is implemented by a user-defined **System Witness**
66+ /// to partially apply (fix) four of the five generic parameters of an `HKT5` type.
67+ /// It is designed for highly expressive effect systems that need to track four distinct fixed effect types
68+ /// (e.g., Error, Warning, Counter, and Trace information) alongside the primary value type.
5369pub trait Effect5 {
70+ /// The fixed type for the first parameter of the `HKT5` type (e.g., an Error type).
5471 type Fixed1 ;
72+
73+ /// The fixed type for the second parameter of the `HKT5` type (e.g., a Log type).
5574 type Fixed2 ;
75+
76+ /// The fixed type for the third parameter of the `HKT5` type (e.g., a Counter type).
5677 type Fixed3 ;
78+
79+ /// The fixed type for the fourth parameter of the `HKT5` type (e.g., a Trace type).
5780 type Fixed4 ;
5881
59- /// The concrete witness type that implements HKT5 with the four fixed types.
82+ /// The concrete witness type that implements `HKT5` with the four fixed types (`Fixed1`, `Fixed2`, `Fixed3`, `Fixed4`).
83+ /// This witness type *MUST* also implement `HKT` to be compatible with `Functor` and `Monad` traits.
6084 type HktWitness : HKT5 < Self :: Fixed1 , Self :: Fixed2 , Self :: Fixed3 , Self :: Fixed4 > + HKT ;
6185}
0 commit comments