functype 0.46.2 → 0.47.0

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.
@@ -1,4 +1,4 @@
1
- import { mn as Doable, nn as Reshapeable, pn as DoResult } from "../Functype-Dc440LS5.js";
1
+ import { mn as Doable, nn as Reshapeable, pn as DoResult } from "../Functype-Boat1fLo.js";
2
2
  import { Try } from "../try/index.js";
3
3
  import { Option } from "../option/index.js";
4
4
  import { List } from "../list/index.js";
@@ -1,5 +1,5 @@
1
- import { an as AsyncMonad, dn as Extractable, mn as Doable, n as FunctypeBase, nn as Reshapeable, rn as Promisable } from "../Functype-Dc440LS5.js";
2
- import { l as Type } from "../Typeable-E4-aX9Gc.js";
1
+ import { an as AsyncMonad, dn as Extractable, mn as Doable, n as FunctypeBase, nn as Reshapeable, rn as Promisable } from "../Functype-Boat1fLo.js";
2
+ import { l as Type } from "../Typeable-lfO2nRVW.js";
3
3
  import { Option } from "../option/index.js";
4
4
  import { List } from "../list/index.js";
5
5
 
@@ -0,0 +1,638 @@
1
+ const e=`0.47.0`,t={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.orNull()`,`.match({Some, None})`],check:[`.isSome`,`.isNone`,`.isDefined`,`.isEmpty`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:[`Functor`,`Monad`,`Foldable`,`Traversable`,`PromiseLike`],methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.orElse(d)`,`.orThrow()`,`.match({Left, Right})`],check:[`.isRight`,`.isLeft`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Try(() => expr)`,`Success(v)`,`Failure(e)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.orElse(d)`,`.orThrow()`,`.toOption()`,`.toEither()`],check:[`.isSuccess`,`.isFailure`]}},List:{description:`Immutable array with functional operations`,interfaces:[`Functor`,`Monad`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`List([...])`,`List.of(...)`,`List.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.take(n)`,`.takeWhile(p)`,`.takeRight(n)`,`.drop(n)`,`.dropWhile(p)`,`.concat(list)`,`.reverse()`,`.distinct()`,`.sorted()`,`.sortBy(f)`,`.zip(list)`,`.zipWithIndex()`,`.prepend(v)`,`.slice(s, e)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.indexOf(v)`,`.toArray()`],check:[`.isEmpty`,`.nonEmpty`,`.size`,`.contains(v)`],other:[`.groupBy(f)`,`.partition(p)`,`.span(p)`]}},Set:{description:`Immutable set of unique values`,interfaces:[`Functor`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.filter(p)`,`.union(s)`,`.intersection(s)`,`.difference(s)`,`.add(v)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:[`SafeTraversable`,`Collection`,`Serializable`],methods:{create:[`Map([[k, v], ...])`,`Map.of([k, v], ...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`,`.add(k, v)`],extract:[`.get(k)`,`.keys()`,`.values()`,`.entries()`,`.fold(z, f)`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Lazy:{description:`Deferred computation with memoization`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Serializable`,`Traversable`],methods:{create:[`Lazy(() => expr)`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:[`Functor`,`Monad`,`Iterable`],methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`],transform:[`.map(f)`,`.filter(p)`,`.take(n)`,`.takeRight(n)`,`.drop(n)`,`.takeWhile(p)`,`.dropWhile(p)`,`.concat(ll)`,`.reverse()`,`.distinct()`,`.zip(ll)`,`.zipWithIndex()`],extract:[`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.toArray()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress`,interfaces:[],methods:{create:[`Task.of(v)`,`Task.from(promise)`,`Task.sync(f)`,`Task.async(f)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`],extract:[`.run()`,`.cancel()`],other:[`.onProgress(cb)`,`.onCancel(cb)`]}},IO:{description:`Lazy effect type with typed errors and dependency injection`,interfaces:[`Functor`,`Monad`,`Foldable`,`Matchable`],methods:{create:[`IO(() => v)`,`IO.succeed(v)`,`IO.fail(e)`,`IO.sync(f)`,`IO.async(f)`,`IO.tryPromise({try, catch})`,`IO.fromEither(e)`,`IO.fromOption(o)`,`IO.fromTry(t)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run()`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit()`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...])`,`IO.race([...])`,`IO.bracket(acquire, use, release)`,`IO.gen(function*() {...})`,`IO.Do.bind().map()`,`IO.service(Tag)`,`.provideService(Tag, impl)`,`.provideLayer(layer)`]}},Cond:{description:`Conditional expression builder - replace if-else chains`,interfaces:[],methods:{create:[`Cond<T>()`],other:[`.case(pred, result)`,`.otherwise(result)`,`.eval()`]}},Match:{description:`Pattern matching - replace switch statements`,interfaces:[],methods:{create:[`Match(value)`],other:[`.case(pattern, result)`,`.when(pred, result)`,`.default(result)`,`.done()`]}},Brand:{description:`Nominal typing without runtime overhead`,interfaces:[],methods:{create:[`Brand<K, T>(value)`],extract:[`.unwrap()`,`.toString()`]}},ValidatedBrand:{description:`Branded types with runtime validation`,interfaces:[],methods:{create:[`ValidatedBrand(validator)`,`.of(v)`,`.from(v)`,`.unsafeOf(v)`],check:[`.is(v)`],other:[`.refine(validator)`]}},Tuple:{description:`Fixed-size typed array`,interfaces:[`Typeable`,`Valuable`,`Iterable`],methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`],extract:[`.first`,`.second`,`.toArray()`],transform:[`.map(f)`]}},Stack:{description:`Immutable LIFO stack`,interfaces:[`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Stack()`,`Stack.of(...)`],transform:[`.push(v)`,`.pop()`],extract:[`.peek()`,`.toArray()`],check:[`.isEmpty`,`.size`]}}},n={Functor:{description:`Transform contained values`,methods:[`.map<B>(f: A => B): Functor<B>`]},Applicative:{extends:`Functor`,description:`Apply wrapped functions`,methods:[`.ap<B>(ff: Applicative<A => B>): Applicative<B>`]},Monad:{extends:`Applicative`,description:`Chain operations returning wrapped values`,methods:[`.flatMap<B>(f: A => Monad<B>): Monad<B>`]},Foldable:{description:`Extract via pattern matching`,methods:[`.fold<B>(empty: () => B, f: A => B): B`,`.foldLeft<B>(z: B, op: (B, A) => B): B`,`.foldRight<B>(z: B, op: (A, B) => B): B`]},Extractable:{description:`Get contained value with fallback`,methods:[`.orElse(d: T): T`,`.orThrow(e?: Error): T`,`.orNull(): T | null`,`.orUndefined(): T | undefined`]},Matchable:{description:`Pattern match on type variants`,methods:[`.match<R>(patterns: Record<Tag, Handler>): R`]},Traversable:{description:`Iterate and check contents`,methods:[`.size: number`,`.isEmpty: boolean`,`.contains(v: A): boolean`,`.reduce<B>(f, init): B`]},Collection:{description:`Collection operations`,methods:[`.toArray(): A[]`,`.forEach(f: A => void): void`]},Serializable:{description:`Convert to string formats`,methods:[`.serialize().toJSON(): string`,`.serialize().toYAML(): string`]}},r={Core:[`Option`,`Either`,`Try`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},i={Option:`export interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
2
+ /** The contained value (undefined for None) */
3
+ readonly value: T | undefined
4
+ /** Whether this Option contains no value */
5
+ isEmpty: boolean
6
+ /**
7
+ * Returns true if this Option is a Some (contains a value)
8
+ * @returns true if this Option contains a value, false otherwise
9
+ */
10
+ isSome(): this is Option<T> & { value: T; isEmpty: false }
11
+ /**
12
+ * Returns true if this Option is a None (contains no value)
13
+ * @returns true if this Option is empty, false otherwise
14
+ */
15
+ isNone(): this is Option<T> & { value: undefined; isEmpty: true }
16
+ /**
17
+ * Returns the contained value or a default value if None
18
+ * @param defaultValue - The value to return if this Option is None
19
+ * @returns The contained value or defaultValue
20
+ */
21
+ orElse(defaultValue: T): T
22
+ /**
23
+ * Returns the contained value or throws an error if None
24
+ * @param error - Optional custom error to throw. If not provided, throws a default error
25
+ * @returns The contained value
26
+ * @throws The specified error or a default error if the Option is None
27
+ */
28
+ orThrow(error?: Error): T
29
+ /**
30
+ * Returns this Option if it contains a value, otherwise returns the alternative container
31
+ * @param alternative - The alternative Option to return if this is None
32
+ * @returns This Option or the alternative
33
+ */
34
+ or(alternative: Option<T>): Option<T>
35
+ /**
36
+ * Returns the contained value or null if None
37
+ * @returns The contained value or null
38
+ */
39
+ orNull(): T | null
40
+ /**
41
+ * Returns the contained value or undefined if None
42
+ * @returns The contained value or undefined
43
+ */
44
+ orUndefined(): T | undefined
45
+ /**
46
+ * Maps the value inside the Option using the provided function
47
+ * @param f - The mapping function
48
+ * @returns A new Option containing the mapped value, or None if this Option is None
49
+ */
50
+ map<U extends Type>(f: (value: T) => U): Option<U>
51
+ /**
52
+ * Applies a wrapped function to a wrapped value (Applicative pattern)
53
+ * @param ff - An Option containing a function from T to U
54
+ * @returns A new Option containing the result of applying the function
55
+ */
56
+ ap<U extends Type>(ff: Option<(value: T) => U>): Option<U>
57
+ /**
58
+ * Returns this Option if it contains a value that satisfies the predicate, otherwise returns None
59
+ * @param predicate - The predicate function to test the value
60
+ * @returns This Option or None
61
+ */
62
+ filter(predicate: (value: T) => boolean): Option<T>
63
+ /**
64
+ * Maps the value using a function that returns an Option
65
+ * @param f - The mapping function returning an Option
66
+ * @returns The result of applying f to the contained value, or None if this Option is None
67
+ */
68
+ flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>
69
+ /**
70
+ * Maps the value using an async function that returns an Option
71
+ * @param f - The async mapping function returning an Option
72
+ * @returns Promise of the result of applying f to the contained value, or None if this Option is None
73
+ */
74
+ flatMapAsync<U extends Type>(f: (value: T) => Promise<Option<U>>): Promise<Option<U>>
75
+ /**
76
+ * Applies a binary operator to a start value and the contained value
77
+ * @param f - The binary operator
78
+ * @returns The result of the reduction
79
+ */
80
+ reduce<U>(f: (acc: U, value: T) => U): U
81
+ /**
82
+ * Applies a binary operator to the contained value and a start value
83
+ * @param f - The binary operator
84
+ * @returns The result of the reduction
85
+ */
86
+ reduceRight<U>(f: (acc: U, value: T) => U): U
87
+ /**
88
+ * Pattern matches over the Option, applying onNone if None and onSome if Some
89
+ * @param onNone - Function to apply if the Option is None
90
+ * @param onSome - Function to apply if the Option has a value
91
+ * @returns The result of applying the appropriate function
92
+ */
93
+ fold<U>(onNone: () => U, onSome: (value: T) => U): U
94
+ /**
95
+ * Left-associative fold using the provided zero value and operation
96
+ * @param z - Zero/identity value
97
+ * @returns A function that takes an operation to apply
98
+ */
99
+ foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B
100
+ /**
101
+ * Right-associative fold using the provided zero value and operation
102
+ * @param z - Zero/identity value
103
+ * @returns A function that takes an operation to apply
104
+ */
105
+ foldRight<B>(z: B): (op: (a: T, b: B) => B) => B
106
+ /**
107
+ * Converts this Option to a List
108
+ * @returns A List containing the value if Some, or empty List if None
109
+ */
110
+ toList(): List<T>
111
+ /**
112
+ * Checks if this Option contains the specified value
113
+ * @param value - The value to check for
114
+ * @returns true if this Option contains the value, false otherwise
115
+ */
116
+ contains(value: T): boolean
117
+ /** The number of elements in this Option (0 or 1) */
118
+ size: number
119
+ /**
120
+ * Converts this Option to an Either
121
+ * @param left - The value to use for Left if this Option is None
122
+ * @returns Either.Right with the contained value if Some, or Either.Left with left if None
123
+ */
124
+ toEither<E>(left: E): Either<E, T>
125
+ /**
126
+ * Returns a string representation of this Option
127
+ * @returns A string representation
128
+ */
129
+ toString(): string
130
+ /**
131
+ * Returns a simple object representation of this Option
132
+ * @returns An object with _tag and value properties
133
+ */
134
+ toValue(): { _tag: "Some" | "None"; value: T }
135
+ /**
136
+ * Pattern matches over the Option, applying a handler function based on the variant
137
+ * @param patterns - Object with handler functions for Some and None variants
138
+ * @returns The result of applying the matching handler function
139
+ */
140
+ match<R>(patterns: { Some: (value: T) => R; None: () => R }): R
141
+ }`,Either:`export interface Either<L extends Type, R extends Type>
142
+ extends FunctypeBase<R, "Left" | "Right">, Promisable<R>, Doable<R>, Reshapeable<R>, Extractable<R> {
143
+ readonly _tag: "Left" | "Right"
144
+ value: L | R
145
+ isLeft(): this is Either<L, R> & { readonly _tag: "Left"; value: L }
146
+ isRight(): this is Either<L, R> & { readonly _tag: "Right"; value: R }
147
+ orElse: (defaultValue: R) => R
148
+ orThrow: (error?: Error) => R
149
+ or(alternative: Either<L, R>): Either<L, R>
150
+ orNull: () => R | null
151
+ orUndefined: () => R | undefined
152
+ readonly map: <U extends Type>(f: (value: R) => U) => Either<L, U>
153
+ ap: <U extends Type>(ff: Either<L, (value: R) => U>) => Either<L, U>
154
+ merge: <L1 extends Type, R1 extends Type>(other: Either<L1, R1>) => Either<L | L1, [R, R1]>
155
+ mapAsync: <U extends Type>(f: (value: R) => Promise<U>) => Promise<Either<L, U>>
156
+ flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>
157
+ flatMapAsync: <U extends Type>(f: (value: R) => Promise<Either<L, U>>) => Promise<Either<L, U>>
158
+ toOption: () => Option<R>
159
+ toList: () => List<R>
160
+ toString: () => string
161
+ [Symbol.iterator]: () => Iterator<R>
162
+ yield: () => Generator<R, void, unknown>
163
+ traverse: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U[]>
164
+ lazyMap: <U extends Type>(f: (value: R) => U) => Generator<Either<L, U>, void, unknown>
165
+ tap: (f: (value: R) => void) => Either<L, R>
166
+ tapLeft: (f: (value: L) => void) => Either<L, R>
167
+ mapLeft: <L2 extends Type>(f: (value: L) => L2) => Either<L2, R>
168
+ bimap: <L2 extends Type, R2 extends Type>(fl: (value: L) => L2, fr: (value: R) => R2) => Either<L2, R2>
169
+ fold: <T extends Type>(onLeft: (value: L) => T, onRight: (value: R) => T) => T
170
+ swap: () => Either<R, L>
171
+ /**
172
+ * Pipes the value through the provided function based on whether this is a Left or Right
173
+ * @param onLeft - The function to apply if this is a Left
174
+ * @param onRight - The function to apply if this is a Right
175
+ * @returns The result of applying the appropriate function
176
+ */
177
+ pipeEither<U extends Type>(onLeft: (value: L) => U, onRight: (value: R) => U): U
178
+
179
+ /**
180
+ * Pipes the Either value through the provided function
181
+ * @param f - The function to apply to the value (Left or Right)
182
+ * @returns The result of applying the function to the value
183
+ */
184
+ pipe<U extends Type>(f: (value: L | R) => U): U
185
+ /**
186
+ * Pattern matches over the Either, applying a handler function based on the variant
187
+ * @param patterns - Object with handler functions for Left and Right variants
188
+ * @returns The result of applying the matching handler function
189
+ */
190
+ match<T>(patterns: { Left: (value: L) => T; Right: (value: R) => T }): T
191
+ /**
192
+ * Returns the value and tag for inspection
193
+ */
194
+ toValue(): { _tag: "Left" | "Right"; value: L | R }
195
+ /**
196
+ * Custom JSON serialization that excludes getter properties
197
+ */
198
+ toJSON(): { _tag: "Left" | "Right"; value: L | R }
199
+ }`,Try:`export interface Try<T>
200
+ extends FunctypeBase<T, TypeNames>, Extractable<T>, Pipe<T>, Promisable<T>, Doable<T>, Reshapeable<T> {
201
+ readonly _tag: TypeNames
202
+ readonly error: Error | undefined
203
+ isSuccess(): this is Try<T> & { readonly _tag: "Success"; error: undefined }
204
+ isFailure(): this is Try<T> & { readonly _tag: "Failure"; error: Error }
205
+ orElse: (defaultValue: T) => T
206
+ orThrow: (error?: Error) => T
207
+ or: (alternative: Try<T>) => Try<T>
208
+ orNull: () => T | null
209
+ orUndefined: () => T | undefined
210
+ toOption: () => Option<T>
211
+ toEither: <E extends Type>(leftValue: E) => Either<E, T>
212
+ toList: () => List<T>
213
+ toTry: () => Try<T>
214
+ map: <U>(f: (value: T) => U) => Try<U>
215
+ ap: <U>(ff: Try<(value: T) => U>) => Try<U>
216
+ flatMap: <U>(f: (value: T) => Try<U>) => Try<U>
217
+ flatMapAsync: <U>(f: (value: T) => Promise<Try<U>>) => Promise<Try<U>>
218
+ /**
219
+ * Pattern matches over the Try, applying onFailure if Failure and onSuccess if Success
220
+ * @param onFailure - Function to apply if the Try is Failure
221
+ * @param onSuccess - Function to apply if the Try is Success
222
+ * @returns The result of applying the appropriate function
223
+ */
224
+ fold: <U extends Type>(onFailure: (error: Error) => U, onSuccess: (value: T) => U) => U
225
+ toString: () => string
226
+ /**
227
+ * Pattern matches over the Try, applying a handler function based on the variant
228
+ * @param patterns - Object with handler functions for Success and Failure variants
229
+ * @returns The result of applying the matching handler function
230
+ */
231
+ match<R>(patterns: { Success: (value: T) => R; Failure: (error: Error) => R }): R
232
+ toValue(): { _tag: TypeNames; value: T | Error }
233
+ }`,List:`export interface List<A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<A> {
234
+ readonly length: number
235
+ readonly [Symbol.iterator]: () => Iterator<A>
236
+ // Override these to return List instead of FunctypeCollection
237
+ map: <B>(f: (a: A) => B) => List<B>
238
+ ap: <B>(ff: List<(value: A) => B>) => List<B>
239
+ flatMap: <B>(f: (a: A) => Iterable<B>) => List<B>
240
+ flatMapAsync: <B>(f: (a: A) => PromiseLike<Iterable<B>>) => PromiseLike<List<B>>
241
+ // Override filter for type guard support
242
+ filter<S extends A>(predicate: (a: A) => a is S): List<S>
243
+ filter(predicate: (a: A) => unknown): List<A>
244
+ filterNot: (p: (a: A) => boolean) => List<A>
245
+ // List-specific methods
246
+ /** @internal */
247
+ filterType: <T extends Typeable<string, unknown>>(tag: string) => List<T & A>
248
+ remove: (value: A) => List<A>
249
+ removeAt: (index: number) => List<A>
250
+ add: (item: A) => List<A>
251
+ get: (index: number) => Option<A>
252
+ concat: (other: List<A>) => List<A>
253
+ take: (n: number) => List<A>
254
+ takeWhile: (p: (a: A) => boolean) => List<A>
255
+ takeRight: (n: number) => List<A>
256
+ get last(): A | undefined
257
+ get lastOption(): Option<A>
258
+ get tail(): List<A>
259
+ get init(): List<A>
260
+ reverse: () => List<A>
261
+ indexOf: (value: A) => number
262
+ prepend: (item: A) => List<A>
263
+ distinct: () => List<A>
264
+ sorted: (compareFn?: (a: A, b: A) => number) => List<A>
265
+ sortBy: <B>(f: (a: A) => B, compareFn?: (a: B, b: B) => number) => List<A>
266
+ zip: <B>(other: List<B>) => List<[A, B]>
267
+ zipWithIndex: () => List<[A, number]>
268
+ groupBy: <K>(f: (a: A) => K) => globalThis.Map<K, List<A>>
269
+ partition: (p: (a: A) => boolean) => [List<A>, List<A>]
270
+ span: (p: (a: A) => boolean) => [List<A>, List<A>]
271
+ slice: (start: number, end: number) => List<A>
272
+ /**
273
+ * Pattern matches over the List, applying a handler function based on whether it's empty
274
+ * @param patterns - Object with handler functions for Empty and NonEmpty variants
275
+ * @returns The result of applying the matching handler function
276
+ */
277
+ match<R>(patterns: { Empty: () => R; NonEmpty: (values: A[]) => R }): R
278
+ }`,Set:`export interface Set<A> extends FunctypeCollection<A, "Set">, Collection<A> {
279
+ add: (value: A) => Set<A>
280
+ remove: (value: A) => Set<A>
281
+ contains: (value: A) => boolean
282
+ has: (value: A) => boolean
283
+ map: <B>(f: (a: A) => B) => Set<B>
284
+ flatMap: <B>(f: (a: A) => Iterable<B>) => Set<B>
285
+ filter: (p: (a: A) => boolean) => Set<A>
286
+ filterNot: (p: (a: A) => boolean) => Set<A>
287
+ fold: <U extends Type>(onEmpty: () => U, onValue: (value: A) => U) => U
288
+ toList: () => List<A>
289
+ toSet: () => Set<A>
290
+ toArray: <B = A>() => B[]
291
+ toString: () => string
292
+ }`,Map:`export interface Map<K, V>
293
+ extends
294
+ SafeTraversable<K, V>,
295
+ Collection<Tuple<[K, V]>>,
296
+ Typeable<"Map">,
297
+ Serializable<[K, V][]>,
298
+ Pipe<[K, V][]>,
299
+ Foldable<Tuple<[K, V]>>,
300
+ Iterable<[K, V]> {
301
+ readonly _tag: "Map"
302
+ add(item: Tuple<[K, V]>): Map<K, V>
303
+ remove(value: K): Map<K, V>
304
+ map<U>(f: (value: V) => U): Map<K, U>
305
+ ap<U>(ff: Map<K, (value: V) => U>): Map<K, U>
306
+ flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => Iterable<[K2, V2]>): Map<K2, V2>
307
+ flatMapAsync<U>(f: (value: V) => PromiseLike<Map<K, U>>): PromiseLike<Map<K, U>>
308
+ get(key: K): Option<V>
309
+ getOrElse(key: K, defaultValue: V): V
310
+ orElse(key: K, alternative: Option<V>): Option<V>
311
+ fold<U extends Type>(onEmpty: () => U, onValue: (value: Tuple<[K, V]>) => U): U
312
+ foldLeft<B>(z: B): (op: (b: B, a: Tuple<[K, V]>) => B) => B
313
+ foldRight<B>(z: B): (op: (a: Tuple<[K, V]>, b: B) => B) => B
314
+ /**
315
+ * Pattern matches over the Map, applying a handler function based on whether it's empty
316
+ * @param patterns - Object with handler functions for Empty and NonEmpty variants
317
+ * @returns The result of applying the matching handler function
318
+ */
319
+ match<R>(patterns: { Empty: () => R; NonEmpty: (entries: Array<Tuple<[K, V]>>) => R }): R
320
+ toValue(): { _tag: "Map"; value: [K, V][] }
321
+ }`,Lazy:`export interface Lazy<T extends Type> extends FunctypeBase<T, "Lazy">, Extractable<T>, Pipe<T> {
322
+ /** Tag identifying this as a Lazy type */
323
+ readonly _tag: "Lazy"
324
+ /** Whether the computation has been evaluated */
325
+ readonly isEvaluated: boolean
326
+ /**
327
+ * Returns the computed value or a default value if computation fails
328
+ * @param defaultValue - The value to return if computation fails
329
+ * @returns The computed value or defaultValue
330
+ */
331
+ orElse(defaultValue: T): T
332
+ /**
333
+ * Returns the computed value or null if computation fails
334
+ * @returns The computed value or null
335
+ */
336
+ orNull(): T | null
337
+ /**
338
+ * Returns the computed value or throws an error if computation fails
339
+ * @param error - Optional custom error to throw. If not provided, throws the computation error or a default error
340
+ * @returns The computed value
341
+ * @throws The specified error, computation error, or a default error
342
+ */
343
+ orThrow(error?: Error): T
344
+ /**
345
+ * Returns this Lazy if computation succeeds, otherwise returns the alternative Lazy
346
+ * @param alternative - The alternative Lazy to use if computation fails
347
+ * @returns This Lazy or the alternative
348
+ */
349
+ or(alternative: Lazy<T>): Lazy<T>
350
+ /**
351
+ * Maps the value inside the Lazy using the provided function
352
+ * @param f - The mapping function
353
+ * @returns A new Lazy containing the mapped value
354
+ */
355
+ map<U extends Type>(f: (value: T) => U): Lazy<U>
356
+ /**
357
+ * Applies a wrapped function to a wrapped value (Applicative pattern)
358
+ * @param ff - A Lazy containing a function from T to U
359
+ * @returns A new Lazy containing the result
360
+ */
361
+ ap<U extends Type>(ff: Lazy<(value: T) => U>): Lazy<U>
362
+ /**
363
+ * Maps the value inside the Lazy using an async function
364
+ * @param f - The async mapping function
365
+ * @returns A Promise of a new Lazy containing the mapped value
366
+ */
367
+ mapAsync<U extends Type>(f: (value: T) => Promise<U>): Promise<Lazy<U>>
368
+ /**
369
+ * Maps the value using a function that returns a Lazy
370
+ * @param f - The mapping function returning a Lazy
371
+ * @returns A new Lazy containing the flattened result
372
+ */
373
+ flatMap<U extends Type>(f: (value: T) => Lazy<U>): Lazy<U>
374
+ /**
375
+ * Maps the value using an async function that returns a Lazy
376
+ * @param f - The async mapping function returning a Lazy
377
+ * @returns A Promise of a new Lazy containing the flattened result
378
+ */
379
+ flatMapAsync<U extends Type>(f: (value: T) => Promise<Lazy<U>>): Promise<Lazy<U>>
380
+ /**
381
+ * Returns a Lazy that filters the value based on a predicate
382
+ * @param predicate - The predicate function
383
+ * @returns A Lazy containing an Option of the value
384
+ */
385
+ filter(predicate: (value: T) => boolean): Lazy<Option<T>>
386
+ /**
387
+ * Recovers from a failed computation by providing an alternative value
388
+ * @param f - Function that takes the error and returns a recovery value
389
+ * @returns A new Lazy that will use the recovery function if computation fails
390
+ */
391
+ recover(f: (error: unknown) => T): Lazy<T>
392
+ /**
393
+ * Recovers from a failed computation by providing an alternative Lazy
394
+ * @param f - Function that takes the error and returns a recovery Lazy
395
+ * @returns A new Lazy that will use the recovery Lazy if computation fails
396
+ */
397
+ recoverWith(f: (error: unknown) => Lazy<T>): Lazy<T>
398
+ /**
399
+ * Evaluates the computation and returns it as an Option
400
+ * @returns Some containing the value if successful, None if computation fails
401
+ */
402
+ toOption(): Option<T>
403
+ /**
404
+ * Evaluates the computation and returns it as an Either
405
+ * @returns Right containing the value if successful, Left containing the error if computation fails
406
+ */
407
+ toEither(): Either<unknown, T>
408
+ /**
409
+ * Evaluates the computation and returns it as an Either with a mapped error
410
+ * @param mapError - Function to map the error
411
+ * @returns Right containing the value if successful, Left containing the mapped error if computation fails
412
+ */
413
+ toEitherWith<E>(mapError: (error: unknown) => E): Either<E, T>
414
+ /**
415
+ * Evaluates the computation and returns it as a Try
416
+ * @returns Try containing the result of the computation
417
+ */
418
+ toTry(): Try<T>
419
+ /**
420
+ * Applies an effect function to the value if computation succeeds
421
+ * @param f - The effect function
422
+ * @returns This Lazy for chaining
423
+ */
424
+ tap(f: (value: T) => void): Lazy<T>
425
+ /**
426
+ * Applies an effect function to the error if computation fails
427
+ * @param f - The effect function for errors
428
+ * @returns This Lazy for chaining
429
+ */
430
+ tapError(f: (error: unknown) => void): Lazy<T>
431
+ /**
432
+ * Pattern matching on the Lazy value
433
+ * @param f - Function to apply to the computed value
434
+ * @returns The result of applying f to the computed value
435
+ */
436
+ fold<U>(f: (value: T) => U): U
437
+ /**
438
+ * Pattern matching with success and failure handlers
439
+ * @param onFailure - Function to handle computation failure
440
+ * @param onSuccess - Function to handle successful computation
441
+ * @returns The result of the appropriate handler
442
+ */
443
+ foldWith<U>(onFailure: (error: unknown) => U, onSuccess: (value: T) => U): U
444
+ /**
445
+ * Left fold operation
446
+ * @param z - Initial value
447
+ * @returns Function that takes an operator and applies it
448
+ */
449
+ foldLeft: <B>(z: B) => (op: (b: B, a: T) => B) => B
450
+ /**
451
+ * Right fold operation
452
+ * @param z - Initial value
453
+ * @returns Function that takes an operator and applies it
454
+ */
455
+ foldRight: <B>(z: B) => (op: (a: T, b: B) => B) => B
456
+ /**
457
+ * Pattern matching for the Lazy type
458
+ * @param patterns - Object with handler for Lazy pattern
459
+ * @returns The result of the matched handler
460
+ */
461
+ match<R>(patterns: { Lazy: (value: T) => R }): R
462
+ /**
463
+ * Creates a string representation of the Lazy
464
+ * @returns String representation showing evaluation status
465
+ */
466
+ toString(): string
467
+ /**
468
+ * Converts the Lazy to a value object
469
+ * @returns Object representation of the Lazy with evaluation state
470
+ */
471
+ toValue(): { _tag: "Lazy"; evaluated: boolean; value?: T }
472
+ }`,LazyList:`export interface LazyList<A extends Type>
473
+ extends Foldable<A>, Pipe<LazyList<A>>, Serializable<LazyList<A>>, Typeable<"LazyList"> {
474
+ // Iterator protocol
475
+ [Symbol.iterator](): Iterator<A>
476
+
477
+ // Lazy operations
478
+ map<B extends Type>(f: (a: A) => B): LazyList<B>
479
+ flatMap<B extends Type>(f: (a: A) => LazyList<B>): LazyList<B>
480
+ filter(predicate: (a: A) => boolean): LazyList<A>
481
+ take(n: number): LazyList<A>
482
+ drop(n: number): LazyList<A>
483
+ takeWhile(predicate: (a: A) => boolean): LazyList<A>
484
+ dropWhile(predicate: (a: A) => boolean): LazyList<A>
485
+ concat(other: LazyList<A>): LazyList<A>
486
+ zip<B extends Type>(other: LazyList<B>): LazyList<[A, B]>
487
+
488
+ takeRight(n: number): LazyList<A>
489
+ reverse(): LazyList<A>
490
+ distinct(): LazyList<A>
491
+ zipWithIndex(): LazyList<[A, number]>
492
+
493
+ // Element access (properties)
494
+ get head(): A | undefined
495
+ get headOption(): Option<A>
496
+ get last(): A | undefined
497
+ get lastOption(): Option<A>
498
+ get tail(): LazyList<A>
499
+ get init(): LazyList<A>
500
+
501
+ // Terminal operations (force evaluation)
502
+ toList(): List<A>
503
+ toArray(): A[]
504
+ forEach(f: (a: A) => void): void
505
+ reduce<B extends Type>(f: (acc: B, a: A) => B, initial: B): B
506
+ find(predicate: (a: A) => boolean): Option<A>
507
+ some(predicate: (a: A) => boolean): boolean
508
+ every(predicate: (a: A) => boolean): boolean
509
+ count(): number
510
+
511
+ // Additional methods for clarity
512
+ toString(): string
513
+ }`,TaskOutcome:`export interface TaskOutcome<T>
514
+ extends FunctypeBase<T, "Ok" | "Err">, Extractable<T>, AsyncMonad<T>, Promisable<T>, Doable<T> {
515
+ readonly _tag: "Ok" | "Err"
516
+ readonly _meta: TaskMetadata
517
+
518
+ // Value access
519
+ readonly value?: T
520
+ readonly error?: Throwable
521
+
522
+ // Functional methods
523
+ readonly map: <U>(f: (value: T) => U) => TaskOutcome<U>
524
+ readonly flatMap: <U>(f: (value: T) => TaskOutcome<U> | Either<Throwable, U>) => TaskOutcome<U>
525
+ readonly ap: <U>(ff: TaskOutcome<(value: T) => U>) => TaskOutcome<U>
526
+ readonly mapAsync: <U>(f: (value: T) => Promise<U>) => Promise<TaskOutcome<U>>
527
+ readonly flatMapAsync: <U>(f: (value: T) => Promise<TaskOutcome<U>>) => Promise<TaskOutcome<U>>
528
+
529
+ // Error handling methods
530
+ readonly mapError: (f: (error: Throwable) => Throwable) => TaskOutcome<T>
531
+ readonly recover: (value: T) => Ok<T>
532
+ readonly recoverWith: (f: (error: Throwable) => T) => Ok<T>
533
+
534
+ // Type guards
535
+ readonly isSuccess: () => this is Ok<T>
536
+ readonly isFailure: () => this is Err<T>
537
+ readonly isOk: () => this is Ok<T>
538
+ readonly isErr: () => this is Err<T>
539
+
540
+ // Conversion methods
541
+ readonly toEither: () => Either<Throwable, T>
542
+ readonly toTry: () => Try<T>
543
+ readonly toOption: () => Option<T>
544
+ readonly toList: () => List<T>
545
+
546
+ // Pattern matching
547
+ readonly fold: <U>(onErr: (error: Throwable) => U, onOk: (value: T) => U) => U
548
+ readonly match: <U>(patterns: { Ok: (value: T) => U; Err: (error: Throwable) => U }) => U
549
+ }`,Tuple:`export interface Tuple<T extends Type[]>
550
+ extends Foldable<T[number]>, Pipe<Tuple<T>>, Serializable<Tuple<T>>, Typeable<"Tuple"> {
551
+ get<K extends number>(index: K): T[K]
552
+
553
+ map<U extends Type[]>(f: (value: T) => U): Tuple<U>
554
+
555
+ flatMap<U extends Type[]>(f: (value: T) => Tuple<U>): Tuple<U>
556
+
557
+ toArray(): T
558
+
559
+ length: number
560
+
561
+ [Symbol.iterator](): Iterator<T[number]>
562
+
563
+ toString(): string
564
+
565
+ toValue(): { _tag: "Tuple"; value: T }
566
+ }`,Stack:`export type Stack<A extends Type> = {
567
+ /**
568
+ * Push a value onto the top of the stack
569
+ * @param value - The value to push
570
+ * @returns A new Stack with the value added
571
+ */
572
+ push(value: A): Stack<A>
573
+
574
+ /**
575
+ * Remove and return the top value from the stack
576
+ * @returns A tuple containing the new Stack and the value
577
+ */
578
+ pop(): [Stack<A>, Option<A>]
579
+
580
+ /**
581
+ * Return the top value without removing it
582
+ * @returns The top value wrapped in an Option
583
+ */
584
+ peek(): Option<A>
585
+
586
+ /**
587
+ * Transforms each element in the stack using the provided function
588
+ * @param f - The mapping function
589
+ * @returns A new Stack with transformed elements
590
+ */
591
+ map<B extends Type>(f: (a: A) => B): Stack<B>
592
+
593
+ /**
594
+ * Maps each element to a Stack and flattens the result
595
+ * @param f - The mapping function returning a Stack
596
+ * @returns A new flattened Stack
597
+ */
598
+ flatMap<B extends Type>(f: (a: A) => Stack<B>): Stack<B>
599
+
600
+ /**
601
+ * Applies a Stack of functions to this Stack
602
+ * @param ff - Stack of functions to apply
603
+ * @returns A new Stack with applied functions
604
+ */
605
+ ap<B extends Type>(ff: Stack<(value: A) => B>): Stack<B>
606
+
607
+ /**
608
+ * Maps each element to an async Stack and flattens the result
609
+ * @param f - The async mapping function returning a Stack
610
+ * @returns A promise of the new flattened Stack
611
+ */
612
+ flatMapAsync<B extends Type>(f: (value: A) => PromiseLike<Stack<B>>): PromiseLike<Stack<B>>
613
+
614
+ /**
615
+ * Convert the stack to a List
616
+ * @returns A List containing all elements
617
+ */
618
+ toList(): List<A>
619
+
620
+ /**
621
+ * Convert the stack to an array
622
+ * @returns An array of all elements
623
+ */
624
+ toArray(): A[]
625
+
626
+ /**
627
+ * Returns a string representation of the stack
628
+ * @returns A string representation
629
+ */
630
+ toString(): string
631
+
632
+ /**
633
+ * Pattern matches over the Stack, applying a handler function based on whether it's empty
634
+ * @param patterns - Object with handler functions for Empty and NonEmpty variants
635
+ * @returns The result of applying the matching handler function
636
+ */
637
+ match<R>(patterns: { Empty: () => R; NonEmpty: (values: A[]) => R }): R
638
+ } & Traversable<A> &`};export{e as a,t as i,r as n,n as r,i as t};