functype 0.58.0 → 0.59.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.
@@ -15,7 +15,7 @@ type Type = unknown;
15
15
  *
16
16
  * @typeParam A - The type of elements in the data structure
17
17
  */
18
- interface Foldable<A> {
18
+ interface Foldable<out A> {
19
19
  /**
20
20
  * Left-associative fold using the provided zero value and operation
21
21
  * @param z - Zero/identity value
@@ -35,7 +35,7 @@ interface Foldable<A> {
35
35
  * Pipe interface for functional data structures
36
36
  * @typeParam T - The type of value to pipe
37
37
  */
38
- interface Pipe<T extends Type> {
38
+ interface Pipe<out T extends Type> {
39
39
  /**
40
40
  * Pipes the value through the provided function
41
41
  * @param f - The function to apply to the value
@@ -54,7 +54,7 @@ interface SerializationMethods<T> {
54
54
  toYAML(): string;
55
55
  toBinary(): string;
56
56
  }
57
- interface Serializable<T> {
57
+ interface Serializable<out T> {
58
58
  serialize(): SerializationMethods<T>;
59
59
  }
60
60
  //#endregion
@@ -1 +1 @@
1
- import{a as e,i as t,n,r,t as i}from"../full-interfaces-CiSsM7TZ.js";export{n as CATEGORIES,i as FULL_INTERFACES,r as INTERFACES,t as TYPES,e as VERSION};
1
+ import{a as e,i as t,n,r,t as i}from"../full-interfaces-B2NCRIHu.js";export{n as CATEGORIES,i as FULL_INTERFACES,r as INTERFACES,t as TYPES,e as VERSION};
package/dist/cli/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import{Dt as e,K as t,et as n}from"../src-Dfm6mrTr.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-CiSsM7TZ.js";const c=()=>{let n=t([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return t(Object.entries(a)).foldLeft(n)((n,[r,a])=>{let o=n.add(r.toUpperCase());return t(a).foldLeft(o)((t,n)=>e(i[n]).fold(()=>t,e=>{let r=e.interfaces.length>0?` [${e.interfaces.join(`, `)}]`:``;return t.add(` ${n}${r}`).add(` ${e.description}`)})).add(``)}).concat(t([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
3
- `)},l=(n,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=t([`create`,`transform`,`extract`,`check`,`other`]),o=t([`${n}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((n,i)=>e(r.methods[i]).filter(e=>e.length>0).fold(()=>n,e=>{let r=n.add(i.toUpperCase());return t(e).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
4
- `).trimEnd()},u=()=>{let e=t([`INTERFACES`,``]);return t(Object.entries(o)).foldLeft(e)((e,[n,r])=>{let i=r.extends?` extends ${r.extends}`:``,a=e.add(`${n}<A>${i}`).add(` ${r.description}`);return t(r.methods).foldLeft(a)((e,t)=>e.add(` ${t}`)).add(``)}).toArray().join(`
5
- `).trimEnd()},d=e=>JSON.stringify(e,null,2),f=()=>({version:r,categories:a,types:i}),p=n=>e(i[n]).map(e=>({name:n,data:e})).or(t(Object.entries(i)).find(([e])=>e.toLowerCase()===n.toLowerCase()).map(([e,t])=>({name:e,data:t}))).orUndefined(),m=()=>Object.keys(i),h=()=>o,g=e=>{let n=t(e.slice(2));return{flags:{json:n.contains(`--json`),full:n.contains(`--full`),help:n.exists(e=>e===`--help`||e===`-h`)},args:n.filter(e=>!e.startsWith(`--`)&&e!==`-h`)}},_=n=>e(s[n]).or(t(Object.entries(s)).find(([e])=>e.toLowerCase()===n.toLowerCase()).map(([,e])=>e)),v=()=>{let e=t([`FULL INTERFACE DEFINITIONS`,`=`.repeat(60),``]);return t(Object.entries(s)).foldLeft(e)((e,[n,r])=>e.concat(t([`// ${n}`,r,``,`-`.repeat(60),``]))).toArray().join(`
2
+ import{J as e,kt as t,yt as n}from"../src-Co3npRp-.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-B2NCRIHu.js";const c=()=>{let e=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(a)).foldLeft(e)((e,[r,a])=>{let o=e.add(r.toUpperCase());return n(a).foldLeft(o)((e,n)=>t(i[n]).fold(()=>e,t=>{let r=t.interfaces.length>0?` [${t.interfaces.join(`, `)}]`:``;return e.add(` ${n}${r}`).add(` ${t.description}`)})).add(``)}).concat(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
3
+ `)},l=(e,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=n([`create`,`transform`,`extract`,`check`,`other`]),o=n([`${e}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((e,i)=>t(r.methods[i]).filter(e=>e.length>0).fold(()=>e,t=>{let r=e.add(i.toUpperCase());return n(t).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
4
+ `).trimEnd()},u=()=>{let e=n([`INTERFACES`,``]);return n(Object.entries(o)).foldLeft(e)((e,[t,r])=>{let i=r.extends?` extends ${r.extends}`:``,a=e.add(`${t}<A>${i}`).add(` ${r.description}`);return n(r.methods).foldLeft(a)((e,t)=>e.add(` ${t}`)).add(``)}).toArray().join(`
5
+ `).trimEnd()},d=e=>JSON.stringify(e,null,2),f=()=>({version:r,categories:a,types:i}),p=e=>t(i[e]).map(t=>({name:e,data:t})).or(n(Object.entries(i)).find(([t])=>t.toLowerCase()===e.toLowerCase()).map(([e,t])=>({name:e,data:t}))).orUndefined(),m=()=>Object.keys(i),h=()=>o,g=e=>{let t=n(e.slice(2));return{flags:{json:t.contains(`--json`),full:t.contains(`--full`),help:t.exists(e=>e===`--help`||e===`-h`)},args:t.filter(e=>!e.startsWith(`--`)&&e!==`-h`)}},_=e=>t(s[e]).or(n(Object.entries(s)).find(([t])=>t.toLowerCase()===e.toLowerCase()).map(([,e])=>e)),v=()=>{let e=n([`FULL INTERFACE DEFINITIONS`,`=`.repeat(60),``]);return n(Object.entries(s)).foldLeft(e)((e,[t,r])=>e.concat(n([`// ${t}`,r,``,`-`.repeat(60),``]))).toArray().join(`
6
6
  `).trimEnd()},y=()=>{console.log(`functype - API documentation for LLMs
7
7
 
8
8
  USAGE
@@ -24,4 +24,4 @@ EXAMPLES
24
24
  npx functype Option --json # Option as JSON
25
25
  npx functype Option --full # Full TypeScript interface
26
26
  npx functype --full # All full interfaces (large output!)
27
- `)},b=e=>{console.error(`Unknown type: ${e}`),console.error(``),console.error(`Available types: ${m().join(`, `)}`),console.error(``),console.error(`Use: npx functype interfaces - for interface reference`),process.exit(1)},x=e=>console.log(e),S=(t,n)=>e(p(t)).fold(()=>b(t),e=>{n.full?_(e.name).fold(()=>x(n.json?d({[e.name]:e.data}):l(e.name,e.data)),t=>x(n.json?d({[e.name]:{...e.data,fullInterface:t}}):t)):x(n.json?d({[e.name]:e.data}):l(e.name,e.data))});(()=>{let{flags:e,args:t}=g(process.argv);n(!0).when(()=>e.help,()=>y()).when(()=>t.isEmpty,()=>e.full?x(e.json?d(s):v()):x(e.json?d(f()):c())).when(()=>t.headOption.contains(`interfaces`),()=>x(e.json?d(h()):u())).default(()=>t.headOption.fold(()=>x(e.json?d(f()):c()),t=>S(t,e)))})();
27
+ `)},b=e=>{console.error(`Unknown type: ${e}`),console.error(``),console.error(`Available types: ${m().join(`, `)}`),console.error(``),console.error(`Use: npx functype interfaces - for interface reference`),process.exit(1)},x=e=>console.log(e),S=(e,n)=>t(p(e)).fold(()=>b(e),e=>{n.full?_(e.name).fold(()=>x(n.json?d({[e.name]:e.data}):l(e.name,e.data)),t=>x(n.json?d({[e.name]:{...e.data,fullInterface:t}}):t)):x(n.json?d({[e.name]:e.data}):l(e.name,e.data))});(()=>{let{flags:t,args:n}=g(process.argv);e(!0).when(()=>t.help,()=>y()).when(()=>n.isEmpty,()=>t.full?x(t.json?d(s):v()):x(t.json?d(f()):c())).when(()=>n.headOption.contains(`interfaces`),()=>x(t.json?d(h()):u())).default(()=>n.headOption.fold(()=>x(t.json?d(f()):c()),e=>S(e,t)))})();
@@ -1,2 +1,2 @@
1
- import { a as EmptyListError, c as LeftError, cr as Doable, d as isDoCapable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, sr as DoResult, t as $, u as NoneError } from "../index-nHF45wRc.js";
1
+ import { a as EmptyListError, c as LeftError, d as isDoCapable, dr as Doable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, t as $, u as NoneError, ur as DoResult } from "../index-DeOx26aF.js";
2
2
  export { $, Do, DoAsync, DoGenerator, DoResult, Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
package/dist/do/index.js CHANGED
@@ -1 +1 @@
1
- import{B as e,F as t,I as n,L as r,M as i,N as a,P as o,R as s,z as c}from"../src-Dfm6mrTr.js";export{i as $,a as Do,o as DoAsync,t as EmptyListError,n as FailureError,r as LeftError,s as NoneError,c as isDoCapable,e as unwrap};
1
+ import{F as e,I as t,L as n,M as r,N as i,P as a,R as o,j as s,z as c}from"../src-Co3npRp-.js";export{s as $,r as Do,i as DoAsync,a as EmptyListError,e as FailureError,t as LeftError,n as NoneError,o as isDoCapable,c as unwrap};
@@ -1,2 +1,2 @@
1
- import { C as isRight, S as isLeft, T as tryCatchAsync, _ as Right, b as TypeCheckLeft, g as LeftOf, h as Left, m as EitherBase, p as Either, v as RightOf, w as tryCatch, x as TypeCheckRight, y as TestEither } from "../index-nHF45wRc.js";
1
+ import { C as isRight, S as isLeft, T as tryCatchAsync, _ as Right, b as TypeCheckLeft, g as LeftOf, h as Left, m as EitherBase, p as Either, v as RightOf, w as tryCatch, x as TypeCheckRight, y as TestEither } from "../index-DeOx26aF.js";
2
2
  export { Either, EitherBase, Left, LeftOf, Right, RightOf, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
@@ -1 +1 @@
1
- import{Ct as e,St as t,_t as n,bt as r,gt as i,vt as a,wt as o,xt as s,yt as c}from"../src-Dfm6mrTr.js";export{i as Either,n as Left,a as Right,c as TypeCheckLeft,r as TypeCheckRight,s as isLeft,t as isRight,e as tryCatch,o as tryCatchAsync};
1
+ import{_t as e,dt as t,ft as n,gt as r,ht as i,mt as a,pt as o,ut as s,vt as c}from"../src-Co3npRp-.js";export{s as Either,t as Left,n as Right,o as TypeCheckLeft,a as TypeCheckRight,i as isLeft,r as isRight,e as tryCatch,c as tryCatchAsync};
@@ -1,5 +1,5 @@
1
- const e=`0.58.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)`,`.foldAsync(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)`,`Either.void()`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.foldAsync(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)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(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`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:[`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`,`Reshapeable`,`Doable`],methods:{create:[`Obj({...})`,`Obj.of({...})`,`Obj.empty()`],transform:[`.set(k, v)`,`.assign(partial)`,`.merge(obj)`,`.when(cond, partial)`,`.omit(...keys)`,`.pick(...keys)`,`.map(f)`,`.flatMap(f)`],extract:[`.get(k)`,`.value()`,`.keys()`,`.values()`,`.entries()`,`.fold(n, s)`,`.match({Obj})`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:[`KVTraversable`,`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 tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:[],methods:{create:[`Task(params).Async(fn, errFn)`,`Task(params).Sync(fn, errFn)`,`Task.ok(value)`,`Task.err(error)`,`Task.fromEither(either)`,`Task.fromTry(try)`,`Task.fromPromise(fn)`,`Task.fromNodeCallback(fn)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},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`]}},Http:{description:`HTTP fetch wrapper returning IO<never, HttpError, HttpResponse<unknown>> by default. Provide a validate function to get typed responses (BYOV: bring your own validator). Works with Zod, TypeBox, Valibot, or manual validators.`,interfaces:[],methods:{create:[`Http.get(url, { validate }?)`,`Http.post(url, { body, validate }?)`,`Http.put(url, { body, validate }?)`,`Http.patch(url, { body, validate }?)`,`Http.delete(url, { validate }?)`,`Http.request({ url, validate })`,`Http.client(config)`],transform:[`.map(f)`,`.flatMap(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.mapError(f)`,`.recover(fallback)`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError`,interfaces:[],methods:{create:[`HttpError.networkError(url, method, cause)`,`HttpError.httpStatusError(url, method, status, statusText, body)`,`HttpError.decodeError(url, method, body, cause)`],check:[`HttpError.isNetworkError(e)`,`HttpError.isHttpStatusError(e)`,`HttpError.isDecodeError(e)`],other:[`HttpError.match(error, { NetworkError, HttpStatusError, DecodeError })`]}}},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`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`Http`,`HttpError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},i={Option:`export interface Option<out T extends Type>
2
- extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Omit<Reshapeable<T>, "toList"> {
1
+ const e=`0.59.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)`,`.foldAsync(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)`,`Either.void()`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.foldAsync(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)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(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`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:[`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`,`Reshapeable`,`Doable`],methods:{create:[`Obj({...})`,`Obj.of({...})`,`Obj.empty()`],transform:[`.set(k, v)`,`.assign(partial)`,`.merge(obj)`,`.when(cond, partial)`,`.omit(...keys)`,`.pick(...keys)`,`.map(f)`,`.flatMap(f)`],extract:[`.get(k)`,`.value()`,`.keys()`,`.values()`,`.entries()`,`.fold(n, s)`,`.match({Obj})`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:[`KVTraversable`,`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 tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:[],methods:{create:[`Task(params).Async(fn, errFn)`,`Task(params).Sync(fn, errFn)`,`Task.ok(value)`,`Task.err(error)`,`Task.fromEither(either)`,`Task.fromTry(try)`,`Task.fromPromise(fn)`,`Task.fromNodeCallback(fn)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},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`]}},Http:{description:`HTTP fetch wrapper returning IO<never, HttpError, HttpResponse<unknown>> by default. Provide a validate function to get typed responses (BYOV: bring your own validator). Works with Zod, TypeBox, Valibot, or manual validators.`,interfaces:[],methods:{create:[`Http.get(url, { validate }?)`,`Http.post(url, { body, validate }?)`,`Http.put(url, { body, validate }?)`,`Http.patch(url, { body, validate }?)`,`Http.delete(url, { validate }?)`,`Http.request({ url, validate })`,`Http.client(config)`],transform:[`.map(f)`,`.flatMap(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.mapError(f)`,`.recover(fallback)`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError`,interfaces:[],methods:{create:[`HttpError.networkError(url, method, cause)`,`HttpError.httpStatusError(url, method, status, statusText, body)`,`HttpError.decodeError(url, method, body, cause)`],check:[`HttpError.isNetworkError(e)`,`HttpError.isHttpStatusError(e)`,`HttpError.isDecodeError(e)`],other:[`HttpError.match(error, { NetworkError, HttpStatusError, DecodeError })`]}}},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`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`Http`,`HttpError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},i={Option:`export interface Option<out T extends Type>
2
+ extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
3
3
  /** The contained value (undefined for None) */
4
4
  readonly value: T | undefined
5
5
  /** Whether this Option contains no value */
@@ -75,18 +75,6 @@ const e=`0.58.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
75
75
  * @returns Promise of the result of applying f to the contained value, or None if this Option is None
76
76
  */
77
77
  flatMapAsync<U extends Type>(f: (value: T) => Promise<Option<U>>): Promise<Option<U>>
78
- /**
79
- * Applies a binary operator to a start value and the contained value
80
- * @param f - The binary operator
81
- * @returns The result of the reduction
82
- */
83
- reduce<U>(f: (acc: U, value: T) => U): U
84
- /**
85
- * Applies a binary operator to the contained value and a start value
86
- * @param f - The binary operator
87
- * @returns The result of the reduction
88
- */
89
- reduceRight<U>(f: (acc: U, value: T) => U): U
90
78
  /**
91
79
  * Pattern matches over the Option, applying onNone if None and onSome if Some
92
80
  * @param onNone - Function to apply if the Option is None
@@ -117,6 +105,11 @@ const e=`0.58.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
117
105
  * @returns true if this Option contains the value, false otherwise
118
106
  */
119
107
  contains(value: T): boolean
108
+ /**
109
+ * Converts this Option to a List.
110
+ * @returns A List containing the value if Some, or empty List if None
111
+ */
112
+ toList(): List<T>
120
113
  /** The number of elements in this Option (0 or 1) */
121
114
  size: number
122
115
  /**
@@ -177,6 +170,7 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
177
170
  ): Promise<Either<L | L2, U>> =>
178
171
  f(value).catch((error: unknown) => Left<L | L2, U>(error as L | L2)) as Promise<Either<L | L2, U>>,
179
172
  toOption: () => Some<R>(value),
173
+ toList: () => List<R>([value]),
180
174
  toEither: <E extends Type>(_leftValue: E) => Right<E, R>(value),
181
175
  toTry: () => Try(() => value),
182
176
  toJSON() {
@@ -230,12 +224,7 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
230
224
  })
231
225
 
232
226
  export interface EitherBase<out L extends Type, out R extends Type>
233
- extends
234
- FunctypeSum<R, "Left" | "Right">,
235
- Promisable<R>,
236
- Doable<R>,
237
- Omit<Reshapeable<R>, "toList">,
238
- Omit<Extractable<R>, "or" | "orElse"> {
227
+ extends FunctypeSum<R, "Left" | "Right">, Promisable<R>, Doable<R>, Reshapeable<R>, Extractable<R> {
239
228
  isLeft(): this is LeftOf<L, R>
240
229
  isRight(): this is RightOf<L, R>
241
230
  orElse<R2 extends Type>(defaultValue: R2): R | R2
@@ -297,13 +286,7 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
297
286
  readonly _tag: "Right"
298
287
  readonly value: R
299
288
  }`,Try:`export interface Try<out T>
300
- extends
301
- FunctypeSum<T, TypeNames>,
302
- Omit<Extractable<T>, "or" | "orElse">,
303
- Pipe<T>,
304
- Promisable<T>,
305
- Doable<T>,
306
- Omit<Reshapeable<T>, "toList"> {
289
+ extends FunctypeSum<T, TypeNames>, Extractable<T>, Pipe<T>, Promisable<T>, Doable<T>, Reshapeable<T> {
307
290
  readonly _tag: TypeNames
308
291
  readonly error: Error | undefined
309
292
  isSuccess(): this is Try<T> & { readonly _tag: "Success"; error: undefined }
@@ -354,7 +337,7 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
354
337
  */
355
338
  recoverWith<U extends Type>(f: (error: Error) => Try<U>): Try<T | U>
356
339
  toValue(): { _tag: TypeNames; value: T | Error }
357
- }`,List:`export interface List<A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<A> {
340
+ }`,List:`export interface List<out A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<A> {
358
341
  readonly length: number
359
342
  readonly [Symbol.iterator]: () => Iterator<A>
360
343
  // Override these to return List instead of FunctypeCollection
@@ -369,11 +352,14 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
369
352
  // List-specific methods
370
353
  /** @internal */
371
354
  filterType: <T extends Typeable<string, unknown>>(tag: string) => List<T & A>
372
- remove: (value: A) => List<A>
355
+ /** Remove a value. Accepts \`unknown\` so an unrelated-type arg is a safe no-op (Scala: \`-(elem: Any)\`). */
356
+ remove: (value: unknown) => List<A>
373
357
  removeAt: (index: number) => List<A>
374
- add: (item: A) => List<A>
358
+ /** Add a value, possibly widening the element type (Scala: \`:+[B >: A]\`). */
359
+ add<B>(item: B): List<A | B>
375
360
  get: (index: number) => Option<A>
376
- concat: (other: List<A>) => List<A>
361
+ /** Concatenate with another list, possibly widening (Scala: \`++[B >: A]\`). */
362
+ concat<B>(other: List<B>): List<A | B>
377
363
  take: (n: number) => List<A>
378
364
  takeWhile: (p: (a: A) => boolean) => List<A>
379
365
  takeRight: (n: number) => List<A>
@@ -382,8 +368,10 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
382
368
  get tail(): List<A>
383
369
  get init(): List<A>
384
370
  reverse: () => List<A>
385
- indexOf: (value: A) => number
386
- prepend: (item: A) => List<A>
371
+ /** Find the index of a value. Accepts \`unknown\` (Scala: \`indexOf(elem: Any)\`). */
372
+ indexOf: (value: unknown) => number
373
+ /** Prepend a value, possibly widening (Scala: \`+:[B >: A]\`). */
374
+ prepend<B>(item: B): List<A | B>
387
375
  distinct: () => List<A>
388
376
  sorted: (compareFn?: (a: A, b: A) => number) => List<A>
389
377
  sortBy: <B>(f: (a: A) => B, compareFn?: (a: B, b: B) => number) => List<A>
@@ -399,11 +387,10 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
399
387
  * @returns The result of applying the matching handler function
400
388
  */
401
389
  match<R>(patterns: { Empty: () => R; NonEmpty: (values: A[]) => R }): R
402
- }`,Set:`export interface Set<A> extends FunctypeCollection<A, "Set">, Collection<A> {
403
- add: (value: A) => Set<A>
404
- remove: (value: A) => Set<A>
405
- contains: (value: A) => boolean
406
- has: (value: A) => boolean
390
+ }`,Set:`export interface Set<out A> extends FunctypeCollection<A, "Set">, Collection<A> {
391
+ add<B>(value: B): Set<A | B>
392
+ remove: (value: unknown) => Set<A>
393
+ has(value: unknown): boolean
407
394
  map: <B>(f: (a: A) => B) => Set<B>
408
395
  flatMap: <B>(f: (a: A) => Iterable<B>) => Set<B>
409
396
  filter: (p: (a: A) => boolean) => Set<A>
@@ -449,11 +436,10 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
449
436
  /** Whether the computation has been evaluated */
450
437
  readonly isEvaluated: boolean
451
438
  /**
452
- * Returns the computed value or a default value if computation fails
453
- * @param defaultValue - The value to return if computation fails
454
- * @returns The computed value or defaultValue
439
+ * Returns the computed value or a default value if computation fails.
440
+ * Result widens to \`T | T2\` (Scala: \`getOrElse[B >: A](default: B): B\`).
455
441
  */
456
- orElse(defaultValue: T): T
442
+ orElse<T2 extends Type>(defaultValue: T2): T | T2
457
443
  /**
458
444
  * Returns the computed value or null if computation fails
459
445
  * @returns The computed value or null
@@ -467,11 +453,10 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
467
453
  */
468
454
  orThrow(error?: Error): T
469
455
  /**
470
- * Returns this Lazy if computation succeeds, otherwise returns the alternative Lazy
471
- * @param alternative - The alternative Lazy to use if computation fails
472
- * @returns This Lazy or the alternative
456
+ * Returns this Lazy if computation succeeds, otherwise returns the alternative Lazy.
457
+ * The alternative may carry a different type; result is \`Lazy<T | T2>\`.
473
458
  */
474
- or(alternative: Lazy<T>): Lazy<T>
459
+ or<T2 extends Type>(alternative: Lazy<T2>): Lazy<T | T2>
475
460
  /**
476
461
  * Maps the value inside the Lazy using the provided function
477
462
  * @param f - The mapping function