Skip to main content

fp_library/brands/
optics.rs

1//! Brand types for optics profunctors.
2//!
3//! These zero-sized types serve as type-level witnesses for the [`Kind`](crate::kinds)
4//! trait, enabling higher-kinded polymorphism over optics profunctors.
5
6#[fp_macros::document_module]
7mod inner {
8	use {
9		fp_macros::*,
10		std::marker::PhantomData,
11	};
12
13	/// Brand for the [`Bazaar`](crate::types::optics::Bazaar) profunctor.
14	#[document_type_parameters(
15		"The cloneable function brand.",
16		"The type of focus values extracted from the source.",
17		"The type of replacement values used during reconstruction."
18	)]
19	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
20	pub struct BazaarBrand<FunctionBrand, A, B>(PhantomData<(FunctionBrand, A, B)>);
21
22	/// Brand for the [`BazaarList`](crate::types::optics::BazaarList) applicative.
23	#[document_type_parameters(
24		"The cloneable function brand.",
25		"The type of focus values extracted from the source.",
26		"The type of replacement values used during reconstruction."
27	)]
28	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
29	pub struct BazaarListBrand<FunctionBrand, A, B>(PhantomData<(FunctionBrand, A, B)>);
30
31	/// Brand for the [`Exchange`](crate::types::optics::Exchange) profunctor.
32	#[document_type_parameters(
33		"The cloneable function brand.",
34		"The type of the value produced by the forward function.",
35		"The type of the value consumed by the backward function."
36	)]
37	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
38	pub struct ExchangeBrand<FunctionBrand, A, B>(PhantomData<(FunctionBrand, A, B)>);
39
40	/// Brand for the [`Forget`](crate::types::optics::Forget) profunctor.
41	#[document_type_parameters("The pointer brand.", "The return type of the function.")]
42	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
43	pub struct ForgetBrand<PointerBrand, R>(PhantomData<(PointerBrand, R)>);
44
45	/// Brand for the [`Grating`](crate::types::optics::Grating) profunctor.
46	#[document_type_parameters(
47		"The cloneable function brand.",
48		"The type of the value produced by the inner function.",
49		"The type of the value consumed by the inner function."
50	)]
51	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
52	pub struct GratingBrand<FunctionBrand, A, B>(PhantomData<(FunctionBrand, A, B)>);
53
54	/// Brand for the [`Indexed`](crate::types::optics::Indexed) profunctor wrapper.
55	#[document_type_parameters("The underlying profunctor brand.", "The index type.")]
56	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
57	pub struct IndexedBrand<P, I>(PhantomData<(P, I)>);
58
59	/// Brand for the [`Market`](crate::types::optics::Market) profunctor.
60	#[document_type_parameters(
61		"The cloneable function brand.",
62		"The type of the value produced by the preview function.",
63		"The type of the value consumed by the review function."
64	)]
65	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
66	pub struct MarketBrand<FunctionBrand, A, B>(PhantomData<(FunctionBrand, A, B)>);
67
68	/// Brand for the [`Reverse`](crate::types::optics::Reverse) profunctor.
69	///
70	/// `ReverseBrand<InnerP, PointerBrand, S, T>` fixes the inner profunctor `InnerP` and the outer
71	/// types `S` and `T`, leaving `A` and `B` free for kind application.
72	#[document_type_parameters(
73		"The inner profunctor brand whose instances are reversed.",
74		"The outer cloneable function pointer brand for wrapping the `run` function.",
75		"The fixed source type.",
76		"The fixed target type."
77	)]
78	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
79	pub struct ReverseBrand<InnerP, PointerBrand, S, T>(PhantomData<(InnerP, PointerBrand, S, T)>);
80
81	/// Brand for the [`Shop`](crate::types::optics::Shop) profunctor.
82	#[document_type_parameters(
83		"The cloneable function brand.",
84		"The type of the value produced by the getter.",
85		"The type of the value consumed by the setter."
86	)]
87	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
88	pub struct ShopBrand<FunctionBrand, A, B>(PhantomData<(FunctionBrand, A, B)>);
89
90	/// Brand for the [`Stall`](crate::types::optics::Stall) profunctor.
91	#[document_type_parameters(
92		"The cloneable function brand.",
93		"The type of the value produced by the preview function.",
94		"The type of the value consumed by the setter."
95	)]
96	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
97	pub struct StallBrand<FunctionBrand, A, B>(PhantomData<(FunctionBrand, A, B)>);
98
99	/// Brand for the [`Tagged`](crate::types::optics::Tagged) profunctor.
100	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
101	pub struct TaggedBrand;
102
103	/// Brand for the [`Zipping`](crate::types::optics::Zipping) profunctor.
104	#[document_type_parameters("The cloneable function brand.")]
105	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
106	pub struct ZippingBrand<FunctionBrand>(PhantomData<FunctionBrand>);
107}
108
109pub use inner::*;