@nlozgachev/pipekit 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  A TypeScript toolkit for writing code that means exactly what it says.
6
6
 
7
+ > **Note:** pipekit is pre-1.0. The API may change between minor versions until the 1.0 release.
8
+
7
9
  ```sh
8
10
  # npm / pnpm / yarn / bun
9
11
  npm add @nlozgachev/pipekit
@@ -36,6 +38,10 @@ No FP jargon required. You won't find `Monad`, `Functor`, or `Applicative` in th
36
38
  - **`These<E, A>`** — an inclusive OR: holds an error, a value, or both at once.
37
39
  - **`RemoteData<E, A>`** — the four states of a data fetch: `NotAsked`, `Loading`, `Failure`,
38
40
  `Success`.
41
+ - **`Lens<S, A>`** — focus on a required field in a nested structure. Read, set, and modify
42
+ immutably.
43
+ - **`Optional<S, A>`** — like `Lens`, but the target may be absent (nullable fields, array indices).
44
+ - **`Reader<R, A>`** — a computation that depends on an environment `R`, resolved later.
39
45
  - **`Arr`** — array utilities that return `Option` instead of `undefined`.
40
46
  - **`Rec`** — record/object utilities.
41
47
 
@@ -0,0 +1,98 @@
1
+ export var Lens;
2
+ (function (Lens) {
3
+ /**
4
+ * Constructs a Lens from a getter and a setter.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const nameLens = Lens.make(
9
+ * (user: User) => user.name,
10
+ * (name) => (user) => ({ ...user, name }),
11
+ * );
12
+ * ```
13
+ */
14
+ Lens.make = (get, set) => ({ get, set });
15
+ /**
16
+ * Creates a Lens that focuses on a property of an object.
17
+ * Call with the structure type first, then the key.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const nameLens = Lens.prop<User>()("name");
22
+ * ```
23
+ */
24
+ Lens.prop = () => (key) => Lens.make((s) => s[key], (a) => (s) => ({ ...s, [key]: a }));
25
+ /**
26
+ * Reads the focused value from a structure.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * pipe(user, Lens.get(nameLens)); // "Alice"
31
+ * ```
32
+ */
33
+ Lens.get = (lens) => (s) => lens.get(s);
34
+ /**
35
+ * Replaces the focused value within a structure, returning a new structure.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * pipe(user, Lens.set(nameLens)("Bob")); // new User with name "Bob"
40
+ * ```
41
+ */
42
+ Lens.set = (lens) => (a) => (s) => lens.set(a)(s);
43
+ /**
44
+ * Applies a function to the focused value, returning a new structure.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * pipe(user, Lens.modify(nameLens)(n => n.toUpperCase())); // "ALICE"
49
+ * ```
50
+ */
51
+ Lens.modify = (lens) => (f) => (s) => lens.set(f(lens.get(s)))(s);
52
+ /**
53
+ * Composes two Lenses: focuses through the outer, then through the inner.
54
+ * Use in a pipe chain to build up a deep focus step by step.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const userCityLens = pipe(
59
+ * Lens.prop<User>()("address"),
60
+ * Lens.andThen(Lens.prop<Address>()("city")),
61
+ * );
62
+ * ```
63
+ */
64
+ Lens.andThen = (inner) => (outer) => Lens.make((s) => inner.get(outer.get(s)), (b) => (s) => outer.set(inner.set(b)(outer.get(s)))(s));
65
+ /**
66
+ * Composes a Lens with an Optional, producing an Optional.
67
+ * Use when the next step in the focus is optional (may be absent).
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const userBioOpt = pipe(
72
+ * Lens.prop<User>()("profile"),
73
+ * Lens.andThenOptional(Optional.prop<Profile>()("bio")),
74
+ * );
75
+ * ```
76
+ */
77
+ Lens.andThenOptional = (inner) => (outer) => ({
78
+ get: (s) => inner.get(outer.get(s)),
79
+ set: (b) => (s) => outer.set(inner.set(b)(outer.get(s)))(s),
80
+ });
81
+ /**
82
+ * Converts a Lens to an Optional. Every Lens is a valid Optional
83
+ * whose get always returns Some.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * pipe(
88
+ * Lens.prop<User>()("address"),
89
+ * Lens.toOptional,
90
+ * Optional.andThen(Optional.prop<Address>()("landmark")),
91
+ * );
92
+ * ```
93
+ */
94
+ Lens.toOptional = (lens) => ({
95
+ get: (s) => ({ kind: "Some", value: lens.get(s) }),
96
+ set: lens.set,
97
+ });
98
+ })(Lens || (Lens = {}));
@@ -0,0 +1,160 @@
1
+ import { Option } from "./Option.js";
2
+ export var Optional;
3
+ (function (Optional) {
4
+ /**
5
+ * Constructs an Optional from a getter (returning Option<A>) and a setter.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const firstChar = Optional.make(
10
+ * (s: string) => s.length > 0 ? Option.some(s[0]) : Option.none(),
11
+ * (c) => (s) => s.length > 0 ? c + s.slice(1) : s,
12
+ * );
13
+ * ```
14
+ */
15
+ Optional.make = (get, set) => ({ get, set });
16
+ /**
17
+ * Creates an Optional that focuses on an optional property of an object.
18
+ * Only keys whose type includes undefined (i.e. `field?: T`) are accepted.
19
+ * Call with the structure type first, then the key.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * type Profile = { username: string; bio?: string };
24
+ * const bioOpt = Optional.prop<Profile>()("bio");
25
+ * ```
26
+ */
27
+ Optional.prop = () => (key) => Optional.make((s) => {
28
+ const val = s[key];
29
+ return val != null ? Option.some(val) : Option.none();
30
+ }, (a) => (s) => ({ ...s, [key]: a }));
31
+ /**
32
+ * Creates an Optional that focuses on an element at a given index in an array.
33
+ * Returns None when the index is out of bounds; set is a no-op when out of bounds.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const firstItem = Optional.index<string>(0);
38
+ *
39
+ * pipe(["a", "b"], Optional.get(firstItem)); // Some("a")
40
+ * pipe([], Optional.get(firstItem)); // None
41
+ * ```
42
+ */
43
+ Optional.index = (i) => Optional.make((arr) => i >= 0 && i < arr.length ? Option.some(arr[i]) : Option.none(), (a) => (arr) => {
44
+ if (i < 0 || i >= arr.length)
45
+ return arr;
46
+ const copy = [...arr];
47
+ copy[i] = a;
48
+ return copy;
49
+ });
50
+ /**
51
+ * Reads the focused value from a structure, returning Option<A>.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * pipe(profile, Optional.get(bioOpt)); // Some("...") or None
56
+ * ```
57
+ */
58
+ Optional.get = (opt) => (s) => opt.get(s);
59
+ /**
60
+ * Replaces the focused value within a structure.
61
+ * For indexed focuses, this is a no-op when the index is out of bounds.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * pipe(profile, Optional.set(bioOpt)("hello"));
66
+ * ```
67
+ */
68
+ Optional.set = (opt) => (a) => (s) => opt.set(a)(s);
69
+ /**
70
+ * Applies a function to the focused value if it is present; returns the
71
+ * structure unchanged if the focus is absent.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * pipe(profile, Optional.modify(bioOpt)(s => s.toUpperCase()));
76
+ * ```
77
+ */
78
+ Optional.modify = (opt) => (f) => (s) => {
79
+ const val = opt.get(s);
80
+ return val.kind === "None" ? s : opt.set(f(val.value))(s);
81
+ };
82
+ /**
83
+ * Returns the focused value or a default when the focus is absent.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * pipe(profile, Optional.getOrElse(bioOpt)("no bio"));
88
+ * ```
89
+ */
90
+ Optional.getOrElse = (opt) => (defaultValue) => (s) => {
91
+ const val = opt.get(s);
92
+ return val.kind === "Some" ? val.value : defaultValue;
93
+ };
94
+ /**
95
+ * Extracts a value from an Optional focus using handlers for the present
96
+ * and absent cases.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * pipe(profile, Optional.fold(bioOpt)(() => "no bio", (bio) => bio.toUpperCase()));
101
+ * ```
102
+ */
103
+ Optional.fold = (opt) => (onNone, onSome) => (s) => {
104
+ const val = opt.get(s);
105
+ return val.kind === "Some" ? onSome(val.value) : onNone();
106
+ };
107
+ /**
108
+ * Pattern matches on an Optional focus using a named-case object.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * pipe(
113
+ * profile,
114
+ * Optional.match(bioOpt)({ none: () => "no bio", some: (bio) => bio }),
115
+ * );
116
+ * ```
117
+ */
118
+ Optional.match = (opt) => (cases) => (s) => {
119
+ const val = opt.get(s);
120
+ return val.kind === "Some" ? cases.some(val.value) : cases.none();
121
+ };
122
+ /**
123
+ * Composes two Optionals: focuses through the outer, then through the inner.
124
+ * Returns None if either focus is absent.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * const deepOpt = pipe(
129
+ * Optional.prop<User>()("address"),
130
+ * Optional.andThen(Optional.prop<Address>()("landmark")),
131
+ * );
132
+ * ```
133
+ */
134
+ Optional.andThen = (inner) => (outer) => Optional.make((s) => {
135
+ const mid = outer.get(s);
136
+ return mid.kind === "None" ? Option.none() : inner.get(mid.value);
137
+ }, (b) => (s) => {
138
+ const mid = outer.get(s);
139
+ return mid.kind === "None" ? s : outer.set(inner.set(b)(mid.value))(s);
140
+ });
141
+ /**
142
+ * Composes an Optional with a Lens, producing an Optional.
143
+ * The Lens focuses within the value found by the Optional.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * const cityOpt = pipe(
148
+ * Optional.prop<User>()("address"),
149
+ * Optional.andThenLens(Lens.prop<Address>()("city")),
150
+ * );
151
+ * ```
152
+ */
153
+ Optional.andThenLens = (inner) => (outer) => Optional.make((s) => {
154
+ const mid = outer.get(s);
155
+ return mid.kind === "None" ? Option.none() : Option.some(inner.get(mid.value));
156
+ }, (b) => (s) => {
157
+ const mid = outer.get(s);
158
+ return mid.kind === "None" ? s : outer.set(inner.set(b)(mid.value))(s);
159
+ });
160
+ })(Optional || (Optional = {}));
@@ -0,0 +1,134 @@
1
+ export var Reader;
2
+ (function (Reader) {
3
+ /**
4
+ * Lifts a pure value into a Reader. The environment is ignored.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const always42: Reader<Config, number> = Reader.resolve(42);
9
+ * always42(anyConfig); // 42
10
+ * ```
11
+ */
12
+ Reader.resolve = (value) => (_env) => value;
13
+ /**
14
+ * Returns the full environment as the result.
15
+ * The fundamental way to access the environment in a pipeline.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * pipe(
20
+ * Reader.ask<Config>(),
21
+ * Reader.map(config => config.baseUrl)
22
+ * )(appConfig); // "https://api.example.com"
23
+ * ```
24
+ */
25
+ Reader.ask = () => (env) => env;
26
+ /**
27
+ * Projects a value from the environment using a selector function.
28
+ * Equivalent to `pipe(Reader.ask(), Reader.map(f))` but more direct.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const getBaseUrl: Reader<Config, string> = Reader.asks(c => c.baseUrl);
33
+ * getBaseUrl(appConfig); // "https://api.example.com"
34
+ * ```
35
+ */
36
+ Reader.asks = (f) => (env) => f(env);
37
+ /**
38
+ * Transforms the value produced by a Reader.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * pipe(
43
+ * Reader.asks((c: Config) => c.baseUrl),
44
+ * Reader.map(url => url.toUpperCase())
45
+ * )(appConfig); // "HTTPS://API.EXAMPLE.COM"
46
+ * ```
47
+ */
48
+ Reader.map = (f) => (data) => (env) => f(data(env));
49
+ /**
50
+ * Sequences two Readers. Both see the same environment.
51
+ * The output of the first is passed to `f`, which returns the next Reader.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const buildUrl = (path: string): Reader<Config, string> =>
56
+ * Reader.asks(c => `${c.baseUrl}${path}`);
57
+ *
58
+ * const addAuth = (url: string): Reader<Config, string> =>
59
+ * Reader.asks(c => `${url}?key=${c.apiKey}`);
60
+ *
61
+ * pipe(
62
+ * buildUrl("/items"),
63
+ * Reader.chain(addAuth)
64
+ * )(appConfig); // "https://api.example.com/items?key=secret"
65
+ * ```
66
+ */
67
+ Reader.chain = (f) => (data) => (env) => f(data(env))(env);
68
+ /**
69
+ * Applies a function wrapped in a Reader to a value wrapped in a Reader.
70
+ * Both Readers see the same environment.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const add = (a: number) => (b: number) => a + b;
75
+ * pipe(
76
+ * Reader.resolve<Config, typeof add>(add),
77
+ * Reader.ap(Reader.asks(c => c.timeout)),
78
+ * Reader.ap(Reader.resolve(5))
79
+ * )(appConfig);
80
+ * ```
81
+ */
82
+ Reader.ap = (arg) => (data) => (env) => data(env)(arg(env));
83
+ /**
84
+ * Executes a side effect on the produced value without changing the Reader.
85
+ * Useful for logging or debugging inside a pipeline.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * pipe(
90
+ * buildUrl("/users"),
91
+ * Reader.tap(url => console.log("Requesting:", url)),
92
+ * Reader.chain(addAuth)
93
+ * )(appConfig);
94
+ * ```
95
+ */
96
+ Reader.tap = (f) => (data) => (env) => {
97
+ const a = data(env);
98
+ f(a);
99
+ return a;
100
+ };
101
+ /**
102
+ * Adapts a Reader to work with a different (typically wider) environment
103
+ * by transforming the environment before passing it to the Reader.
104
+ * This lets you compose Readers that expect different environments.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * type AppEnv = { db: DbPool; config: Config; logger: Logger };
109
+ *
110
+ * // buildUrl only needs Config
111
+ * const buildUrl: Reader<Config, string> = Reader.asks(c => c.baseUrl);
112
+ *
113
+ * // Zoom in from AppEnv to Config
114
+ * const buildUrlFromApp: Reader<AppEnv, string> =
115
+ * pipe(buildUrl, Reader.local((env: AppEnv) => env.config));
116
+ *
117
+ * buildUrlFromApp(appEnv); // works with the full AppEnv
118
+ * ```
119
+ */
120
+ Reader.local = (f) => (data) => (env) => data(f(env));
121
+ /**
122
+ * Runs a Reader by supplying the environment. Use this at the edge of your
123
+ * program where the environment is available.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * pipe(
128
+ * buildEndpoint("/users"),
129
+ * Reader.run(appConfig)
130
+ * ); // "https://api.example.com/users?key=secret"
131
+ * ```
132
+ */
133
+ Reader.run = (env) => (data) => data(env);
134
+ })(Reader || (Reader = {}));
@@ -1,5 +1,8 @@
1
1
  export * from "./Arr.js";
