1use fp_macros::*;
34
35pub use crate::dispatch::contravariant::contramap;
36pub use crate::dispatch::{
38 alt::alt,
39 apply_first::apply_first,
40 apply_second::apply_second,
41 bifoldable::{
42 bi_fold_left,
43 bi_fold_map,
44 bi_fold_right,
45 },
46 bifunctor::bimap,
47 bitraversable::bi_traverse,
48 compactable::{
49 compact,
50 separate,
51 },
52 filterable::{
53 filter,
54 filter_map,
55 partition,
56 partition_map,
57 },
58 filterable_with_index::{
59 filter_map_with_index,
60 filter_with_index,
61 partition_map_with_index,
62 partition_with_index,
63 },
64 foldable::{
65 fold_left,
66 fold_map,
67 fold_right,
68 },
69 foldable_with_index::{
70 fold_left_with_index,
71 fold_map_with_index,
72 fold_right_with_index,
73 },
74 functor::map,
75 functor_with_index::map_with_index,
76 lift::{
77 lift2,
78 lift3,
79 lift4,
80 lift5,
81 },
82 semimonad::{
83 bind,
84 bind_flipped,
85 join,
86 },
87 traversable::traverse,
88 traversable_with_index::traverse_with_index,
89 witherable::{
90 wilt,
91 wither,
92 },
93};
94fp_macros::generate_function_re_exports!("src/classes", {
96 "category::identity": category_identity,
97 "clone_fn::new": lift_fn_new,
98 "clone_fn::ref_new": ref_lift_fn_new,
99 "pointer::new": pointer_new,
100 "ref_counted_pointer::cloneable_new": ref_counted_pointer_new,
101 "send_ref_counted_pointer::send_new": send_ref_counted_pointer_new,
102 "plus::empty": plus_empty,
103 "semigroupoid::compose": semigroupoid_compose,
104 "send_clone_fn::new": send_lift_fn_new,
105 "send_clone_fn::ref_new": send_ref_lift_fn_new,
106}, exclude {
107 "contravariant::contramap",
109 "alt::alt",
110 "apply_first::apply_first",
111 "apply_second::apply_second",
112 "bifoldable::bi_fold_left",
113 "bifoldable::bi_fold_map",
114 "bifoldable::bi_fold_right",
115 "bifunctor::bimap",
116 "bitraversable::bi_traverse",
117 "compactable::compact",
118 "compactable::separate",
119 "filterable::filter",
120 "filterable::filter_map",
121 "filterable::partition",
122 "filterable::partition_map",
123 "filterable_with_index::filter_map_with_index",
124 "filterable_with_index::filter_with_index",
125 "filterable_with_index::partition_map_with_index",
126 "filterable_with_index::partition_with_index",
127 "foldable_with_index::fold_left_with_index",
128 "foldable_with_index::fold_map_with_index",
129 "foldable_with_index::fold_right_with_index",
130 "functor_with_index::map_with_index",
131 "semimonad::join",
132 "traversable::traverse",
133 "traversable_with_index::traverse_with_index",
134 "witherable::wilt",
135 "witherable::wither",
136 "ref_alt::ref_alt",
138 "ref_apply_first::ref_apply_first",
139 "ref_apply_second::ref_apply_second",
140 "ref_bifunctor::ref_bimap",
141 "ref_bifoldable::ref_bi_fold_left",
142 "ref_bifoldable::ref_bi_fold_map",
143 "ref_bifoldable::ref_bi_fold_right",
144 "ref_bitraversable::ref_bi_traverse",
145 "ref_compactable::ref_compact",
146 "ref_compactable::ref_separate",
147 "ref_filterable::ref_filter",
148 "ref_filterable::ref_filter_map",
149 "ref_filterable::ref_partition",
150 "ref_filterable::ref_partition_map",
151 "ref_filterable_with_index::ref_filter_with_index",
152 "ref_filterable_with_index::ref_filter_map_with_index",
153 "ref_filterable_with_index::ref_partition_with_index",
154 "ref_filterable_with_index::ref_partition_map_with_index",
155 "ref_foldable_with_index::ref_fold_left_with_index",
156 "ref_foldable_with_index::ref_fold_map_with_index",
157 "ref_foldable_with_index::ref_fold_right_with_index",
158 "ref_functor_with_index::ref_map_with_index",
159 "ref_semimonad::ref_join",
160 "ref_traversable_with_index::ref_traverse_with_index",
161 "ref_witherable::ref_wilt",
162 "ref_witherable::ref_wither",
163});
164pub mod explicit {
169 pub use crate::dispatch::{
170 alt::explicit::alt,
171 apply_first::explicit::apply_first,
172 apply_second::explicit::apply_second,
173 bifoldable::explicit::{
174 bi_fold_left,
175 bi_fold_map,
176 bi_fold_right,
177 },
178 bifunctor::explicit::bimap,
179 bitraversable::explicit::bi_traverse,
180 compactable::explicit::{
181 compact,
182 separate,
183 },
184 contravariant::explicit::contramap,
185 filterable::explicit::{
186 filter,
187 filter_map,
188 partition,
189 partition_map,
190 },
191 filterable_with_index::explicit::{
192 filter_map_with_index,
193 filter_with_index,
194 partition_map_with_index,
195 partition_with_index,
196 },
197 foldable::explicit::{
198 fold_left,
199 fold_map,
200 fold_right,
201 },
202 foldable_with_index::explicit::{
203 fold_left_with_index,
204 fold_map_with_index,
205 fold_right_with_index,
206 },
207 functor::explicit::map,
208 functor_with_index::explicit::map_with_index,
209 lift::explicit::{
210 lift2,
211 lift3,
212 lift4,
213 lift5,
214 },
215 semimonad::explicit::{
216 bind,
217 bind_flipped,
218 join,
219 },
220 traversable::explicit::traverse,
221 traversable_with_index::explicit::traverse_with_index,
222 witherable::explicit::{
223 wilt,
224 wither,
225 },
226 };
227}
228
229pub use crate::dispatch::semimonad::{
231 compose_kleisli,
232 compose_kleisli_flipped,
233};
234pub use crate::types::{
236 lazy::{
237 arc_lazy_fix,
238 rc_lazy_fix,
239 },
240 optics::{
241 optics_as_index,
242 optics_compose,
243 optics_indexed_fold_map,
244 optics_indexed_over,
245 optics_indexed_preview,
246 optics_indexed_set,
247 optics_indexed_view,
248 optics_reindexed,
249 optics_un_index,
250 positions,
251 },
252};
253
254#[document_signature]
259#[document_type_parameters(
261 "The input type of the inner function `g`.",
262 "The output type of `g` and the input type of `f`.",
263 "The output type of the outer function `f`."
264)]
265#[document_parameters(
267 "The outer function to apply second.",
268 "The inner function to apply first.",
269 "The argument to be passed to the composed function."
270)]
271pub fn compose<A, B, C>(
288 f: impl Fn(B) -> C,
289 g: impl Fn(A) -> B,
290) -> impl Fn(A) -> C {
291 move |a| f(g(a))
292}
293
294#[document_signature]
299#[document_type_parameters(
301 "The type of the value to return.",
302 "The type of the argument to ignore."
303)]
304#[document_parameters(
306 "The value to be returned by the constant function.",
307 "The argument to be ignored."
308)]
309pub fn constant<A: Clone, B>(
321 a: A,
322 _b: B,
323) -> A {
324 a
325}
326
327#[document_signature]
332#[document_type_parameters(
334 "The type of the first argument of the input function.",
335 "The type of the second argument of the input function.",
336 "The return type of the function."
337)]
338#[document_parameters(
340 "A binary function.",
341 "The second argument (which will be passed as the first to `f`).",
342 "The first argument (which will be passed as the second to `f`)."
343)]
344pub fn flip<A, B, C>(f: impl Fn(A, B) -> C) -> impl Fn(B, A) -> C {
359 move |b, a| f(a, b)
360}
361
362#[document_signature]
366#[document_type_parameters("The type of the value.")]
368#[document_parameters("A value.")]
370pub fn identity<A>(a: A) -> A {
383 a
384}
385
386#[document_signature]
391#[document_type_parameters(
393 "The type of the original arguments.",
394 "The type of the projected arguments.",
395 "The result type."
396)]
397#[document_parameters(
399 "The binary function to apply to the projected values.",
400 "The projection function applied to both arguments.",
401 "The first argument.",
402 "The second argument."
403)]
404#[document_returns("The result of applying `f` to the projected values.")]
406#[document_examples]
407pub fn on<A, B, C>(
420 f: impl Fn(B, B) -> C,
421 g: impl Fn(A) -> B,
422 x: A,
423 y: A,
424) -> C {
425 f(g(x), g(y))
426}