functype 0.8.69 → 0.8.80
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 +181 -3
- package/dist/{Either-BfXNbTHo.d.ts → Either-CfG7OVB-.d.ts} +20 -20
- package/dist/{Map-vivbm5n0.d.ts → Map-wkGSJvYa.d.ts} +2 -2
- package/dist/{Valuable-CtuVEKTZ.d.ts → Valuable-BI2O7E9Q.d.ts} +1 -1
- package/dist/chunk-7PQA3W7W.mjs.map +1 -1
- package/dist/chunk-JIVKCD74.mjs +42 -0
- package/dist/chunk-JIVKCD74.mjs.map +1 -0
- package/dist/chunk-TQJDL6YW.mjs.map +1 -1
- package/dist/either/index.d.ts +2 -2
- package/dist/either/index.mjs +1 -1
- package/dist/fpromise/index.d.ts +2 -2
- package/dist/fpromise/index.mjs +1 -1
- package/dist/index.d.ts +769 -7
- package/dist/index.mjs +1 -1
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.mjs +1 -1
- package/dist/map/index.d.ts +3 -3
- package/dist/map/index.mjs +1 -1
- package/dist/option/index.d.ts +2 -2
- package/dist/option/index.mjs +1 -1
- package/dist/set/index.d.ts +2 -2
- package/dist/set/index.mjs +1 -1
- package/dist/try/index.d.ts +2 -2
- package/dist/try/index.mjs +1 -1
- package/dist/tuple/index.d.ts +1 -1
- package/package.json +39 -13
- package/readme/TUPLE-EXAMPLES.md +0 -3
- package/readme/task-error-handling.md +0 -1
- package/dist/chunk-5DWCHDSA.mjs +0 -39
- package/dist/chunk-5DWCHDSA.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Brand } from './branded/index.js';
|
|
2
|
+
export { BrandedBoolean, BrandedNumber, BrandedString, ExtractBrand, Unbrand, createBrander, hasBrand, unbrand } from './branded/index.js';
|
|
3
|
+
import { O as Option, E as Either, F as Foldable, L as List, P as Pipe, S as Serializable, M as Matchable, T as Traversable } from './Either-CfG7OVB-.js';
|
|
4
|
+
export { a as Collection, C as Converters, I as IterableType, c as Left, h as MatchableUtils, N as None, k as OptionConstructor, R as Right, l as SerializationMethods, m as Set, j as Some, b as TestEither, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './Either-CfG7OVB-.js';
|
|
5
|
+
import { T as Type, a as Typeable, F as Functor, A as AsyncFunctor, V as Valuable } from './Valuable-BI2O7E9Q.js';
|
|
6
|
+
export { b as AbstractFunctor, c as ArrayFunctor, E as ExtractTag, d as TypeableParams, e as ValuableParams, i as isTypeable } from './Valuable-BI2O7E9Q.js';
|
|
6
7
|
import { FPromise } from './fpromise/index.js';
|
|
7
8
|
export { ErrorContext, FPromiseCompanion } from './fpromise/index.js';
|
|
8
9
|
import { Try } from './try/index.js';
|
|
9
10
|
export { TypeNames } from './try/index.js';
|
|
10
|
-
export { a as ESMap, E as ESMapType, M as Map, S as SafeTraversable } from './Map-
|
|
11
|
+
export { a as ESMap, E as ESMapType, M as Map, S as SafeTraversable } from './Map-wkGSJvYa.js';
|
|
11
12
|
export { Tuple } from './tuple/index.js';
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
* A brand with runtime validation
|
|
16
|
+
* @example
|
|
17
|
+
* const Age = ValidatedBrand("Age", (n: number) => n >= 0 && n <= 150)
|
|
18
|
+
* const myAge = Age.of(25) // Option<Brand<"Age", number>>
|
|
19
|
+
* const invalid = Age.of(-5) // None
|
|
20
|
+
*/
|
|
21
|
+
type ValidatedBrand<K extends string, T> = {
|
|
22
|
+
readonly brand: K;
|
|
23
|
+
readonly validate: (value: T) => boolean;
|
|
24
|
+
readonly of: (value: T) => Option<Brand<K, T>>;
|
|
25
|
+
readonly from: (value: T) => Either<string, Brand<K, T>>;
|
|
26
|
+
readonly unsafeOf: (value: T) => Brand<K, T>;
|
|
27
|
+
readonly is: (value: unknown) => value is Brand<K, T>;
|
|
28
|
+
readonly refine: <K2 extends string>(brand: K2, validate: (value: Brand<K, T>) => boolean) => ValidatedBrand<K2, Brand<K, T>>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Create a validated brand with runtime validation
|
|
32
|
+
* @example
|
|
33
|
+
* const Email = ValidatedBrand("Email", (s: string) => /^[^@]+@[^@]+\.[^@]+$/.test(s))
|
|
34
|
+
* const email = Email.of("user@example.com") // Some(Brand<"Email", string>)
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // With Either for error messages
|
|
38
|
+
* const Port = ValidatedBrand("Port", (n: number) => n >= 1 && n <= 65535)
|
|
39
|
+
* const result = Port.from(8080) // Right(Brand<"Port", number>)
|
|
40
|
+
* const error = Port.from(70000) // Left("Invalid Port: validation failed")
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Type guard usage
|
|
44
|
+
* const value: unknown = "test@example.com"
|
|
45
|
+
* if (Email.is(value)) {
|
|
46
|
+
* // value is Brand<"Email", string>
|
|
47
|
+
* }
|
|
48
|
+
*/
|
|
49
|
+
declare function ValidatedBrand<K extends string, T>(brand: K, validate: (value: T) => boolean): ValidatedBrand<K, T>;
|
|
50
|
+
/**
|
|
51
|
+
* Positive number brand (> 0)
|
|
52
|
+
* @example
|
|
53
|
+
* const price = PositiveNumber.of(19.99) // Some(Brand<"PositiveNumber", number>)
|
|
54
|
+
* const invalid = PositiveNumber.of(-5) // None
|
|
55
|
+
* const checked = PositiveNumber.from(0) // Left("Invalid PositiveNumber: validation failed")
|
|
56
|
+
*/
|
|
57
|
+
declare const PositiveNumber: ValidatedBrand<"PositiveNumber", number>;
|
|
58
|
+
declare const NonNegativeNumber: ValidatedBrand<"NonNegativeNumber", number>;
|
|
59
|
+
declare const IntegerNumber: ValidatedBrand<"IntegerNumber", number>;
|
|
60
|
+
declare const PositiveInteger: ValidatedBrand<"PositiveInteger", Brand<"PositiveNumber", number>>;
|
|
61
|
+
/**
|
|
62
|
+
* Non-empty string brand
|
|
63
|
+
* @example
|
|
64
|
+
* const name = NonEmptyString.of("John") // Some(Brand<"NonEmptyString", string>)
|
|
65
|
+
* const empty = NonEmptyString.of("") // None
|
|
66
|
+
*/
|
|
67
|
+
declare const NonEmptyString: ValidatedBrand<"NonEmptyString", string>;
|
|
68
|
+
/**
|
|
69
|
+
* Email address brand with basic validation
|
|
70
|
+
* @example
|
|
71
|
+
* const email = EmailAddress.of("user@example.com") // Some(Brand<"EmailAddress", string>)
|
|
72
|
+
* const invalid = EmailAddress.of("not-an-email") // None
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // Using with forms
|
|
76
|
+
* const processEmail = (input: string) => {
|
|
77
|
+
* return EmailAddress.from(input)
|
|
78
|
+
* .map(email => sendWelcomeEmail(email))
|
|
79
|
+
* .getOrElse("Invalid email address")
|
|
80
|
+
* }
|
|
81
|
+
*/
|
|
82
|
+
declare const EmailAddress: ValidatedBrand<"EmailAddress", string>;
|
|
83
|
+
declare const UrlString: ValidatedBrand<"UrlString", string>;
|
|
84
|
+
declare const UUID: ValidatedBrand<"UUID", string>;
|
|
85
|
+
declare const ISO8601Date: ValidatedBrand<"ISO8601Date", string>;
|
|
86
|
+
/**
|
|
87
|
+
* Create a number brand with min/max bounds
|
|
88
|
+
* @example
|
|
89
|
+
* const Percentage = BoundedNumber("Percentage", 0, 100)
|
|
90
|
+
* const valid = Percentage.of(75) // Some(Brand<"Percentage", number>)
|
|
91
|
+
* const invalid = Percentage.of(150) // None
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const Port = BoundedNumber("Port", 1, 65535)
|
|
95
|
+
* const httpPort = Port.unsafeOf(80) // Brand<"Port", number>
|
|
96
|
+
* // Port.unsafeOf(70000) // throws Error
|
|
97
|
+
*/
|
|
98
|
+
declare function BoundedNumber(brand: string, min: number, max: number): ValidatedBrand<string, number>;
|
|
99
|
+
/**
|
|
100
|
+
* Create a string brand with length constraints
|
|
101
|
+
* @example
|
|
102
|
+
* const Username = BoundedString("Username", 3, 20)
|
|
103
|
+
* const valid = Username.of("johndoe") // Some(Brand<"Username", string>)
|
|
104
|
+
* const tooShort = Username.of("jo") // None
|
|
105
|
+
* const tooLong = Username.of("verylongusernamethatexceedslimit") // None
|
|
106
|
+
*/
|
|
107
|
+
declare function BoundedString(brand: string, minLength: number, maxLength: number): ValidatedBrand<string, string>;
|
|
108
|
+
/**
|
|
109
|
+
* Create a string brand that matches a regex pattern
|
|
110
|
+
* @example
|
|
111
|
+
* const HexColor = PatternString("HexColor", /^#[0-9a-f]{6}$/i)
|
|
112
|
+
* const red = HexColor.of("#ff0000") // Some(Brand<"HexColor", string>)
|
|
113
|
+
* const invalid = HexColor.of("red") // None
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const PhoneNumber = PatternString("PhoneNumber", /^\+?[1-9]\d{1,14}$/)
|
|
117
|
+
* const phone = PhoneNumber.from("+1234567890")
|
|
118
|
+
* .map(p => formatPhoneNumber(p))
|
|
119
|
+
* .getOrElse("Invalid phone number")
|
|
120
|
+
*/
|
|
121
|
+
declare function PatternString(brand: string, pattern: RegExp): ValidatedBrand<string, string>;
|
|
122
|
+
|
|
13
123
|
/**
|
|
14
124
|
* Creates a function-object hybrid similar to Scala's companion objects.
|
|
15
125
|
* This utility allows creating TypeScript function objects with attached methods,
|
|
@@ -34,6 +144,280 @@ export { Tuple } from './tuple/index.js';
|
|
|
34
144
|
*/
|
|
35
145
|
declare function Companion<ObjectF extends object, CompanionF extends object>(object: ObjectF, companion: CompanionF): ObjectF & CompanionF;
|
|
36
146
|
|
|
147
|
+
type LazyCondChain<T> = {
|
|
148
|
+
when: (condition: () => boolean, value: () => T) => LazyCondChain<T>;
|
|
149
|
+
elseWhen: (condition: () => boolean, value: () => T) => LazyCondChain<T>;
|
|
150
|
+
else: (value: () => T) => T;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Conditional expression that enforces exhaustive returns without early returns.
|
|
154
|
+
* Similar to Scala's if/else expressions that always return a value.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* const discount = Cond.of<number>()
|
|
158
|
+
* .when(isPremiumMember, 0.2)
|
|
159
|
+
* .elseWhen(isRegularMember, 0.1)
|
|
160
|
+
* .else(0)
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* // Chaining multiple conditions
|
|
164
|
+
* const status = Cond.of<string>()
|
|
165
|
+
* .when(response.status >= 500, "Server Error")
|
|
166
|
+
* .elseWhen(response.status >= 400, "Client Error")
|
|
167
|
+
* .elseWhen(response.status >= 200, "Success")
|
|
168
|
+
* .else("Unknown")
|
|
169
|
+
*/
|
|
170
|
+
type Cond<T extends Type> = {
|
|
171
|
+
/**
|
|
172
|
+
* Add an if condition
|
|
173
|
+
*/
|
|
174
|
+
when: (condition: boolean, value: T | (() => T)) => Cond<T>;
|
|
175
|
+
/**
|
|
176
|
+
* Add an else-if condition
|
|
177
|
+
*/
|
|
178
|
+
elseWhen: (condition: boolean, value: T | (() => T)) => Cond<T>;
|
|
179
|
+
/**
|
|
180
|
+
* Terminal else clause - required to get the result
|
|
181
|
+
*/
|
|
182
|
+
else: (value: T | (() => T)) => T;
|
|
183
|
+
/**
|
|
184
|
+
* Get the result if a condition was met, throws if no condition met
|
|
185
|
+
*/
|
|
186
|
+
getOrThrow: () => T;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Conditional expression builder for functional if/else chains
|
|
190
|
+
* @example
|
|
191
|
+
* // Basic usage
|
|
192
|
+
* const size = Cond.of<string>()
|
|
193
|
+
* .when(value > 100, "large")
|
|
194
|
+
* .elseWhen(value > 50, "medium")
|
|
195
|
+
* .else("small")
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* // Pattern matching
|
|
199
|
+
* const message = Cond.match(errorCode)({
|
|
200
|
+
* 404: "Not Found",
|
|
201
|
+
* 500: "Server Error",
|
|
202
|
+
* 200: "OK"
|
|
203
|
+
* })
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* // Lazy evaluation
|
|
207
|
+
* const result = Cond.lazy<string>()
|
|
208
|
+
* .when(() => checkCondition1(), () => "Result 1")
|
|
209
|
+
* .when(() => checkCondition2(), () => "Result 2")
|
|
210
|
+
* .else(() => "Default")
|
|
211
|
+
*/
|
|
212
|
+
declare const Cond: (<T extends Type>() => Cond<T>) & {
|
|
213
|
+
/**
|
|
214
|
+
* Create a conditional expression that must end with else
|
|
215
|
+
* @example
|
|
216
|
+
* const x = 7
|
|
217
|
+
* const result = Cond.of<string>()
|
|
218
|
+
* .when(x > 10, "large")
|
|
219
|
+
* .elseWhen(x > 5, "medium")
|
|
220
|
+
* .else("small")
|
|
221
|
+
* // result = "medium"
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* // With lazy evaluation
|
|
225
|
+
* const discount = Cond.of<number>()
|
|
226
|
+
* .when(isPremium, () => calculatePremiumDiscount())
|
|
227
|
+
* .when(isLoyal, () => calculateLoyaltyDiscount())
|
|
228
|
+
* .else(0)
|
|
229
|
+
*/
|
|
230
|
+
of: <T extends Type>() => Cond<T>;
|
|
231
|
+
/**
|
|
232
|
+
* Pattern matching helper that ensures exhaustiveness
|
|
233
|
+
* @example
|
|
234
|
+
* type Status = "pending" | "success" | "error"
|
|
235
|
+
* const status: Status = "success"
|
|
236
|
+
* const result = Cond.match(status)({
|
|
237
|
+
* "pending": "Waiting...",
|
|
238
|
+
* "success": "Done!",
|
|
239
|
+
* "error": "Failed!"
|
|
240
|
+
* })
|
|
241
|
+
* // result = "Done!"
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* // With function values
|
|
245
|
+
* const action = "compute"
|
|
246
|
+
* const result = Cond.match(action)({
|
|
247
|
+
* "compute": () => expensiveComputation(),
|
|
248
|
+
* "cache": () => getCachedValue(),
|
|
249
|
+
* "skip": () => defaultValue
|
|
250
|
+
* })
|
|
251
|
+
*/
|
|
252
|
+
match: <T extends string | number | symbol>(value: T) => <R extends Type>(cases: Record<T, R | (() => R)>) => R;
|
|
253
|
+
/**
|
|
254
|
+
* Create a lazy conditional that defers evaluation
|
|
255
|
+
* @example
|
|
256
|
+
* // Only evaluates conditions and values when needed
|
|
257
|
+
* const getMessage = Cond.lazy<string>()
|
|
258
|
+
* .when(() => isError(), () => computeErrorMessage())
|
|
259
|
+
* .when(() => isWarning(), () => computeWarningMessage())
|
|
260
|
+
* .else(() => "Success")
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* // Complex conditional with expensive checks
|
|
264
|
+
* const result = Cond.lazy<Action>()
|
|
265
|
+
* .when(
|
|
266
|
+
* () => user.role === "admin" && checkAdminPermissions(),
|
|
267
|
+
* () => ({ type: "admin", permissions: loadAdminPermissions() })
|
|
268
|
+
* )
|
|
269
|
+
* .when(
|
|
270
|
+
* () => user.role === "user" && user.isActive,
|
|
271
|
+
* () => ({ type: "user", permissions: loadUserPermissions() })
|
|
272
|
+
* )
|
|
273
|
+
* .else(() => ({ type: "guest", permissions: [] }))
|
|
274
|
+
*/
|
|
275
|
+
lazy: <T extends Type>() => LazyCondChain<T>;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Pattern matching construct similar to Scala's match expressions.
|
|
280
|
+
* Enforces exhaustive matching and returns values.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* const result = Match(value)
|
|
284
|
+
* .case(x => x > 100, "large")
|
|
285
|
+
* .case(x => x > 50, "medium")
|
|
286
|
+
* .default("small")
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* // Matching exact values
|
|
290
|
+
* const message = Match(status)
|
|
291
|
+
* .caseValue("pending", "Please wait...")
|
|
292
|
+
* .caseValue("success", "Completed!")
|
|
293
|
+
* .caseValue("error", "Failed")
|
|
294
|
+
* .default("Unknown")
|
|
295
|
+
*/
|
|
296
|
+
type Match<T extends Type, R extends Type> = {
|
|
297
|
+
/**
|
|
298
|
+
* Add a case with a predicate
|
|
299
|
+
*/
|
|
300
|
+
case: (predicate: (value: T) => boolean, result: R | ((value: T) => R)) => Match<T, R>;
|
|
301
|
+
/**
|
|
302
|
+
* Add a case that matches a specific value
|
|
303
|
+
*/
|
|
304
|
+
caseValue: (match: T, result: R | (() => R)) => Match<T, R>;
|
|
305
|
+
/**
|
|
306
|
+
* Add a case that matches multiple values
|
|
307
|
+
*/
|
|
308
|
+
caseValues: (matches: T[], result: R | (() => R)) => Match<T, R>;
|
|
309
|
+
/**
|
|
310
|
+
* Default case - required to get result
|
|
311
|
+
*/
|
|
312
|
+
default: (result: R | ((value: T) => R)) => R;
|
|
313
|
+
/**
|
|
314
|
+
* Get result if a case matched, throws if no match
|
|
315
|
+
*/
|
|
316
|
+
getOrThrow: () => R;
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Pattern matching utility for type-safe conditional logic
|
|
320
|
+
* @example
|
|
321
|
+
* // Basic pattern matching
|
|
322
|
+
* const result = Match(value)
|
|
323
|
+
* .case(x => x > 0, "positive")
|
|
324
|
+
* .case(x => x < 0, "negative")
|
|
325
|
+
* .default("zero")
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* // Exhaustive matching for union types
|
|
329
|
+
* type Color = "red" | "green" | "blue"
|
|
330
|
+
* const hex = Match.exhaustive<Color, string>({
|
|
331
|
+
* red: "#FF0000",
|
|
332
|
+
* green: "#00FF00",
|
|
333
|
+
* blue: "#0000FF"
|
|
334
|
+
* })(color)
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* // Partial matching with default
|
|
338
|
+
* const name = Match.partial<number, string>({
|
|
339
|
+
* 1: "one",
|
|
340
|
+
* 2: "two",
|
|
341
|
+
* 3: "three"
|
|
342
|
+
* }).withDefault(n => `number ${n}`)(value)
|
|
343
|
+
*/
|
|
344
|
+
declare const Match: (<T extends Type, R extends Type>(value: T) => Match<T, R>) & {
|
|
345
|
+
/**
|
|
346
|
+
* Create a type-safe exhaustive match for union types
|
|
347
|
+
* @example
|
|
348
|
+
* type Status = "pending" | "success" | "error"
|
|
349
|
+
* const status: Status = "success"
|
|
350
|
+
* const result = Match.exhaustive<Status, string>({
|
|
351
|
+
* pending: "Waiting...",
|
|
352
|
+
* success: "Done!",
|
|
353
|
+
* error: "Failed!"
|
|
354
|
+
* })(status)
|
|
355
|
+
* // result = "Done!"
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* // For function values, wrap in object to prevent execution
|
|
359
|
+
* type Operation = "add" | "subtract" | "multiply"
|
|
360
|
+
* const ops = Match.exhaustive<Operation, { fn: (a: number, b: number) => number }>({
|
|
361
|
+
* add: { fn: (a, b) => a + b },
|
|
362
|
+
* subtract: { fn: (a, b) => a - b },
|
|
363
|
+
* multiply: { fn: (a, b) => a * b }
|
|
364
|
+
* })
|
|
365
|
+
* const compute = ops("multiply").fn
|
|
366
|
+
* const result = compute(4, 5) // 20
|
|
367
|
+
*/
|
|
368
|
+
exhaustive: <T extends string | number | symbol, R extends Type>(cases: Record<T, R>) => (value: T) => R;
|
|
369
|
+
/**
|
|
370
|
+
* Create a partial match that requires a default
|
|
371
|
+
* @example
|
|
372
|
+
* const httpCode = 404
|
|
373
|
+
* const message = Match.partial<number, string>({
|
|
374
|
+
* 200: "OK",
|
|
375
|
+
* 201: "Created",
|
|
376
|
+
* 404: "Not Found",
|
|
377
|
+
* 500: "Server Error"
|
|
378
|
+
* }).withDefault("Unknown Status")(httpCode)
|
|
379
|
+
* // message = "Not Found"
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* // With function default
|
|
383
|
+
* const getMessage = Match.partial<number, string>({
|
|
384
|
+
* 0: "Zero",
|
|
385
|
+
* 1: "One",
|
|
386
|
+
* 2: "Two"
|
|
387
|
+
* }).withDefault((n) => `Number: ${n}`)
|
|
388
|
+
* getMessage(5) // "Number: 5"
|
|
389
|
+
*/
|
|
390
|
+
partial: <T extends string | number | symbol, R extends Type>(cases: Partial<Record<T, R | ((value: T) => R)>>) => {
|
|
391
|
+
withDefault: (defaultValue: R | ((value: T) => R)) => (value: T) => R;
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* Pattern match with guards
|
|
395
|
+
* @example
|
|
396
|
+
* const score = 85
|
|
397
|
+
* const grade = Match.withGuards<number, string>([
|
|
398
|
+
* [n => n >= 90, "A"],
|
|
399
|
+
* [n => n >= 80, "B"],
|
|
400
|
+
* [n => n >= 70, "C"],
|
|
401
|
+
* [n => n >= 60, "D"]
|
|
402
|
+
* ]).withDefault("F")(score)
|
|
403
|
+
* // grade = "B"
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* // With function results for custom messages
|
|
407
|
+
* const age = 25
|
|
408
|
+
* const category = Match.withGuards<number, string>([
|
|
409
|
+
* [n => n < 13, n => `Child (${n} years)`],
|
|
410
|
+
* [n => n < 20, n => `Teenager (${n} years)`],
|
|
411
|
+
* [n => n < 60, n => `Adult (${n} years)`],
|
|
412
|
+
* [n => n >= 60, n => `Senior (${n} years)`]
|
|
413
|
+
* ]).withDefault("Unknown")(age)
|
|
414
|
+
* // category = "Adult (25 years)"
|
|
415
|
+
*/
|
|
416
|
+
withGuards: <T extends Type, R extends Type>(guards: Array<[(value: T) => boolean, R | ((value: T) => R)]>) => {
|
|
417
|
+
withDefault: (defaultValue: R | ((value: T) => R)) => (value: T) => R;
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
|
|
37
421
|
/**
|
|
38
422
|
* Base Object from which most other objects inherit
|
|
39
423
|
* @param type - The type name for the object
|
|
@@ -441,6 +825,384 @@ type Identity<T> = {
|
|
|
441
825
|
};
|
|
442
826
|
declare function Identity<T>(value: T): Identity<T>;
|
|
443
827
|
|
|
828
|
+
/**
|
|
829
|
+
* Lazy type module
|
|
830
|
+
* @module Lazy
|
|
831
|
+
* @category Core
|
|
832
|
+
*/
|
|
833
|
+
/**
|
|
834
|
+
* The Lazy type represents a computation that is deferred until needed.
|
|
835
|
+
* It provides memoization and safe evaluation with integration to Option, Either, and Try.
|
|
836
|
+
* @typeParam T - The type of the value to be computed
|
|
837
|
+
*/
|
|
838
|
+
type Lazy<T extends Type> = {
|
|
839
|
+
/** Tag identifying this as a Lazy type */
|
|
840
|
+
readonly _tag: "Lazy";
|
|
841
|
+
/** Whether the computation has been evaluated */
|
|
842
|
+
readonly isEvaluated: boolean;
|
|
843
|
+
/**
|
|
844
|
+
* Forces evaluation of the lazy value and returns the result.
|
|
845
|
+
* The result is memoized after first evaluation.
|
|
846
|
+
* @returns The computed value
|
|
847
|
+
* @throws Any error thrown by the computation
|
|
848
|
+
*/
|
|
849
|
+
get(): T;
|
|
850
|
+
/**
|
|
851
|
+
* Returns the computed value or a default value if computation fails
|
|
852
|
+
* @param defaultValue - The value to return if computation fails
|
|
853
|
+
* @returns The computed value or defaultValue
|
|
854
|
+
*/
|
|
855
|
+
getOrElse(defaultValue: T): T;
|
|
856
|
+
/**
|
|
857
|
+
* Returns the computed value or null if computation fails
|
|
858
|
+
* @returns The computed value or null
|
|
859
|
+
*/
|
|
860
|
+
getOrNull(): T | null;
|
|
861
|
+
/**
|
|
862
|
+
* Returns the computed value or throws a specified error if computation fails
|
|
863
|
+
* @param error - The error to throw if computation fails
|
|
864
|
+
* @returns The computed value
|
|
865
|
+
* @throws The specified error if computation fails
|
|
866
|
+
*/
|
|
867
|
+
getOrThrow(error: Error): T;
|
|
868
|
+
/**
|
|
869
|
+
* Maps the value inside the Lazy using the provided function
|
|
870
|
+
* @param f - The mapping function
|
|
871
|
+
* @returns A new Lazy containing the mapped value
|
|
872
|
+
*/
|
|
873
|
+
map<U extends Type>(f: (value: T) => U): Lazy<U>;
|
|
874
|
+
/**
|
|
875
|
+
* Maps the value inside the Lazy using an async function
|
|
876
|
+
* @param f - The async mapping function
|
|
877
|
+
* @returns A Promise of a new Lazy containing the mapped value
|
|
878
|
+
*/
|
|
879
|
+
mapAsync<U extends Type>(f: (value: T) => Promise<U>): Promise<Lazy<U>>;
|
|
880
|
+
/**
|
|
881
|
+
* Maps the value using a function that returns a Lazy
|
|
882
|
+
* @param f - The mapping function returning a Lazy
|
|
883
|
+
* @returns A new Lazy containing the flattened result
|
|
884
|
+
*/
|
|
885
|
+
flatMap<U extends Type>(f: (value: T) => Lazy<U>): Lazy<U>;
|
|
886
|
+
/**
|
|
887
|
+
* Maps the value using an async function that returns a Lazy
|
|
888
|
+
* @param f - The async mapping function returning a Lazy
|
|
889
|
+
* @returns A Promise of a new Lazy containing the flattened result
|
|
890
|
+
*/
|
|
891
|
+
flatMapAsync<U extends Type>(f: (value: T) => Promise<Lazy<U>>): Promise<Lazy<U>>;
|
|
892
|
+
/**
|
|
893
|
+
* Returns a Lazy that filters the value based on a predicate
|
|
894
|
+
* @param predicate - The predicate function
|
|
895
|
+
* @returns A Lazy containing an Option of the value
|
|
896
|
+
*/
|
|
897
|
+
filter(predicate: (value: T) => boolean): Lazy<Option<T>>;
|
|
898
|
+
/**
|
|
899
|
+
* Recovers from a failed computation by providing an alternative value
|
|
900
|
+
* @param f - Function that takes the error and returns a recovery value
|
|
901
|
+
* @returns A new Lazy that will use the recovery function if computation fails
|
|
902
|
+
*/
|
|
903
|
+
recover(f: (error: unknown) => T): Lazy<T>;
|
|
904
|
+
/**
|
|
905
|
+
* Recovers from a failed computation by providing an alternative Lazy
|
|
906
|
+
* @param f - Function that takes the error and returns a recovery Lazy
|
|
907
|
+
* @returns A new Lazy that will use the recovery Lazy if computation fails
|
|
908
|
+
*/
|
|
909
|
+
recoverWith(f: (error: unknown) => Lazy<T>): Lazy<T>;
|
|
910
|
+
/**
|
|
911
|
+
* Evaluates the computation and returns it as an Option
|
|
912
|
+
* @returns Some containing the value if successful, None if computation fails
|
|
913
|
+
*/
|
|
914
|
+
toOption(): Option<T>;
|
|
915
|
+
/**
|
|
916
|
+
* Evaluates the computation and returns it as an Either
|
|
917
|
+
* @returns Right containing the value if successful, Left containing the error if computation fails
|
|
918
|
+
*/
|
|
919
|
+
toEither(): Either<unknown, T>;
|
|
920
|
+
/**
|
|
921
|
+
* Evaluates the computation and returns it as an Either with a mapped error
|
|
922
|
+
* @param mapError - Function to map the error
|
|
923
|
+
* @returns Right containing the value if successful, Left containing the mapped error if computation fails
|
|
924
|
+
*/
|
|
925
|
+
toEitherWith<E>(mapError: (error: unknown) => E): Either<E, T>;
|
|
926
|
+
/**
|
|
927
|
+
* Evaluates the computation and returns it as a Try
|
|
928
|
+
* @returns Try containing the result of the computation
|
|
929
|
+
*/
|
|
930
|
+
toTry(): Try<T>;
|
|
931
|
+
/**
|
|
932
|
+
* Applies an effect function to the value if computation succeeds
|
|
933
|
+
* @param f - The effect function
|
|
934
|
+
* @returns This Lazy for chaining
|
|
935
|
+
*/
|
|
936
|
+
tap(f: (value: T) => void): Lazy<T>;
|
|
937
|
+
/**
|
|
938
|
+
* Applies an effect function to the error if computation fails
|
|
939
|
+
* @param f - The effect function for errors
|
|
940
|
+
* @returns This Lazy for chaining
|
|
941
|
+
*/
|
|
942
|
+
tapError(f: (error: unknown) => void): Lazy<T>;
|
|
943
|
+
/**
|
|
944
|
+
* Pattern matching on the Lazy value
|
|
945
|
+
* @param f - Function to apply to the computed value
|
|
946
|
+
* @returns The result of applying f to the computed value
|
|
947
|
+
*/
|
|
948
|
+
fold<U>(f: (value: T) => U): U;
|
|
949
|
+
/**
|
|
950
|
+
* Pattern matching with success and failure handlers
|
|
951
|
+
* @param onFailure - Function to handle computation failure
|
|
952
|
+
* @param onSuccess - Function to handle successful computation
|
|
953
|
+
* @returns The result of the appropriate handler
|
|
954
|
+
*/
|
|
955
|
+
foldWith<U>(onFailure: (error: unknown) => U, onSuccess: (value: T) => U): U;
|
|
956
|
+
/**
|
|
957
|
+
* Left fold operation
|
|
958
|
+
* @param z - Initial value
|
|
959
|
+
* @returns Function that takes an operator and applies it
|
|
960
|
+
*/
|
|
961
|
+
foldLeft: <B>(z: B) => (op: (b: B, a: T) => B) => B;
|
|
962
|
+
/**
|
|
963
|
+
* Right fold operation
|
|
964
|
+
* @param z - Initial value
|
|
965
|
+
* @returns Function that takes an operator and applies it
|
|
966
|
+
*/
|
|
967
|
+
foldRight: <B>(z: B) => (op: (a: T, b: B) => B) => B;
|
|
968
|
+
/**
|
|
969
|
+
* Pattern matching for the Lazy type
|
|
970
|
+
* @param patterns - Object with handler for Lazy pattern
|
|
971
|
+
* @returns The result of the matched handler
|
|
972
|
+
*/
|
|
973
|
+
match<R>(patterns: {
|
|
974
|
+
Lazy: (value: T) => R;
|
|
975
|
+
}): R;
|
|
976
|
+
/**
|
|
977
|
+
* Creates a string representation of the Lazy
|
|
978
|
+
* @returns String representation showing evaluation status
|
|
979
|
+
*/
|
|
980
|
+
toString(): string;
|
|
981
|
+
/**
|
|
982
|
+
* Converts the Lazy to a value object
|
|
983
|
+
* @returns Object representation of the Lazy
|
|
984
|
+
*/
|
|
985
|
+
toValue(): {
|
|
986
|
+
_tag: "Lazy";
|
|
987
|
+
evaluated: boolean;
|
|
988
|
+
value?: T;
|
|
989
|
+
};
|
|
990
|
+
} & Functor<T> & AsyncFunctor<T> & Pipe<T> & Serializable<T> & Typeable<"Lazy"> & Foldable<T> & Matchable<T, "Lazy">;
|
|
991
|
+
/**
|
|
992
|
+
* Creates a Lazy computation that defers evaluation until needed.
|
|
993
|
+
* Results are memoized after first evaluation.
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* // Basic lazy evaluation
|
|
997
|
+
* const expensive = Lazy(() => {
|
|
998
|
+
* console.log("Computing...")
|
|
999
|
+
* return 42
|
|
1000
|
+
* })
|
|
1001
|
+
* // Nothing printed yet
|
|
1002
|
+
* const result = expensive.get() // Prints "Computing..." and returns 42
|
|
1003
|
+
* const cached = expensive.get() // Returns 42 without printing
|
|
1004
|
+
*
|
|
1005
|
+
* @example
|
|
1006
|
+
* // Error handling
|
|
1007
|
+
* const risky = Lazy(() => {
|
|
1008
|
+
* if (Math.random() > 0.5) throw new Error("Failed")
|
|
1009
|
+
* return "Success"
|
|
1010
|
+
* })
|
|
1011
|
+
* const safe = risky.getOrElse("Default") // Returns "Success" or "Default"
|
|
1012
|
+
* const option = risky.toOption() // Some("Success") or None
|
|
1013
|
+
* const either = risky.toEither() // Right("Success") or Left(Error)
|
|
1014
|
+
*
|
|
1015
|
+
* @example
|
|
1016
|
+
* // Chaining computations
|
|
1017
|
+
* const result = Lazy(() => 10)
|
|
1018
|
+
* .map(x => x * 2)
|
|
1019
|
+
* .flatMap(x => Lazy(() => x + 5))
|
|
1020
|
+
* .recover(err => 0)
|
|
1021
|
+
* .get() // 25
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* // Integration with functype
|
|
1025
|
+
* const userOption = Option({ id: 1, name: "Alice" })
|
|
1026
|
+
* const userName = Lazy.fromOption(userOption, () => ({ id: 0, name: "Anonymous" }))
|
|
1027
|
+
* .map(user => user.name)
|
|
1028
|
+
* .get() // "Alice"
|
|
1029
|
+
*/
|
|
1030
|
+
declare const Lazy: (<T extends Type>(thunk: () => T) => Lazy<T>) & {
|
|
1031
|
+
/**
|
|
1032
|
+
* Creates a Lazy from a thunk (deferred computation)
|
|
1033
|
+
* @param thunk - Function that computes the value
|
|
1034
|
+
* @returns A new Lazy instance
|
|
1035
|
+
*/
|
|
1036
|
+
of: <T extends Type>(thunk: () => T) => Lazy<T>;
|
|
1037
|
+
/**
|
|
1038
|
+
* Creates a Lazy from an immediate value
|
|
1039
|
+
* @param value - The value to wrap
|
|
1040
|
+
* @returns A new Lazy instance that returns the value
|
|
1041
|
+
*/
|
|
1042
|
+
fromValue: <T extends Type>(value: T) => Lazy<T>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Creates a Lazy from an Option
|
|
1045
|
+
* @param option - The Option to convert
|
|
1046
|
+
* @param defaultThunk - Thunk to compute default value if Option is None
|
|
1047
|
+
* @returns A new Lazy instance
|
|
1048
|
+
*/
|
|
1049
|
+
fromOption: <T extends Type>(option: Option<T>, defaultThunk: () => T) => Lazy<T>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Creates a Lazy from a Try
|
|
1052
|
+
* @param tryValue - The Try to convert
|
|
1053
|
+
* @returns A new Lazy instance
|
|
1054
|
+
*/
|
|
1055
|
+
fromTry: <T extends Type>(tryValue: Try<T>) => Lazy<T>;
|
|
1056
|
+
/**
|
|
1057
|
+
* Creates a Lazy from an Either
|
|
1058
|
+
* @param either - The Either to convert
|
|
1059
|
+
* @returns A new Lazy instance
|
|
1060
|
+
*/
|
|
1061
|
+
fromEither: <E, T extends Type>(either: Either<E, T>) => Lazy<T>;
|
|
1062
|
+
/**
|
|
1063
|
+
* Creates a Lazy that will throw an error since promises need to be awaited first
|
|
1064
|
+
* @param promise - The Promise to convert
|
|
1065
|
+
* @returns A new Lazy instance that throws an error
|
|
1066
|
+
*/
|
|
1067
|
+
fromPromise: <T extends Type>(promise: Promise<T>) => Lazy<T>;
|
|
1068
|
+
/**
|
|
1069
|
+
* Creates a failed Lazy that will throw when evaluated
|
|
1070
|
+
* @param error - The error to throw
|
|
1071
|
+
* @returns A new Lazy instance that throws the error
|
|
1072
|
+
*/
|
|
1073
|
+
fail: <T extends Type>(error: unknown) => Lazy<T>;
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* LazyList provides lazy evaluation for list operations.
|
|
1078
|
+
* Operations are deferred until the list is materialized.
|
|
1079
|
+
*
|
|
1080
|
+
* @example
|
|
1081
|
+
* // Basic lazy evaluation
|
|
1082
|
+
* const result = LazyList([1, 2, 3, 4, 5])
|
|
1083
|
+
* .map(x => x * 2)
|
|
1084
|
+
* .filter(x => x > 5)
|
|
1085
|
+
* .toArray() // [6, 8, 10]
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
* // Infinite sequences with take
|
|
1089
|
+
* const fibonacci = LazyList.iterate([0, 1], ([a, b]) => [b, a + b])
|
|
1090
|
+
* .map(([a]) => a)
|
|
1091
|
+
* .take(10)
|
|
1092
|
+
* .toArray() // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
|
|
1093
|
+
*/
|
|
1094
|
+
type LazyList<A extends Type> = {
|
|
1095
|
+
[Symbol.iterator](): Iterator<A>;
|
|
1096
|
+
map<B extends Type>(f: (a: A) => B): LazyList<B>;
|
|
1097
|
+
flatMap<B extends Type>(f: (a: A) => LazyList<B>): LazyList<B>;
|
|
1098
|
+
filter(predicate: (a: A) => boolean): LazyList<A>;
|
|
1099
|
+
take(n: number): LazyList<A>;
|
|
1100
|
+
drop(n: number): LazyList<A>;
|
|
1101
|
+
takeWhile(predicate: (a: A) => boolean): LazyList<A>;
|
|
1102
|
+
dropWhile(predicate: (a: A) => boolean): LazyList<A>;
|
|
1103
|
+
concat(other: LazyList<A>): LazyList<A>;
|
|
1104
|
+
zip<B extends Type>(other: LazyList<B>): LazyList<[A, B]>;
|
|
1105
|
+
toList(): List<A>;
|
|
1106
|
+
toArray(): A[];
|
|
1107
|
+
forEach(f: (a: A) => void): void;
|
|
1108
|
+
reduce<B extends Type>(f: (acc: B, a: A) => B, initial: B): B;
|
|
1109
|
+
find(predicate: (a: A) => boolean): Option<A>;
|
|
1110
|
+
some(predicate: (a: A) => boolean): boolean;
|
|
1111
|
+
every(predicate: (a: A) => boolean): boolean;
|
|
1112
|
+
count(): number;
|
|
1113
|
+
first(): Option<A>;
|
|
1114
|
+
last(): Option<A>;
|
|
1115
|
+
};
|
|
1116
|
+
/**
|
|
1117
|
+
* Lazy list implementation for efficient deferred computation
|
|
1118
|
+
* @example
|
|
1119
|
+
* // Process large datasets efficiently
|
|
1120
|
+
* const result = LazyList.range(1, 1000000)
|
|
1121
|
+
* .filter(x => x % 2 === 0)
|
|
1122
|
+
* .map(x => x * x)
|
|
1123
|
+
* .take(5)
|
|
1124
|
+
* .toArray() // [4, 16, 36, 64, 100]
|
|
1125
|
+
*
|
|
1126
|
+
* @example
|
|
1127
|
+
* // Infinite sequences
|
|
1128
|
+
* const primes = LazyList.iterate(2, n => n + 1)
|
|
1129
|
+
* .filter(isPrime)
|
|
1130
|
+
* .take(10)
|
|
1131
|
+
* .toArray() // First 10 prime numbers
|
|
1132
|
+
*
|
|
1133
|
+
* @example
|
|
1134
|
+
* // Combining operations
|
|
1135
|
+
* const evens = LazyList.range(0, 100, 2)
|
|
1136
|
+
* const odds = LazyList.range(1, 100, 2)
|
|
1137
|
+
* const combined = evens.zip(odds)
|
|
1138
|
+
* .map(([e, o]) => e + o)
|
|
1139
|
+
* .take(5)
|
|
1140
|
+
* .toArray() // [1, 5, 9, 13, 17]
|
|
1141
|
+
*/
|
|
1142
|
+
declare const LazyList: (<A extends Type>(iterable: Iterable<A>) => LazyList<A>) & {
|
|
1143
|
+
/**
|
|
1144
|
+
* Create an empty LazyList
|
|
1145
|
+
* @example
|
|
1146
|
+
* const empty = LazyList.empty<number>()
|
|
1147
|
+
* empty.toArray() // []
|
|
1148
|
+
*/
|
|
1149
|
+
empty: <A extends Type>() => LazyList<A>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Create a LazyList from a single value
|
|
1152
|
+
* @example
|
|
1153
|
+
* const single = LazyList.of(42)
|
|
1154
|
+
* .map(x => x * 2)
|
|
1155
|
+
* .toArray() // [84]
|
|
1156
|
+
*/
|
|
1157
|
+
of: <A extends Type>(value: A) => LazyList<A>;
|
|
1158
|
+
/**
|
|
1159
|
+
* Create a LazyList from multiple values
|
|
1160
|
+
*/
|
|
1161
|
+
from: <A extends Type>(...values: A[]) => LazyList<A>;
|
|
1162
|
+
/**
|
|
1163
|
+
* Create an infinite LazyList by repeatedly applying a function
|
|
1164
|
+
* @example
|
|
1165
|
+
* // Powers of 2
|
|
1166
|
+
* const powers = LazyList.iterate(1, x => x * 2)
|
|
1167
|
+
* .take(10)
|
|
1168
|
+
* .toArray() // [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
|
|
1169
|
+
*
|
|
1170
|
+
* @example
|
|
1171
|
+
* // Fibonacci sequence
|
|
1172
|
+
* const fib = LazyList.iterate([0, 1], ([a, b]) => [b, a + b])
|
|
1173
|
+
* .map(([a]) => a)
|
|
1174
|
+
* .take(8)
|
|
1175
|
+
* .toArray() // [0, 1, 1, 2, 3, 5, 8, 13]
|
|
1176
|
+
*/
|
|
1177
|
+
iterate: <A extends Type>(initial: A, f: (a: A) => A) => LazyList<A>;
|
|
1178
|
+
/**
|
|
1179
|
+
* Create an infinite LazyList by repeatedly calling a function
|
|
1180
|
+
*/
|
|
1181
|
+
generate: <A extends Type>(f: () => A) => LazyList<A>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Create a LazyList of numbers from start to end (exclusive)
|
|
1184
|
+
* @example
|
|
1185
|
+
* LazyList.range(1, 6).toArray() // [1, 2, 3, 4, 5]
|
|
1186
|
+
* LazyList.range(0, 10, 2).toArray() // [0, 2, 4, 6, 8]
|
|
1187
|
+
* LazyList.range(10, 0, -1).toArray() // [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
|
|
1188
|
+
*
|
|
1189
|
+
* @example
|
|
1190
|
+
* // Sum of squares from 1 to 100
|
|
1191
|
+
* const sum = LazyList.range(1, 101)
|
|
1192
|
+
* .map(x => x * x)
|
|
1193
|
+
* .reduce((a, b) => a + b, 0) // 338350
|
|
1194
|
+
*/
|
|
1195
|
+
range: (start: number, end: number, step?: number) => LazyList<number>;
|
|
1196
|
+
/**
|
|
1197
|
+
* Create a LazyList that repeats a value n times (or infinitely if n is not provided)
|
|
1198
|
+
*/
|
|
1199
|
+
repeat: <A extends Type>(value: A, n?: number) => LazyList<A>;
|
|
1200
|
+
/**
|
|
1201
|
+
* Create a LazyList that cycles through an iterable infinitely
|
|
1202
|
+
*/
|
|
1203
|
+
cycle: <A extends Type>(iterable: Iterable<A>) => LazyList<A>;
|
|
1204
|
+
};
|
|
1205
|
+
|
|
444
1206
|
/**
|
|
445
1207
|
* Stack data structure - Last In, First Out (LIFO)
|
|
446
1208
|
* Implements the Traversable interface for working with ordered collections
|
|
@@ -531,4 +1293,4 @@ declare const Stack: (<A extends Type>(values?: A[]) => Stack<A>) & {
|
|
|
531
1293
|
fromBinary: <A>(binary: string) => Stack<A>;
|
|
532
1294
|
};
|
|
533
1295
|
|
|
534
|
-
export { type Async, Base, type CancellationToken, type CancellationTokenSource, Companion, Either, type EitherKind, type ErrorChainElement, type ErrorFormatterOptions, type ErrorWithTaskInfo, FPromise, Foldable, FoldableUtils, Functor, HKT, Identity, type Kind, List, type ListKind, Matchable, NAME, Option, type OptionKind, ParseError, Pipe, Serializable, Stack, type Sync, type TaggedThrowable, Task, type TaskErrorInfo, TaskException, type TaskInfo, type TaskParams, TaskResult, Throwable, type ThrowableType, Traversable, Try, type TryKind, Type, Typeable, type UniversalContainer, Valuable, createCancellationTokenSource, createErrorSerializer, formatError, formatStackTrace, isTaggedThrowable, safeStringify };
|
|
1296
|
+
export { type Async, AsyncFunctor, Base, BoundedNumber, BoundedString, Brand, type CancellationToken, type CancellationTokenSource, Companion, Cond, Either, type EitherKind, EmailAddress, type ErrorChainElement, type ErrorFormatterOptions, type ErrorWithTaskInfo, FPromise, Foldable, FoldableUtils, Functor, HKT, ISO8601Date, Identity, IntegerNumber, type Kind, Lazy, LazyList, Lazy as LazyType, List, type ListKind, Match, Matchable, NAME, NonEmptyString, NonNegativeNumber, Option, type OptionKind, ParseError, PatternString, Pipe, PositiveInteger, PositiveNumber, Serializable, Stack, type Sync, type TaggedThrowable, Task, type TaskErrorInfo, TaskException, type TaskInfo, type TaskParams, TaskResult, Throwable, type ThrowableType, Traversable, Try, type TryKind, Type, Typeable, UUID, type UniversalContainer, UrlString, ValidatedBrand, Valuable, createCancellationTokenSource, createErrorSerializer, formatError, formatStackTrace, isTaggedThrowable, safeStringify };
|