2
+ export * from "./Lens.js";
2
3
  export * from "./Option.js";
4
+ export * from "./Reader.js";
5
+ export * from "./Optional.js";
3
6
  export * from "./Rec.js";
4
7
  export * from "./RemoteData.js";
5
8
  export * from "./Result.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nlozgachev/pipekit",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Simple functional programming toolkit for TypeScript",
5
5
  "keywords": [
6
6
  "functional",
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Lens = void 0;
4
+ var Lens;
5
+ (function (Lens) {
6
+ /**
7
+ * Constructs a Lens from a getter and a setter.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const nameLens = Lens.make(
12
+ * (user: User) => user.name,
13
+ * (name) => (user) => ({ ...user, name }),
14
+ * );
15
+ * ```
16
+ */
17
+ Lens.make = (get, set) => ({ get, set });
18
+ /**
19
+ * Creates a Lens that focuses on a property of an object.
20
+ * Call with the structure type first, then the key.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const nameLens = Lens.prop<User>()("name");
25
+ * ```
26
+ */
27
+ Lens.prop = () => (key) => Lens.make((s) => s[key], (a) => (s) => ({ ...s, [key]: a }));
28
+ /**
29
+ * Reads the focused value from a structure.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * pipe(user, Lens.get(nameLens)); // "Alice"
34
+ * ```
35
+ */
36
+ Lens.get = (lens) => (s) => lens.get(s);
37
+ /**
38
+ * Replaces the focused value within a structure, returning a new structure.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * pipe(user, Lens.set(nameLens)("Bob")); // new User with name "Bob"
43
+ * ```
44
+ */
45
+ Lens.set = (lens) => (a) => (s) => lens.set(a)(s);
46
+ /**
47
+ * Applies a function to the focused value, returning a new structure.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * pipe(user, Lens.modify(nameLens)(n => n.toUpperCase())); // "ALICE"
52
+ * ```
53
+ */
54
+ Lens.modify = (lens) => (f) => (s) => lens.set(f(lens.get(s)))(s);
55
+ /**
56
+ * Composes two Lenses: focuses through the outer, then through the inner.
57
+ * Use in a pipe chain to build up a deep focus step by step.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const userCityLens = pipe(
62
+ * Lens.prop<User>()("address"),
63
+ * Lens.andThen(Lens.prop<Address>()("city")),
64
+ * );
65
+ * ```
66
+ */
67
+ Lens.andThen = (inner) => (outer) => Lens.make((s) => inner.get(outer.get(s)), (b) => (s) => outer.set(inner.set(b)(outer.get(s)))(s));
68
+ /**
69
+ * Composes a Lens with an Optional, producing an Optional.
70
+ * Use when the next step in the focus is optional (may be absent).
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const userBioOpt = pipe(
75
+ * Lens.prop<User>()("profile"),
76
+ * Lens.andThenOptional(Optional.prop<Profile>()("bio")),
77
+ * );
78
+ * ```
79
+ */
80
+ Lens.andThenOptional = (inner) => (outer) => ({
81
+ get: (s) => inner.get(outer.get(s)),
82
+ set: (b) => (s) => outer.set(inner.set(b)(outer.get(s)))(s),
83
+ });
84
+ /**
85
+ * Converts a Lens to an Optional. Every Lens is a valid Optional
86
+ * whose get always returns Some.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * pipe(
91
+ * Lens.prop<User>()("address"),
92
+ * Lens.toOptional,
93
+ * Optional.andThen(Optional.prop<Address>()("landmark")),
94
+ * );
95
+ * ```
96
+ */
97
+ Lens.toOptional = (lens) => ({
98
+ get: (s) => ({ kind: "Some", value: lens.get(s) }),
99
+ set: lens.set,
100
+ });
101
+ })(Lens || (exports.Lens = Lens = {}));
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Optional = void 0;
4
+ const Option_js_1 = require("./Option.js");
5
+ var Optional;
6
+ (function (Optional) {
7
+ /**
8
+ * Constructs an Optional from a getter (returning Option<A>) and a setter.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const firstChar = Optional.make(
13
+ * (s: string) => s.length > 0 ? Option.some(s[0]) : Option.none(),
14
+ * (c) => (s) => s.length > 0 ? c + s.slice(1) : s,
15
+ * );
16
+ * ```
17
+ */
18
+ Optional.make = (get, set) => ({ get, set });
19
+ /**
20
+ * Creates an Optional that focuses on an optional property of an object.
21
+ * Only keys whose type includes undefined (i.e. `field?: T`) are accepted.
22
+ * Call with the structure type first, then the key.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * type Profile = { username: string; bio?: string };
27
+ * const bioOpt = Optional.prop<Profile>()("bio");
28
+ * ```
29
+ */
30
+ Optional.prop = () => (key) => Optional.make((s) => {
31
+ const val = s[key];
32
+ return val != null ? Option_js_1.Option.some(val) : Option_js_1.Option.none();
33
+ }, (a) => (s) => ({ ...s, [key]: a }));
34
+ /**
35
+ * Creates an Optional that focuses on an element at a given index in an array.
36
+ * Returns None when the index is out of bounds; set is a no-op when out of bounds.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const firstItem = Optional.index<string>(0);
41
+ *
42
+ * pipe(["a", "b"], Optional.get(firstItem)); // Some("a")
43
+ * pipe([], Optional.get(firstItem)); // None
44
+ * ```
45
+ */
46
+ Optional.index = (i) => Optional.make((arr) => i >= 0 && i < arr.length ? Option_js_1.Option.some(arr[i]) : Option_js_1.Option.none(), (a) => (arr) => {
47
+ if (i < 0 || i >= arr.length)
48
+ return arr;
49
+ const copy = [...arr];
50
+ copy[i] = a;
51
+ return copy;
52
+ });
53
+ /**
54
+ * Reads the focused value from a structure, returning Option<A>.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * pipe(profile, Optional.get(bioOpt)); // Some("...") or None
59
+ * ```
60
+ */
61
+ Optional.get = (opt) => (s) => opt.get(s);
62
+ /**
63
+ * Replaces the focused value within a structure.
64
+ * For indexed focuses, this is a no-op when the index is out of bounds.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * pipe(profile, Optional.set(bioOpt)("hello"));
69
+ * ```
70
+ */
71
+ Optional.set = (opt) => (a) => (s) => opt.set(a)(s);
72
+ /**
73
+ * Applies a function to the focused value if it is present; returns the
74
+ * structure unchanged if the focus is absent.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * pipe(profile, Optional.modify(bioOpt)(s => s.toUpperCase()));
79
+ * ```
80
+ */
81
+ Optional.modify = (opt) => (f) => (s) => {
82
+ const val = opt.get(s);
83
+ return val.kind === "None" ? s : opt.set(f(val.value))(s);
84
+ };
85
+ /**
86
+ * Returns the focused value or a default when the focus is absent.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * pipe(profile, Optional.getOrElse(bioOpt)("no bio"));
91
+ * ```
92
+ */
93
+ Optional.getOrElse = (opt) => (defaultValue) => (s) => {
94
+ const val = opt.get(s);
95
+ return val.kind === "Some" ? val.value : defaultValue;
96
+ };
97
+ /**
98
+ * Extracts a value from an Optional focus using handlers for the present
99
+ * and absent cases.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * pipe(profile, Optional.fold(bioOpt)(() => "no bio", (bio) => bio.toUpperCase()));
104
+ * ```
105
+ */
106
+ Optional.fold = (opt) => (onNone, onSome) => (s) => {
107
+ const val = opt.get(s);
108
+ return val.kind === "Some" ? onSome(val.value) : onNone();
109
+ };
110
+ /**
111
+ * Pattern matches on an Optional focus using a named-case object.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * pipe(
116
+ * profile,
117
+ * Optional.match(bioOpt)({ none: () => "no bio", some: (bio) => bio }),
118
+ * );
119
+ * ```
120
+ */
121
+ Optional.match = (opt) => (cases) => (s) => {
122
+ const val = opt.get(s);
123
+ return val.kind === "Some" ? cases.some(val.value) : cases.none();
124
+ };
125
+ /**
126
+ * Composes two Optionals: focuses through the outer, then through the inner.
127
+ * Returns None if either focus is absent.
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * const deepOpt = pipe(
132
+ * Optional.prop<User>()("address"),
133
+ * Optional.andThen(Optional.prop<Address>()("landmark")),
134
+ * );
135
+ * ```
136
+ */
137
+ Optional.andThen = (inner) => (outer) => Optional.make((s) => {
138
+ const mid = outer.get(s);
139
+ return mid.kind === "None" ? Option_js_1.Option.none() : inner.get(mid.value);
140
+ }, (b) => (s) => {
141
+ const mid = outer.get(s);
142
+ return mid.kind === "None" ? s : outer.set(inner.set(b)(mid.value))(s);
143
+ });
144
+ /**
145
+ * Composes an Optional with a Lens, producing an Optional.
146
+ * The Lens focuses within the value found by the Optional.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * const cityOpt = pipe(
151
+ * Optional.prop<User>()("address"),
152
+ * Optional.andThenLens(Lens.prop<Address>()("city")),
153
+ * );
154
+ * ```
155
+ */
156
+ Optional.andThenLens = (inner) => (outer) => Optional.make((s) => {
157
+ const mid = outer.get(s);
158
+ return mid.kind === "None" ? Option_js_1.Option.none() : Option_js_1.Option.some(inner.get(mid.value));
159
+ }, (b) => (s) => {
160
+ const mid = outer.get(s);
161
+ return mid.kind === "None" ? s : outer.set(inner.set(b)(mid.value))(s);
162
+ });
163
+ })(Optional || (exports.Optional = Optional = {}));
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Reader = void 0;
4
+ var Reader;
5
+ (function (Reader) {
6
+ /**
7
+ * Lifts a pure value into a Reader. The environment is ignored.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const always42: Reader<Config, number> = Reader.resolve(42);
12
+ * always42(anyConfig); // 42
13
+ * ```
14
+ */
15
+ Reader.resolve = (value) => (_env) => value;
16
+ /**
17
+ * Returns the full environment as the result.
18
+ * The fundamental way to access the environment in a pipeline.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * pipe(
23
+ * Reader.ask<Config>(),
24
+ * Reader.map(config => config.baseUrl)
25
+ * )(appConfig); // "https://api.example.com"
26
+ * ```
27
+ */
28
+ Reader.ask = () => (env) => env;
29
+ /**
30
+ * Projects a value from the environment using a selector function.
31
+ * Equivalent to `pipe(Reader.ask(), Reader.map(f))` but more direct.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const getBaseUrl: Reader<Config, string> = Reader.asks(c => c.baseUrl);
36
+ * getBaseUrl(appConfig); // "https://api.example.com"
37
+ * ```
38
+ */
39
+ Reader.asks = (f) => (env) => f(env);
40
+ /**
41
+ * Transforms the value produced by a Reader.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * pipe(
46
+ * Reader.asks((c: Config) => c.baseUrl),
47
+ * Reader.map(url => url.toUpperCase())
48
+ * )(appConfig); // "HTTPS://API.EXAMPLE.COM"
49
+ * ```
50
+ */
51
+ Reader.map = (f) => (data) => (env) => f(data(env));
52
+ /**
53
+ * Sequences two Readers. Both see the same environment.
54
+ * The output of the first is passed to `f`, which returns the next Reader.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const buildUrl = (path: string): Reader<Config, string> =>
59
+ * Reader.asks(c => `${c.baseUrl}${path}`);
60
+ *
61
+ * const addAuth = (url: string): Reader<Config, string> =>
62
+ * Reader.asks(c => `${url}?key=${c.apiKey}`);
63
+ *
64
+ * pipe(
65
+ * buildUrl("/items"),
66
+ * Reader.chain(addAuth)
67
+ * )(appConfig); // "https://api.example.com/items?key=secret"
68
+ * ```
69
+ */
70
+ Reader.chain = (f) => (data) => (env) => f(data(env))(env);
71
+ /**
72
+ * Applies a function wrapped in a Reader to a value wrapped in a Reader.
73
+ * Both Readers see the same environment.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * const add = (a: number) => (b: number) => a + b;
78
+ * pipe(
79
+ * Reader.resolve<Config, typeof add>(add),
80
+ * Reader.ap(Reader.asks(c => c.timeout)),
81
+ * Reader.ap(Reader.resolve(5))
82
+ * )(appConfig);
83
+ * ```
84
+ */
85
+ Reader.ap = (arg) => (data) => (env) => data(env)(arg(env));
86
+ /**
87
+ * Executes a side effect on the produced value without changing the Reader.
88
+ * Useful for logging or debugging inside a pipeline.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * pipe(
93
+ * buildUrl("/users"),
94
+ * Reader.tap(url => console.log("Requesting:", url)),
95
+ * Reader.chain(addAuth)
96
+ * )(appConfig);
97
+ * ```
98
+ */
99
+ Reader.tap = (f) => (data) => (env) => {
100
+ const a = data(env);
101
+ f(a);
102
+ return a;
103
+ };
104
+ /**
105
+ * Adapts a Reader to work with a different (typically wider) environment
106
+ * by transforming the environment before passing it to the Reader.
107
+ * This lets you compose Readers that expect different environments.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * type AppEnv = { db: DbPool; config: Config; logger: Logger };
112
+ *
113
+ * // buildUrl only needs Config
114
+ * const buildUrl: Reader<Config, string> = Reader.asks(c => c.baseUrl);
115
+ *
116
+ * // Zoom in from AppEnv to Config
117
+ * const buildUrlFromApp: Reader<AppEnv, string> =
118
+ * pipe(buildUrl, Reader.local((env: AppEnv) => env.config));
119
+ *
120
+ * buildUrlFromApp(appEnv); // works with the full AppEnv
121
+ * ```
122
+ */
123
+ Reader.local = (f) => (data) => (env) => data(f(env));
124
+ /**
125
+ * Runs a Reader by supplying the environment. Use this at the edge of your
126
+ * program where the environment is available.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * pipe(
131
+ * buildEndpoint("/users"),
132
+ * Reader.run(appConfig)
133
+ * ); // "https://api.example.com/users?key=secret"
134
+ * ```
135
+ */
136
+ Reader.run = (env) => (data) => data(env);
137
+ })(Reader || (exports.Reader = Reader = {}));
@@ -15,7 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Arr.js"), exports);
18
+ __exportStar(require("./Lens.js"), exports);
18
19
  __exportStar(require("./Option.js"), exports);
20
+ __exportStar(require("./Reader.js"), exports);
21
+ __exportStar(require("./Optional.js"), exports);
19
22
  __exportStar(require("./Rec.js"), exports);
20
23
  __exportStar(require("./RemoteData.js"), exports);
21
24
  __exportStar(require("./Result.js"), exports);
@@ -0,0 +1,118 @@
1
+ import type { Optional } from "./Optional.js";
2
+ /**
3
+ * Lens<S, A> focuses on a single value A inside a structure S, providing
4
+ * a composable way to read and immutably update nested data.
5
+ *
6
+ * A Lens always succeeds: the focused value is guaranteed to exist.
7
+ * For optional or indexed focuses, use Optional<S, A>.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * type Address = { city: string; zip: string };
12
+ * type User = { name: string; address: Address };
13
+ *
14
+ * const addressLens = Lens.prop<User>()("address");
15
+ * const cityLens = Lens.prop<Address>()("city");
16
+ * const userCityLens = pipe(addressLens, Lens.andThen(cityLens));
17
+ *
18
+ * pipe(user, Lens.get(userCityLens)); // "Berlin"
19
+ * pipe(user, Lens.set(userCityLens)("Hamburg")); // new User with city updated
20
+ * pipe(user, Lens.modify(userCityLens)(c => c.toUpperCase())); // "BERLIN"
21
+ * ```
22
+ */
23
+ export type Lens<S, A> = {
24
+ readonly get: (s: S) => A;
25
+ readonly set: (a: A) => (s: S) => S;
26
+ };
27
+ export declare namespace Lens {
28
+ /**
29
+ * Constructs a Lens from a getter and a setter.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const nameLens = Lens.make(
34
+ * (user: User) => user.name,
35
+ * (name) => (user) => ({ ...user, name }),
36
+ * );
37
+ * ```
38
+ */
39
+ const make: <S, A>(get: (s: S) => A, set: (a: A) => (s: S) => S) => Lens<S, A>;
40
+ /**
41
+ * Creates a Lens that focuses on a property of an object.
42
+ * Call with the structure type first, then the key.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const nameLens = Lens.prop<User>()("name");
47
+ * ```
48
+ */
49
+ const prop: <S>() => <K extends keyof S>(key: K) => Lens<S, S[K]>;
50
+ /**
51
+ * Reads the focused value from a structure.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * pipe(user, Lens.get(nameLens)); // "Alice"
56
+ * ```
57
+ */
58
+ const get: <S, A>(lens: Lens<S, A>) => (s: S) => A;
59
+ /**
60
+ * Replaces the focused value within a structure, returning a new structure.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * pipe(user, Lens.set(nameLens)("Bob")); // new User with name "Bob"
65
+ * ```
66
+ */
67
+ const set: <S, A>(lens: Lens<S, A>) => (a: A) => (s: S) => S;
68
+ /**
69
+ * Applies a function to the focused value, returning a new structure.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * pipe(user, Lens.modify(nameLens)(n => n.toUpperCase())); // "ALICE"
74
+ * ```
75
+ */
76
+ const modify: <S, A>(lens: Lens<S, A>) => (f: (a: A) => A) => (s: S) => S;
77
+ /**
78
+ * Composes two Lenses: focuses through the outer, then through the inner.
79
+ * Use in a pipe chain to build up a deep focus step by step.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * const userCityLens = pipe(
84
+ * Lens.prop<User>()("address"),
85
+ * Lens.andThen(Lens.prop<Address>()("city")),
86
+ * );
87
+ * ```
88
+ */
89
+ const andThen: <A, B>(inner: Lens<A, B>) => <S>(outer: Lens<S, A>) => Lens<S, B>;
90
+ /**
91
+ * Composes a Lens with an Optional, producing an Optional.
92
+ * Use when the next step in the focus is optional (may be absent).
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const userBioOpt = pipe(
97
+ * Lens.prop<User>()("profile"),
98
+ * Lens.andThenOptional(Optional.prop<Profile>()("bio")),
99
+ * );
100
+ * ```
101
+ */
102
+ const andThenOptional: <A, B>(inner: Optional<A, B>) => <S>(outer: Lens<S, A>) => Optional<S, B>;
103
+ /**
104
+ * Converts a Lens to an Optional. Every Lens is a valid Optional
105
+ * whose get always returns Some.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * pipe(
110
+ * Lens.prop<User>()("address"),
111
+ * Lens.toOptional,
112
+ * Optional.andThen(Optional.prop<Address>()("landmark")),
113
+ * );
114
+ * ```
115
+ */
116
+ const toOptional: <S, A>(lens: Lens<S, A>) => Optional<S, A>;
117
+ }
118
+ //# sourceMappingURL=Lens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Lens.d.ts","sourceRoot":"","sources":["../../../src/src/Core/Lens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI;IACvB,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,MAAM,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAIlF,CAAC;IAEJ;;;;;;;;;;;OAWG;IACI,MAAM,eAAe,GACzB,CAAC,EAAE,CAAC,EAAE,OAAO,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAGpE,CAAC;IAEL;;;;;;;;;;;;OAYG;IACI,MAAM,UAAU,GAAI,CAAC,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAG/D,CAAC;CACJ"}
@@ -0,0 +1,158 @@
1
+ import { Option } from "./Option.js";
2
+ import type { Lens } from "./Lens.js";
3
+ /** Keys of T for which undefined is assignable (i.e. optional fields). */
4
+ type OptionalKeys<T> = {
5
+ [K in keyof T]-?: undefined extends T[K] ? K : never;
6
+ }[keyof T];
7
+ /**
8
+ * Optional<S, A> focuses on a value A inside a structure S that may or may
9
+ * not be present. Like a Lens, but get returns Option<A>.
10
+ *
11
+ * Compose with other Optionals via `andThen`, or with a Lens via `andThenLens`.
12
+ * Convert a Lens to an Optional with `Lens.toOptional`.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * type Profile = { username: string; bio?: string };
17
+ *
18
+ * const bioOpt = Optional.prop<Profile>()("bio");
19
+ *
20
+ * pipe(profile, Optional.get(bioOpt)); // Some("hello") or None
21
+ * pipe(profile, Optional.set(bioOpt)("hello")); // new Profile with bio set
22
+ * pipe(profile, Optional.modify(bioOpt)(s => s + "!")); // appends if present
23
+ * ```
24
+ */
25
+ export type Optional<S, A> = {
26
+ readonly get: (s: S) => Option<A>;
27
+ readonly set: (a: A) => (s: S) => S;
28
+ };
29
+ export declare namespace Optional {
30
+ /**
31
+ * Constructs an Optional from a getter (returning Option<A>) and a setter.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const firstChar = Optional.make(
36
+ * (s: string) => s.length > 0 ? Option.some(s[0]) : Option.none(),
37
+ * (c) => (s) => s.length > 0 ? c + s.slice(1) : s,
38
+ * );
39
+ * ```
40
+ */
41
+ const make: <S, A>(get: (s: S) => Option<A>, set: (a: A) => (s: S) => S) => Optional<S, A>;
42
+ /**
43
+ * Creates an Optional that focuses on an optional property of an object.
44
+ * Only keys whose type includes undefined (i.e. `field?: T`) are accepted.
45
+ * Call with the structure type first, then the key.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * type Profile = { username: string; bio?: string };
50
+ * const bioOpt = Optional.prop<Profile>()("bio");
51
+ * ```
52
+ */
53
+ const prop: <S>() => <K extends OptionalKeys<S>>(key: K) => Optional<S, NonNullable<S[K]>>;
54
+ /**
55
+ * Creates an Optional that focuses on an element at a given index in an array.
56
+ * Returns None when the index is out of bounds; set is a no-op when out of bounds.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const firstItem = Optional.index<string>(0);
61
+ *
62
+ * pipe(["a", "b"], Optional.get(firstItem)); // Some("a")
63
+ * pipe([], Optional.get(firstItem)); // None
64
+ * ```
65
+ */
66
+ const index: <A>(i: number) => Optional<A[], A>;
67
+ /**
68
+ * Reads the focused value from a structure, returning Option<A>.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * pipe(profile, Optional.get(bioOpt)); // Some("...") or None
73
+ * ```
74
+ */
75
+ const get: <S, A>(opt: Optional<S, A>) => (s: S) => Option<A>;
76
+ /**
77
+ * Replaces the focused value within a structure.
78
+ * For indexed focuses, this is a no-op when the index is out of bounds.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * pipe(profile, Optional.set(bioOpt)("hello"));
83
+ * ```
84
+ */
85
+ const set: <S, A>(opt: Optional<S, A>) => (a: A) => (s: S) => S;
86
+ /**
87
+ * Applies a function to the focused value if it is present; returns the
88
+ * structure unchanged if the focus is absent.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * pipe(profile, Optional.modify(bioOpt)(s => s.toUpperCase()));
93
+ * ```
94
+ */
95
+ const modify: <S, A>(opt: Optional<S, A>) => (f: (a: A) => A) => (s: S) => S;
96
+ /**
97
+ * Returns the focused value or a default when the focus is absent.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * pipe(profile, Optional.getOrElse(bioOpt)("no bio"));
102
+ * ```
103
+ */
104
+ const getOrElse: <S, A>(opt: Optional<S, A>) => (defaultValue: A) => (s: S) => A;
105
+ /**
106
+ * Extracts a value from an Optional focus using handlers for the present
107
+ * and absent cases.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * pipe(profile, Optional.fold(bioOpt)(() => "no bio", (bio) => bio.toUpperCase()));
112
+ * ```
113
+ */
114
+ const fold: <S, A>(opt: Optional<S, A>) => <B>(onNone: () => B, onSome: (a: A) => B) => (s: S) => B;
115
+ /**
116
+ * Pattern matches on an Optional focus using a named-case object.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * pipe(
121
+ * profile,
122
+ * Optional.match(bioOpt)({ none: () => "no bio", some: (bio) => bio }),
123
+ * );
124
+ * ```
125
+ */
126
+ const match: <S, A>(opt: Optional<S, A>) => <B>(cases: {
127
+ none: () => B;
128
+ some: (a: A) => B;
129
+ }) => (s: S) => B;
130
+ /**
131
+ * Composes two Optionals: focuses through the outer, then through the inner.
132
+ * Returns None if either focus is absent.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * const deepOpt = pipe(
137
+ * Optional.prop<User>()("address"),
138
+ * Optional.andThen(Optional.prop<Address>()("landmark")),
139
+ * );
140
+ * ```
141
+ */
142
+ const andThen: <A, B>(inner: Optional<A, B>) => <S>(outer: Optional<S, A>) => Optional<S, B>;
143
+ /**
144
+ * Composes an Optional with a Lens, producing an Optional.
145
+ * The Lens focuses within the value found by the Optional.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * const cityOpt = pipe(
150
+ * Optional.prop<User>()("address"),
151
+ * Optional.andThenLens(Lens.prop<Address>()("city")),
152
+ * );
153
+ * ```
154
+ */
155
+ const andThenLens: <A, B>(inner: Lens<A, B>) => <S>(outer: Optional<S, A>) => Optional<S, B>;
156
+ }
157
+ export {};
158
+ //# sourceMappingURL=Optional.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Optional.d.ts","sourceRoot":"","sources":["../../../src/src/Core/Optional.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,0EAA0E;AAC1E,KAAK,YAAY,CAAC,CAAC,IAAI;KACpB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CACrD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI;IAC3B,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;CACrC,CAAC;AAEF,yBAAiB,QAAQ,CAAC;IACxB;;;;;;;;;;OAUG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,EACvB,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,EACxB,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KACzB,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAmB,CAAC;IAEpC;;;;;;;;;;OAUG;IACI,MAAM,IAAI,GACd,CAAC,QAAQ,CAAC,SAAS,YA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AAE,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,MACzB,CAAC,EAAE,OAAO;QAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;KAAE,MAE7C,GAAG,CAAC,KACH,CAGF,CAAC;IAEJ;;;;;;;;;;;OAWG;IACI,MAAM,OAAO,GACjB,CAAC,EAAE,CAAC,EAAE,OAAO,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAUvE,CAAC;IAEN;;;;;;;;;;;OAWG;IACI,MAAM,WAAW,GACrB,CAAC,EAAE,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAUnE,CAAC;CACP"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * A computation that reads from a shared environment `R` and produces a value `A`.
3
+ * Use Reader to thread a dependency (config, logger, DB pool) through a pipeline
4
+ * without passing it explicitly to every function.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * type Config = { baseUrl: string; apiKey: string };
9
+ *
10
+ * const buildUrl = (path: string): Reader<Config, string> =>
11
+ * (config) => `${config.baseUrl}${path}`;
12
+ *
13
+ * const withAuth = (url: string): Reader<Config, string> =>
14
+ * (config) => `${url}?key=${config.apiKey}`;
15
+ *
16
+ * const fetchEndpoint = (path: string): Reader<Config, string> =>
17
+ * pipe(
18
+ * buildUrl(path),
19
+ * Reader.chain(withAuth)
20
+ * );
21
+ *
22
+ * // Inject the config once at the edge
23
+ * fetchEndpoint("/users")(appConfig); // "https://api.example.com/users?key=secret"
24
+ * ```
25
+ */
26
+ export type Reader<R, A> = (env: R) => A;
27
+ export declare namespace Reader {
28
+ /**
29
+ * Lifts a pure value into a Reader. The environment is ignored.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const always42: Reader<Config, number> = Reader.resolve(42);
34
+ * always42(anyConfig); // 42
35
+ * ```
36
+ */
37
+ const resolve: <R, A>(value: A) => Reader<R, A>;
38
+ /**
39
+ * Returns the full environment as the result.
40
+ * The fundamental way to access the environment in a pipeline.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * pipe(
45
+ * Reader.ask<Config>(),
46
+ * Reader.map(config => config.baseUrl)
47
+ * )(appConfig); // "https://api.example.com"
48
+ * ```
49
+ */
50
+ const ask: <R>() => Reader<R, R>;
51
+ /**
52
+ * Projects a value from the environment using a selector function.
53
+ * Equivalent to `pipe(Reader.ask(), Reader.map(f))` but more direct.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const getBaseUrl: Reader<Config, string> = Reader.asks(c => c.baseUrl);
58
+ * getBaseUrl(appConfig); // "https://api.example.com"
59
+ * ```
60
+ */
61
+ const asks: <R, A>(f: (env: R) => A) => Reader<R, A>;
62
+ /**
63
+ * Transforms the value produced by a Reader.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * pipe(
68
+ * Reader.asks((c: Config) => c.baseUrl),
69
+ * Reader.map(url => url.toUpperCase())
70
+ * )(appConfig); // "HTTPS://API.EXAMPLE.COM"
71
+ * ```
72
+ */
73
+ const map: <R, A, B>(f: (a: A) => B) => (data: Reader<R, A>) => Reader<R, B>;
74
+ /**
75
+ * Sequences two Readers. Both see the same environment.
76
+ * The output of the first is passed to `f`, which returns the next Reader.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * const buildUrl = (path: string): Reader<Config, string> =>
81
+ * Reader.asks(c => `${c.baseUrl}${path}`);
82
+ *
83
+ * const addAuth = (url: string): Reader<Config, string> =>
84
+ * Reader.asks(c => `${url}?key=${c.apiKey}`);
85
+ *
86
+ * pipe(
87
+ * buildUrl("/items"),
88
+ * Reader.chain(addAuth)
89
+ * )(appConfig); // "https://api.example.com/items?key=secret"
90
+ * ```
91
+ */
92
+ const chain: <R, A, B>(f: (a: A) => Reader<R, B>) => (data: Reader<R, A>) => Reader<R, B>;
93
+ /**
94
+ * Applies a function wrapped in a Reader to a value wrapped in a Reader.
95
+ * Both Readers see the same environment.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const add = (a: number) => (b: number) => a + b;
100
+ * pipe(
101
+ * Reader.resolve<Config, typeof add>(add),
102
+ * Reader.ap(Reader.asks(c => c.timeout)),
103
+ * Reader.ap(Reader.resolve(5))
104
+ * )(appConfig);
105
+ * ```
106
+ */
107
+ const ap: <R, A>(arg: Reader<R, A>) => <B>(data: Reader<R, (a: A) => B>) => Reader<R, B>;
108
+ /**
109
+ * Executes a side effect on the produced value without changing the Reader.
110
+ * Useful for logging or debugging inside a pipeline.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * pipe(
115
+ * buildUrl("/users"),
116
+ * Reader.tap(url => console.log("Requesting:", url)),
117
+ * Reader.chain(addAuth)
118
+ * )(appConfig);
119
+ * ```
120
+ */
121
+ const tap: <R, A>(f: (a: A) => void) => (data: Reader<R, A>) => Reader<R, A>;
122
+ /**
123
+ * Adapts a Reader to work with a different (typically wider) environment
124
+ * by transforming the environment before passing it to the Reader.
125
+ * This lets you compose Readers that expect different environments.
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * type AppEnv = { db: DbPool; config: Config; logger: Logger };
130
+ *
131
+ * // buildUrl only needs Config
132
+ * const buildUrl: Reader<Config, string> = Reader.asks(c => c.baseUrl);
133
+ *
134
+ * // Zoom in from AppEnv to Config
135
+ * const buildUrlFromApp: Reader<AppEnv, string> =
136
+ * pipe(buildUrl, Reader.local((env: AppEnv) => env.config));
137
+ *
138
+ * buildUrlFromApp(appEnv); // works with the full AppEnv
139
+ * ```
140
+ */
141
+ const local: <R2, R>(f: (env: R2) => R) => <A>(data: Reader<R, A>) => Reader<R2, A>;
142
+ /**
143
+ * Runs a Reader by supplying the environment. Use this at the edge of your
144
+ * program where the environment is available.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * pipe(
149
+ * buildEndpoint("/users"),
150
+ * Reader.run(appConfig)
151
+ * ); // "https://api.example.com/users?key=secret"
152
+ * ```
153
+ */
154
+ const run: <R>(env: R) => <A>(data: Reader<R, A>) => A;
155
+ }
156
+ //# sourceMappingURL=Reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Reader.d.ts","sourceRoot":"","sources":["../../../src/src/Core/Reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AAEzC,yBAAiB,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACI,MAAM,OAAO,GAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAoB,CAAC;IAEzE;;;;;;;;;;;OAWG;IACI,MAAM,GAAG,GAAI,CAAC,OAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAiB,CAAC;IAEvD;;;;;;;;;OASG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAoB,CAAC;IAE9E;;;;;;;;;;OAUG;IACI,MAAM,GAAG,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CACnE,CAAC;IAEf;;;;;;;;;;;;;;;;;OAiBG;IACI,MAAM,KAAK,GACf,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,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AC,CAAC,EAAE,CAAC,CAAC,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAG9E,CAAC;IAEF;;;;;;;;;;;;OAYG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAIxD,CAAC;CACH"}
@@ -1,5 +1,8 @@
1
1
  export * from "./Arr.js";
2
+ export * from "./Lens.js";
2
3
  export * from "./Option.js";
4
+ export * from "./Reader.js";
5
+ export * from "./Optional.js";
3
6
  export * from "./Rec.js";
4
7
  export * from "./RemoteData.js";
5
8
  export * from "./Result.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}