mumuramda/
lib.rs

1// src/lib.rs
2use mumu::parser::interpreter::Interpreter;
3
4mod ns;
5
6mod functions {
7    // core arithmetic / logic
8    pub mod call;
9    pub mod add;
10    pub mod multiply;
11    pub mod subtract;
12    pub mod divide;
13    pub mod inc;
14    pub mod dec;
15    pub mod negate;
16    pub mod not;
17    pub mod and;
18    pub mod or;
19
20    // aggregates / math helpers
21    pub mod sum;
22    pub mod product;
23    pub mod mean;
24    pub mod median;
25    pub mod modulo;
26    pub mod clamp;
27    pub mod max;
28    pub mod min;
29    pub mod range;
30    pub mod times;
31
32    // comparisons / identity
33    pub mod gt;
34    pub mod gte;
35    pub mod lt;
36    pub mod lte;
37    pub mod identity;
38    pub mod always;
39    pub mod xor;
40
41    // strings & arrays basics
42    pub mod starts_with;
43    pub mod ends_with;
44    pub mod join;
45    pub mod split;
46    pub mod replace;
47    pub mod to_upper;
48    pub mod to_lower;
49    pub mod append;
50    pub mod prepend;
51    pub mod take;
52    pub mod drop;
53    pub mod map;
54    pub mod filter;
55
56    // newly included modules (existing set)
57    pub mod ascend;
58    pub mod ascend_natural;
59    pub mod default_to;
60    pub mod descend;
61    pub mod descend_natural;
62    pub mod drop_last;
63    pub mod drop_last_while;
64    pub mod drop_while;
65    pub mod has;
66    pub mod has_in;
67    pub mod head;
68    pub mod includes;
69    pub mod index_of;
70    pub mod init;
71    pub mod is_empty;
72    pub mod is_nil;
73    pub mod is_not_nil;
74    pub mod last;
75    pub mod last_index_of;
76    pub mod obj_of;
77    pub mod pair;
78    pub mod path;
79    pub mod path_or;
80    pub mod prop;
81    pub mod prop_eq;
82    pub mod prop_or;
83    pub mod reverse;
84    pub mod slice;
85    pub mod sort;
86    pub mod split_at;
87    pub mod tail;
88    pub mod take_last;
89    pub mod take_last_while;
90    pub mod zip;
91    pub mod zip_with;
92
93    // extra functions previously added
94    pub mod both;
95    pub mod complement;
96    pub mod concat;
97    pub mod cond;
98    pub mod difference;
99    pub mod dissoc;
100    pub mod dissoc_path;
101    pub mod either;
102    pub mod find;
103    pub mod find_index;
104    pub mod find_last_index;
105    pub mod has_path;
106    pub mod insert;
107    pub mod insert_all;
108    pub mod intersection;
109    pub mod intersperse;
110    pub mod keys;
111    pub mod length;
112    pub mod none;
113    pub mod nth;
114    pub mod omit;
115    pub mod ommit;
116    pub mod path_eq;
117    pub mod path_satisfies;
118    pub mod pick;
119    pub mod pick_all;
120    pub mod pick_by;
121    pub mod pluck;
122    pub mod repeat;
123    pub mod split_every;
124    pub mod to_pair;
125    pub mod union;
126    pub mod uniq;
127    pub mod values;
128
129    // previously added (latest wave)
130    pub mod aperture;
131    pub mod drop_repeats;
132    pub mod empty;
133    pub mod flip;
134    pub mod for_each;
135    pub mod identical;
136    pub mod if_else;
137    pub mod is_not_empty;
138    pub mod keys_in;
139    pub mod split_when;
140    pub mod count;
141    pub mod count_by;
142    pub mod group_by;
143    pub mod group_with;
144    pub mod index_by;
145    pub mod inner_join;
146    pub mod partition;
147    pub mod project;
148
149    // NEW modules to register now
150    pub mod adjust;
151    pub mod all;
152    pub mod all_pass;
153    pub mod any;
154    pub mod any_pass;
155    pub mod find_last;
156    pub mod n_ary; // corresponds to n.ary.rs source
157    pub mod nth_arg;
158    pub mod once;
159    pub mod reject;
160    pub mod remove;
161    pub mod sort_by;
162    pub mod symmetric_difference;
163    pub mod symmetric_difference_with;
164    pub mod tap;
165    pub mod test;
166    pub mod try_catch;
167    pub mod update;
168    pub mod xprod;
169    pub mod zip_obj;
170
171    // Newly added wave (as per latest request)
172    pub mod apply_spec;
173    pub mod apply_to;
174    pub mod clone;
175    pub mod collect_by;
176    pub mod comparator;
177    pub mod compose_with;
178    pub mod construct;
179    pub mod construct_n;
180    pub mod converge;
181    pub mod drop_repeats_with;
182    pub mod from_pairs;
183    pub mod on;
184    pub mod paths;
185    pub mod pipe_with;
186    pub mod reduce_right;
187    pub mod reduce_while;
188    pub mod sort_with;
189    pub mod to_string;
190    pub mod unless;
191
192    // EVEN NEWER modules (recent files list)
193    pub mod ap;
194    pub mod apply;
195    pub mod binary;
196    pub mod difference_with;
197    pub mod drop_repeats_by;
198    pub mod eq_by;
199    pub mod eq_props;
200    pub mod equals;
201    pub mod evolve;
202    pub mod flow;
203    pub mod for_each_obj_indexed;
204    pub mod invert;
205    pub mod invert_obj;
206    pub mod invoker;
207    pub mod is;
208    pub mod juxt;
209    pub mod map_keys;
210    pub mod r#match;
211    pub mod max_by;
212    pub mod memorize_with;
213    pub mod merge_all;
214    pub mod merge_left;
215    pub mod merge_right;
216    pub mod min_by;
217    pub mod modify;
218    pub mod r#move;
219    pub mod o;
220    pub mod partial;
221    pub mod partial_right;
222    pub mod rebuild;
223    pub mod rename_keys;
224    pub mod split_whenever;
225    pub mod swap;
226    pub mod thunkify;
227    pub mod to_pairs;
228    pub mod to_pairs_in;
229    pub mod transpose;
230    pub mod trim;
231    pub mod unapply;
232    pub mod unary;
233    pub mod uncurry;
234    pub mod unnest;
235    pub mod use_with;
236    pub mod values_in;
237    pub mod r#where;
238    pub mod where_any;
239    pub mod where_eq;
240
241    // Newly required modules to add & register now
242    pub mod assoc;
243    pub mod assoc_path;
244    pub mod f;
245    pub mod flatten;
246    pub mod map_accum;
247    pub mod map_accum_right;
248    pub mod map_obj_indexed;
249    pub mod math_mod;
250    pub mod t;
251
252    // --- Newly requested modules to expose & register now ---
253    // AddIndex family
254    pub mod add_index;
255    pub mod add_index_right;
256
257    // Lenses & optics
258    pub mod lens;
259    pub mod lens_prop;
260    pub mod lens_index;
261    pub mod lens_path;
262    pub mod view;
263    pub mod set;
264    pub mod over;
265
266    // Deep merge helpers
267    pub mod merge_deep_left;
268    pub mod merge_deep_right;
269    pub mod merge_deep_with;
270    pub mod merge_deep_with_key; // newly required
271
272    // Additional arity helper
273    pub mod uncurry_n;
274
275    // --- Newly added in this change ---
276    pub mod chain;
277    pub mod intersection_with;
278    pub mod prop_is;
279    pub mod scan;
280    pub mod take_while;
281    pub mod unfold;
282    pub mod union_with;
283    pub mod uniq_by;
284    pub mod uniq_with;
285    pub mod without;
286
287    // --- Additional requested modules to register now ---
288    pub mod and_then;
289    pub mod bind;
290    pub mod compose;
291    pub mod curry;
292    pub mod into;
293    pub mod lift;
294    pub mod lift_n;
295    pub mod of;
296    pub mod otherwise;
297    pub mod partial_object;
298    pub mod pipe;
299    pub mod promap;
300    pub mod reduce;
301    pub mod reduce_by;
302    pub mod reduced;
303    pub mod sequence;
304    pub mod until;
305    pub mod unwind;
306}
307
308pub fn register_all(interp: &mut Interpreter) {
309    // core arithmetic / logic
310    functions::call::register(interp);
311    functions::add::register(interp);
312    functions::multiply::register(interp);
313    functions::subtract::register(interp);
314    functions::divide::register(interp);
315    functions::inc::register(interp);
316    functions::dec::register(interp);
317    functions::negate::register(interp);
318    functions::not::register(interp);
319    functions::and::register(interp);
320    functions::or::register(interp);
321
322    // aggregates / math helpers
323    functions::sum::register(interp);
324    functions::product::register(interp);
325    functions::mean::register(interp);
326    functions::median::register(interp);
327    functions::modulo::register(interp);
328    functions::clamp::register(interp);
329    functions::max::register(interp);
330    functions::min::register(interp);
331    functions::range::register(interp);
332    functions::times::register(interp);
333
334    // comparisons / identity
335    functions::gt::register(interp);
336    functions::gte::register(interp);
337    functions::lt::register(interp);
338    functions::lte::register(interp);
339    functions::identity::register(interp);
340    functions::always::register(interp);
341    functions::xor::register(interp);
342
343    // strings & arrays basics
344    functions::starts_with::register(interp);
345    functions::ends_with::register(interp);
346    functions::join::register(interp);
347    functions::split::register(interp);
348    functions::replace::register(interp);
349    functions::to_upper::register(interp);
350    functions::to_lower::register(interp);
351    functions::append::register(interp);
352    functions::prepend::register(interp);
353    functions::take::register(interp);
354    functions::drop::register(interp);
355    functions::map::register(interp);
356    functions::filter::register(interp);
357
358    // AddIndex family
359    functions::add_index::register(interp);
360    functions::add_index_right::register(interp);
361
362    // existing "new" registrations
363    functions::ascend::register(interp);
364    functions::ascend_natural::register(interp);
365    functions::default_to::register(interp);
366    functions::descend::register(interp);
367    functions::descend_natural::register(interp);
368    functions::drop_last::register(interp);
369    functions::drop_last_while::register(interp);
370    functions::drop_while::register(interp);
371    functions::has::register(interp);
372    functions::has_in::register(interp);
373    functions::head::register(interp);
374    functions::includes::register(interp);
375    functions::index_of::register(interp);
376    functions::init::register(interp);
377    functions::is_empty::register(interp);
378    functions::is_nil::register(interp);
379    functions::is_not_nil::register(interp);
380    functions::last::register(interp);
381    functions::last_index_of::register(interp);
382    functions::obj_of::register(interp);
383    functions::pair::register(interp);
384    functions::path::register(interp);
385    functions::path_or::register(interp);
386    functions::prop::register(interp);
387    functions::prop_eq::register(interp);
388    functions::prop_or::register(interp);
389    functions::reverse::register(interp);
390    functions::slice::register(interp);
391    functions::sort::register(interp);
392    functions::split_at::register(interp);
393    functions::tail::register(interp);
394    functions::take_last::register(interp);
395    functions::take_last_while::register(interp);
396    functions::zip::register(interp);
397    functions::zip_with::register(interp);
398
399    // extra previously added registrations
400    functions::both::register(interp);
401    functions::complement::register(interp);
402    functions::concat::register(interp);
403    functions::cond::register(interp);
404    functions::difference::register(interp);
405    functions::dissoc::register(interp);
406    functions::dissoc_path::register(interp);
407    functions::either::register(interp);
408    functions::find::register(interp);
409    functions::find_index::register(interp);
410    functions::find_last_index::register(interp);
411    functions::has_path::register(interp);
412    functions::insert::register(interp);
413    functions::insert_all::register(interp);
414    functions::intersection::register(interp);
415    functions::intersperse::register(interp);
416    functions::keys::register(interp);
417    functions::length::register(interp);
418    functions::none::register(interp);
419    functions::nth::register(interp);
420    functions::omit::register(interp);
421    functions::ommit::register(interp);
422    functions::path_eq::register(interp);
423    functions::path_satisfies::register(interp);
424    functions::pick::register(interp);
425    functions::pick_all::register(interp);
426    functions::pick_by::register(interp);
427    functions::pluck::register(interp);
428    functions::repeat::register(interp);
429    functions::split_every::register(interp);
430    functions::to_pair::register(interp);
431    functions::union::register(interp);
432    functions::uniq::register(interp);
433    functions::values::register(interp);
434
435    // previously added (latest wave)
436    functions::aperture::register(interp);
437    functions::drop_repeats::register(interp);
438    functions::empty::register(interp);
439    functions::flip::register(interp);
440    functions::for_each::register(interp);
441    functions::identical::register(interp);
442    functions::if_else::register(interp);
443    functions::is_not_empty::register(interp);
444    functions::keys_in::register(interp);
445    functions::split_when::register(interp);
446    functions::count::register(interp);
447    functions::count_by::register(interp);
448    functions::group_by::register(interp);
449    functions::group_with::register(interp);
450    functions::index_by::register(interp);
451    functions::inner_join::register(interp);
452    functions::partition::register(interp);
453    functions::project::register(interp);
454
455    // NEW registrations now
456    functions::adjust::register(interp);
457    functions::all::register(interp);
458    functions::all_pass::register(interp);
459    functions::any::register(interp);
460    functions::any_pass::register(interp);
461    functions::find_last::register(interp);
462    functions::n_ary::register(interp);
463    functions::nth_arg::register(interp);
464    functions::once::register(interp);
465    functions::reject::register(interp);
466    functions::remove::register(interp);
467    functions::sort_by::register(interp);
468    functions::symmetric_difference::register(interp);
469    functions::symmetric_difference_with::register(interp);
470    functions::tap::register(interp);
471    functions::test::register(interp);
472    functions::try_catch::register(interp);
473    functions::update::register(interp);
474    functions::xprod::register(interp);
475    functions::zip_obj::register(interp);
476
477    // Latest added wave (apply_spec, compose_with, etc.)
478    functions::apply_spec::register(interp);
479    functions::apply_to::register(interp);
480    functions::clone::register(interp);
481    functions::collect_by::register(interp);
482    functions::comparator::register(interp);
483    functions::compose_with::register(interp);
484    functions::construct::register(interp);
485    functions::construct_n::register(interp);
486    functions::converge::register(interp);
487    functions::drop_repeats_with::register(interp);
488    functions::from_pairs::register(interp);
489    functions::on::register(interp);
490    functions::paths::register(interp);
491    functions::pipe_with::register(interp);
492    functions::reduce_right::register(interp);
493    functions::reduce_while::register(interp);
494    functions::sort_with::register(interp);
495    functions::to_string::register(interp);
496    functions::unless::register(interp);
497
498    // Even newer registrations (recent files list)
499    functions::ap::register(interp);
500    functions::apply::register(interp);
501    functions::binary::register(interp);
502    functions::difference_with::register(interp);
503    functions::drop_repeats_by::register(interp);
504    functions::eq_by::register(interp);
505    functions::eq_props::register(interp);
506    functions::equals::register(interp);
507    functions::evolve::register(interp);
508    functions::flow::register(interp);
509    functions::for_each_obj_indexed::register(interp);
510    functions::invert::register(interp);
511    functions::invert_obj::register(interp);
512    functions::invoker::register(interp);
513    functions::is::register(interp);
514    functions::juxt::register(interp);
515    functions::map_keys::register(interp);
516    functions::r#match::register(interp);
517    functions::max_by::register(interp);
518    functions::memorize_with::register(interp);
519    functions::merge_all::register(interp);
520    functions::merge_left::register(interp);
521    functions::merge_right::register(interp);
522    functions::min_by::register(interp);
523    functions::modify::register(interp);
524    functions::r#move::register(interp);
525    functions::o::register(interp);
526    functions::partial::register(interp);
527    functions::partial_right::register(interp);
528    functions::rebuild::register(interp);
529    functions::rename_keys::register(interp);
530    functions::split_whenever::register(interp);
531    functions::swap::register(interp);
532    functions::thunkify::register(interp);
533    functions::to_pairs::register(interp);
534    functions::to_pairs_in::register(interp);
535    functions::transpose::register(interp);
536    functions::trim::register(interp);
537    functions::unapply::register(interp);
538    functions::unary::register(interp);
539    functions::uncurry::register(interp);
540    functions::unnest::register(interp);
541    functions::use_with::register(interp);
542    functions::values_in::register(interp);
543    functions::r#where::register(interp);
544    functions::where_any::register(interp);
545    functions::where_eq::register(interp);
546
547    // Newly required registrations
548    functions::assoc::register(interp);
549    functions::assoc_path::register(interp);
550    functions::f::register(interp);
551    functions::flatten::register(interp);
552    functions::map_accum::register(interp);
553    functions::map_accum_right::register(interp);
554    functions::map_obj_indexed::register(interp);
555    functions::math_mod::register(interp);
556    functions::t::register(interp);
557
558    // Newly requested registrations (this change)
559    // Lenses & optics
560    functions::lens::register(interp);
561    functions::lens_prop::register(interp);
562    functions::lens_index::register(interp);
563    functions::lens_path::register(interp);
564    functions::view::register(interp);
565    functions::set::register(interp);
566    functions::over::register(interp);
567
568    // Deep merge helpers
569    functions::merge_deep_left::register(interp);
570    functions::merge_deep_right::register(interp);
571    functions::merge_deep_with::register(interp);
572    functions::merge_deep_with_key::register(interp);
573
574    // Additional arity helper
575    functions::uncurry_n::register(interp);
576
577    // --- Newly added in this change ---
578    functions::chain::register(interp);
579    functions::intersection_with::register(interp);
580    functions::prop_is::register(interp);
581    functions::scan::register(interp);
582    functions::take_while::register(interp);
583    functions::unfold::register(interp);
584    functions::union_with::register(interp);
585    functions::uniq_by::register(interp);
586    functions::uniq_with::register(interp);
587    functions::without::register(interp);
588
589    // --- Additional requested modules to register now ---
590    functions::and_then::register(interp);
591    functions::bind::register(interp);
592    functions::compose::register(interp);
593    functions::curry::register(interp);
594    functions::into::register(interp);
595    functions::lift::register(interp);
596    functions::lift_n::register(interp);
597    functions::of::register(interp);
598    functions::otherwise::register(interp);
599    functions::partial_object::register(interp);
600    functions::pipe::register(interp);
601    functions::promap::register(interp);
602    functions::reduce::register(interp);
603    functions::reduce_by::register(interp);
604    functions::reduced::register(interp);
605    functions::sequence::register(interp);
606    functions::until::register(interp);
607    functions::unwind::register(interp);
608}
609
610#[cfg(feature = "host")]
611#[no_mangle]
612pub extern "C" fn Cargo_lock(
613    interp_ptr: *mut ::std::ffi::c_void,
614    _unused: *const ::std::ffi::c_void,
615) -> i32 {
616    unsafe {
617        let interp = &mut *(interp_ptr as *mut Interpreter);
618        register_all(interp);
619    }
620    0
621}