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
//! Implementations of functional data types.
//!
//! This module contains concrete implementations of common functional
//! programming data types and containers, each with appropriate trait
//! implementations.
//!
//! # Overview
//!
//! The data types in this module provide foundational building blocks for
//! functional programming in Rust. Each type implements relevant traits
//! from the `traits` module, enabling composition and transformation.
//!
//! # Available Data Types
//!
//! ## Core Monadic Types
//!
//! - `maybe` - Optional values with `Just(T)` and `Nothing` variants
//! - `either` - Sum type representing one of two possible values (`Left` or `Right`)
//! - `id` - Identity functor/monad, the simplest container
//! - `validated` - Accumulating error handling (unlike `Either` which fails fast)
//!
//! ## Effect Types
//!
//! - `io` - Encapsulates side effects for deferred execution
//! - `reader` - Computations that read from a shared environment
//! - `writer` - Computations that produce a log alongside a value
//! - `state` - Stateful computations with get/put operations
//! - `cont` - Continuation-passing style computations
//!
//! ## Optics
//!
//! - `lens` - Bidirectional accessors for product types (structs)
//! - `prism` - Bidirectional accessors for sum types (enums)
//! - `iso_lens` - Isomorphism combined with lens functionality
//! - `iso_prism` - Isomorphism combined with prism functionality
//!
//! ## Utility Types
//!
//! - `choice` - N-ary sum type for multiple alternatives
//! - `wrapper` - Newtype wrapper for deriving trait implementations
//!
//! ## Async Support
//!
//! - `async_monad` - Async-aware monadic operations (requires `async` feature)
//!
//! # Example
//!
//! ```rust
//! use rustica::datatypes::maybe::Maybe;
//! use rustica::datatypes::either::Either;
//! use rustica::traits::functor::Functor;
//!
//! // Using Maybe for optional values
//! let value = Maybe::Just(42);
//! let doubled = value.fmap(|x| x * 2);
//! assert_eq!(doubled, Maybe::Just(84));
//!
//! // Using Either for error handling
//! let result: Either<String, i32> = Either::Right(10);
//! let incremented = result.fmap(|x| x + 1);
//! assert_eq!(incremented, Either::Right(11));
//! ```