functype 1.4.4 → 1.5.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 +1 @@
1
- import{a as e,i as t,n,r,t as i}from"../full-interfaces-CgFN2CY5.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-ByZleoi8.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,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{At as e,Q as t,St as n}from"../src-DCf63AzV.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-CgFN2CY5.js";const c=()=>{let t=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(a)).foldLeft(t)((t,[r,a])=>{let o=t.add(r.toUpperCase());return n(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(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
2
+ import{At as e,Q as t,St as n}from"../src-4UEC-cVf.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-ByZleoi8.js";const c=()=>{let t=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(a)).foldLeft(t)((t,[r,a])=>{let o=t.add(r.toUpperCase());return n(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(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
3
3
  `)},l=(t,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=n([`create`,`transform`,`extract`,`check`,`other`]),o=n([`${t}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((t,i)=>e(r.methods[i]).filter(e=>e.length>0).fold(()=>t,e=>{let r=t.add(i.toUpperCase());return n(e).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
4
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
5
  `).trimEnd()},d=e=>JSON.stringify(e,null,2),f=()=>({version:r,categories:a,types:i}),p=t=>e(i[t]).map(e=>({name:t,data:e})).or(n(Object.entries(i)).find(([e])=>e.toLowerCase()===t.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`)}},_=t=>e(s[t]).or(n(Object.entries(s)).find(([e])=>e.toLowerCase()===t.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(`
@@ -1,2 +1,2 @@
1
- import { Tr as Cond, n as UntypedMatch, t as Match } from "../index-Xwjf0L5u.js";
1
+ import { Tr as Cond, n as UntypedMatch, t as Match } from "../index-CGVJBR_H.js";
2
2
  export { Cond, Match, UntypedMatch };
@@ -1 +1 @@
1
- import{$ as e,Q as t}from"../src-DCf63AzV.js";export{e as Cond,t as Match};
1
+ import{$ as e,Q as t}from"../src-4UEC-cVf.js";export{e as Cond,t as Match};
@@ -1,2 +1,2 @@
1
- import { $t as TaskResult, Gt as Ok, Ht as CancellationToken, Jt as Task, Kt as Sync, Qt as TaskParams, Ut as CancellationTokenSource, Vt as Async, Wt as Err, Xt as TaskMetadata, Yt as TaskFailure, Zt as TaskOutcome, en as TaskSuccess, nn as isTaggedThrowable, qt as TaggedThrowable, tn as createCancellationTokenSource } from "../../index-Xwjf0L5u.js";
1
+ import { $t as TaskResult, Gt as Ok, Ht as CancellationToken, Jt as Task, Kt as Sync, Qt as TaskParams, Ut as CancellationTokenSource, Vt as Async, Wt as Err, Xt as TaskMetadata, Yt as TaskFailure, Zt as TaskOutcome, en as TaskSuccess, nn as isTaggedThrowable, qt as TaggedThrowable, tn as createCancellationTokenSource } from "../../index-CGVJBR_H.js";
2
2
  export { Async, CancellationToken, CancellationTokenSource, Err, Ok, Sync, TaggedThrowable, Task, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, createCancellationTokenSource, isTaggedThrowable };
@@ -1 +1 @@
1
- import{G as e,J as t,K as n,W as r,q as i}from"../../src-DCf63AzV.js";export{r as Err,e as Ok,n as Task,i as createCancellationTokenSource,t as isTaggedThrowable};
1
+ import{G as e,J as t,K as n,W as r,q as i}from"../../src-4UEC-cVf.js";export{r as Err,e as Ok,n as Task,i as createCancellationTokenSource,t as isTaggedThrowable};
@@ -1,2 +1,2 @@
1
- import { Bt as DecoderErrorLeaf, Lt as Decoder, Rt as DecoderError, zt as DecoderErrorComposite } from "../index-Xwjf0L5u.js";
1
+ import { Bt as DecoderErrorLeaf, Lt as Decoder, Rt as DecoderError, zt as DecoderErrorComposite } from "../index-CGVJBR_H.js";
2
2
  export { Decoder, DecoderError, type DecoderErrorComposite, type DecoderErrorLeaf };
@@ -1 +1 @@
1
- import{B as e,V as t}from"../src-DCf63AzV.js";export{e as Decoder,t as DecoderError};
1
+ import{B as e,V as t}from"../src-4UEC-cVf.js";export{e as Decoder,t as DecoderError};
@@ -1,2 +1,2 @@
1
- import { At as FailureError, Cr as DoResult, Dt as DoAsync, Et as Do, Ft as isDoCapable, It as unwrap, Mt as LeftError, Nt as LeftErrorType, Ot as DoGenerator, Pt as NoneError, Tt as $, jt as FailureErrorType, kt as EmptyListError, wr as Doable } from "../index-Xwjf0L5u.js";
1
+ import { At as FailureError, Cr as DoResult, Dt as DoAsync, Et as Do, Ft as isDoCapable, It as unwrap, Mt as LeftError, Nt as LeftErrorType, Ot as DoGenerator, Pt as NoneError, Tt as $, jt as FailureErrorType, kt as EmptyListError, wr as Doable } from "../index-CGVJBR_H.js";
2
2
  export { $, Do, DoAsync, DoGenerator, type DoResult, type Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
package/dist/do/index.js CHANGED
@@ -1 +1 @@
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-DCf63AzV.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
+ 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-4UEC-cVf.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 { $n as Left, Qn as EitherBase, Zn as Either, ar as TypeCheckRight, cr as tryCatch, er as LeftOf, ir as TypeCheckLeft, lr as tryCatchAsync, nr as RightOf, or as isLeft, rr as TestEither, sr as isRight, tr as Right } from "../index-Xwjf0L5u.js";
1
+ import { $n as Left, Qn as EitherBase, Zn as Either, ar as TypeCheckRight, cr as tryCatch, er as LeftOf, ir as TypeCheckLeft, lr as tryCatchAsync, nr as RightOf, or as isLeft, rr as TestEither, sr as isRight, tr as Right } from "../index-CGVJBR_H.js";
2
2
  export { Either, EitherBase, Left, LeftOf, Right, RightOf, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
@@ -1 +1 @@
1
- import{_t as e,bt as t,gt as n,ht as r,mt as i,pt as a,vt as o,xt as s,yt as c}from"../src-DCf63AzV.js";export{a as Either,i as Left,r as Right,n as TypeCheckLeft,e as TypeCheckRight,o as isLeft,c as isRight,t as tryCatch,s as tryCatchAsync};
1
+ import{_t as e,bt as t,gt as n,ht as r,mt as i,pt as a,vt as o,xt as s,yt as c}from"../src-4UEC-cVf.js";export{a as Either,i as Left,r as Right,n as TypeCheckLeft,e as TypeCheckRight,o as isLeft,c as isRight,t as tryCatch,s as tryCatchAsync};
@@ -1,2 +1,2 @@
1
- import { A as HttpQueryParams, B as ResponseDecodeError, D as HttpClient, E as Http, F as DecodeError, I as HttpError, L as HttpMethod, M as HttpRequestView, N as HttpResponse, O as HttpClientConfig, P as ParseMode, R as HttpStatusError, j as HttpRequestOptions, k as HttpMethodOptions, z as NetworkError } from "../index-Xwjf0L5u.js";
1
+ import { A as HttpQueryParams, B as ResponseDecodeError, D as HttpClient, E as Http, F as DecodeError, I as HttpError, L as HttpMethod, M as HttpRequestView, N as HttpResponse, O as HttpClientConfig, P as ParseMode, R as HttpStatusError, j as HttpRequestOptions, k as HttpMethodOptions, z as NetworkError } from "../index-CGVJBR_H.js";
2
2
  export { type DecodeError, Http, HttpClient, type HttpClientConfig, type HttpError, HttpError as HttpErrors, type HttpMethod, type HttpMethodOptions, type HttpQueryParams, type HttpRequestOptions, type HttpRequestView, type HttpResponse, type HttpStatusError, type NetworkError, type ParseMode, type ResponseDecodeError };
@@ -1 +1 @@
1
- import{d as e,f as t,u as n}from"../src-DCf63AzV.js";export{n as Http,t as HttpClient,e as HttpErrors};
1
+ import{d as e,f as t,u as n}from"../src-4UEC-cVf.js";export{n as Http,t as HttpClient,e as HttpErrors};
@@ -1,4 +1,4 @@
1
- var e=`1.4.4`;const t={Option:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Matchable`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`,`Traversable`],Either:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],Try:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],List:[`Collection`,`Doable`,`Iterable`,`Reshapeable`],Set:[`Collection`,`Iterable`],Map:[`Collection`,`Foldable`,`Iterable`,`KVTraversable`,`Serializable`],Obj:[`Doable`,`Promisable`,`Reshapeable`],Lazy:[`Applicative`,`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Serializable`,`Traversable`],LazyList:[`Foldable`,`Serializable`],Tuple:[`Foldable`,`Serializable`],Task:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Serializable`,`Traversable`]},n=e,r=(e,...n)=>Array.from(new Set([...t[e],...n])).sort(),i={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:r(`Option`),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()`,`.expect(() => never)`,`.orNull()`,`.match({Some, None})`,`.toEither(left | () => left)`,`.toList()`,`.toArray()`],check:[`.isSome()`,`.isNone()`,`.isEmpty`],other:[`Option.sequence(arr)`,`Option.traverse(arr, f)`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:r(`Either`,`Traversable`),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()`,`.expect((l) => never)`,`.match({Left, Right})`],check:[`.isRight()`,`.isLeft()`],other:[`Either.sequence(arr)`,`Either.traverse(arr, f)`,`Either.fromNullable(v, e)`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:r(`Try`,`Matchable`,`Traversable`),methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`,`Try.async(() => Promise<T>)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(f, s)`,`.orElse(d)`,`.orThrow()`,`.expect((e) => never)`,`.toOption()`,`.toEither(left | (err) => left)`,`.toList()`,`.toArray()`],check:[`.isSuccess()`,`.isFailure()`],other:[`Try.sequence(arr)`,`Try.traverse(arr, f)`]}},List:{description:`Immutable array with functional operations`,interfaces:r(`List`,`Functor`,`Monad`,`Foldable`,`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:r(`Set`,`Functor`,`Foldable`,`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:r(`Obj`,`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`),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:r(`Map`),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. Note: `serialize()` and `toValue()` FORCE the thunk (visible side effect) since a closure cannot be JSON-serialized — there is no representable 'unevaluated post-serialize' state. Thunk failures are captured via SerializedError and rethrown on access after fromJSON.",interfaces:r(`Lazy`),methods:{create:[`Lazy(() => expr)`,`Lazy.fromValue(value) — wrap a non-deferred value`,`Lazy.evaluated(value) — reads as 'already-forced'; used by fromJSON`,`Lazy.fail(error) — Lazy that throws on access`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`,`.toJSON()`,`Lazy.fromJSON(json)`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:r(`LazyList`,`Functor`,`Monad`,`Iterable`),methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`,`LazyList.fromJSON(json)`],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()`,`.toJSON()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:r(`Task`),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)`,`Task.fromJSON(json) — reconstruct from serialize() output`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},TaskOutcome:{description:`Result of a Task execution — Ok<T> or Err<T>. Implements Functor, AsyncMonad, Foldable, Extractable, Serializable. Construct via Ok(v) / Err(e) or as the resolved value of Task(...).Sync() / Task(...).Async().`,interfaces:[`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Serializable`],methods:{create:[`Ok(value)`,`Err(error)`,`Task.ok(value)`,`Task.err(error)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`,`.mapAsync(f)`,`.flatMapAsync(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],check:[`.isOk()`,`.isErr()`,`.isSuccess()`,`.isFailure()`]}},TaskResult:{description:"Type alias for `Promise<TaskOutcome<T>>`. Returned by Task(params).Async(...) and adapter functions like Fs.readFile, Process.exec. Await it to get the inner TaskOutcome; chain Promise methods on the outside, TaskOutcome methods after the await.",interfaces:[],methods:{create:[`Task(params).Async(fn, errFn) → TaskResult<T>`,`Task.fromPromise(fn) → (...args) => TaskResult<U>`],other:[`await taskResult → TaskOutcome<T>`,`// then use any TaskOutcome method (.fold, .map, .toEither, ...)`]}},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)`,`.retryWhile({ n, while, delayMs? })`,`.retryWithBackoff({ n, baseMs, maxMs?, factor?, jitter?, while? })`,`.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:r(`Tuple`,`Typeable`,`Valuable`,`Iterable`),methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`,`Tuple.fromJSON(json)`],extract:[`.first`,`.second`,`.toArray()`,`.toJSON()`],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<T>>. Pass `decode: Decoder<T>` (Either-returning) for typed responses; the deprecated `validate: (data) => T` field is still accepted for throw-pattern back-compat. Request bodies auto-flatten functype ADTs to primitives; `flatten: false` preserves tagged emission for functype-to-functype services. Per-call `params` (HttpQueryParams) appends query strings with proper encoding. Http.client accepts `beforeRequest` and `afterResponse` (both effectful IO transformers). `afterResponse` runs on the success path only — error handling belongs in .catchTag. Composes via .tap/.map/.flatMap/.catchTag/.retry/.retryWhile/.retryWithBackoff/.timeout.",interfaces:[],methods:{create:[`Http.get(url, { decode, params }?)`,`Http.post(url, { body, decode, params }?)`,`Http.put(url, { body, decode, params }?)`,`Http.patch(url, { body, decode, params }?)`,`Http.delete(url, { decode, params }?)`,`Http.request({ url, decode, params })`,`Http.client({ baseUrl, defaultHeaders, fetch, beforeRequest, afterResponse })`],transform:[`.tap(f)`,`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.retryWhile({ n, while, delayMs? })`,`.retryWithBackoff({ n, baseMs, maxMs?, factor?, jitter?, while? })`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`,`.runExit()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.recover(fallback)`,`decode: Decoder<T> (Either-returning, structural failures preserved)`,`validate: (data) => T (deprecated, throws — for back-compat / Zod .parse)`,`flatten: boolean (default true; false preserves tagged emission)`,`params: HttpQueryParams (scalar | array; undefined/null dropped; percent-encoded)`,`beforeRequest: (req) => IO<never, HttpError, HttpRequestView>`,`afterResponse: (HttpResponse<unknown>) => IO<never, HttpError, HttpResponse<unknown>> — success path only; refresh-on-401 uses .catchTag`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError (also exported as ResponseDecodeError alias)`,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 })`]}},Decoder:{description:"Either-returning decoder contract: `Decoder<A> = (raw: unknown) => Either<DecoderError, A>`. Bundled combinators for primitives + functype ADTs (Option/Either/List/Map, null-bias). `Decoder.tagged.*` round-trips the `{_tag, value}` shape for functype-to-functype services.",interfaces:[],methods:{create:[`Decoder.string / .number / .boolean / .unknown / .nullable(inner)`,`Decoder.option(inner)`,`Decoder.either.envelope({ok, err})`,`Decoder.either.discriminated({tag, leftTag, rightTag}, l, r)`,`Decoder.list(inner) / .array(inner) / .map(inner)`,`Decoder.object({k: Decoder<V>, ...}) — accumulates field failures into Composite`,`Decoder.tagged.option/either/try/list/map/obj(inner?) — round-trips {_tag, value}`],other:[`Pluggable by construction: any (raw) => Either<DecoderError, T> IS a Decoder<T>`,`Composes across sources: Decoder.object({a: Decoder.fromZod(s), b: Decoder.option(myAjv)})`]}},DecoderError:{description:"Recursive ADT for decoder failures: Leaf | Composite. Children mirror the input tree so multi-field failures preserve structural paths. Distinct from `HttpError.DecodeError` — this is the inner structural cause that the HTTP wrapper carries.",interfaces:[],methods:{create:[`DecoderError.leaf(path, message, cause?)`,`DecoderError.composite(path, children: List<DecoderError>)`],check:[`DecoderError.isLeaf(e)`,`DecoderError.isComposite(e)`],other:[`DecoderError.match(e, { Leaf, Composite })`,`DecoderError.prepend(segment, e) — used by combinators to attribute child failures`,`DecoderError.flatten(e): List<{path, message}> — collect leaves`,`DecoderError.format(e): string — render tree as multi-line`]}},Serialization:{description:"Universal `@functype`-marked JSON serialization. `deserialize` walks parsed JSON and reconstructs any functype value found — no type argument needed. Lenient: plain JSON passes through. Strict on unknown markers (defends against Effect/fp-ts `_tag` collision). 1.2.1 adds `toEnvelope`/`fromEnvelope` for nesting inside structured serializers (SuperJSON, DBOS), and `deserializeStrict` for boundaries that require functype on the wire.",interfaces:[],methods:{create:[],transform:[`Serialization.serialize(value: unknown): string — lenient JSON codec`,`Serialization.deserialize(json: string): Try<unknown> — lenient; pass-through for unmarked JSON`,`Serialization.deserializeStrict(json: string): Try<unknown> — Failure if no @functype marker at top level`,`Serialization.toEnvelope(value: unknown): JSONValue — parsed JSON shape (1.2.2 tightened from unknown)`,`Serialization.fromEnvelope(envelope: unknown): Try<unknown> — inverse of toEnvelope; input stays permissive (Postel's law)`,`Serialization.JSONValue — exported recursive type for the envelope shape`],check:[`Serialization.isFunctypeValue(v): v is Serializable<unknown>`],other:[`Plain JSON passthrough: non-functype data walks through unchanged (use deserializeStrict to reject)`,`Strict policy on unknown markers: unknown @functype marker → Try.Failure`,`Dispatch table covers all 12 Serializable types (Option, Either, Try, List, Set, Map, Obj, Stack, Tuple, LazyList, Lazy, Task)`,`Algebraic square: serialize ≡ JSON.stringify ∘ toEnvelope; deserialize ≡ fromEnvelope ∘ JSON.parse`,`No DBOS / SuperJSON facade — consumers wire host serializer in ~8 lines via toEnvelope/fromEnvelope`]}},SerializedError:{description:"Canonical Error projection used by Try.Failure, Task.Err, Lazy-with-thrown-thunk. Round-trips name + message + stack + cause chain. `e.name === 'TypeError'` survives; `instanceof TypeError` does NOT.",interfaces:[],methods:{create:[`serializeError(err: unknown): SerializedError`,`deserializeError(s: SerializedError | string): Error`],other:[`Shape: { name: string; message: string; stack?: string; cause?: SerializedError | string }`,`Non-Error throwables (strings, plain objects) projected under name: 'NonErrorThrowable'`,`Cause chain is recursive — arbitrary nesting depth survives`]}},Logger:{description:'Minimal 4-method ecosystem-wide logging interface (1.3.0+). Type-only — no runtime, no `console` dependency, no opinion on output format. Every functype-* package targets this shape. Reachable from the top barrel (`import type { Logger } from "functype"`) and the `functype/logger` subpath. Concrete impls live in consumer packages: `consoleBootLogger` in `functype-os/config`, `DirectLogger` from `functype-log/direct` (structurally satisfies Logger — no adapter). Clock/Random/Tracer NOT being added — those are framework abstractions; Logger is uniquely justified because every production TS app already has one.',interfaces:[],methods:{create:[`interface Logger { debug, info, warn, error: (msg, meta?) => void }`,`import type { Logger } from "functype"`],check:[],other:[`All 4 methods MANDATORY (no defensive logger.debug?.() at call sites)`,`Signature: (message: string, metadata?: Record<string, unknown>) => void`,`DirectLogger from functype-log/direct structurally satisfies Logger (superset shape)`,`IO-shaped Logger from functype-log does NOT satisfy core Logger (methods return IO<>, not void) — bridge via toDirectLogger(ioLogger)`,`Used by: bootDiagnostics({ logger? }) in functype-os/config`]}}},a={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`,`.expect(handler: (e?) => never): 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`]}},o={Core:[`Option`,`Either`,`Try`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`TaskOutcome`,`TaskResult`,`Http`,`HttpError`,`Decoder`,`DecoderError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`],Serialization:[`Serialization`,`SerializedError`],Service:[`Logger`]},s={Option:`export interface Option<out T extends Type>
1
+ var e=`1.5.0`;const t={Option:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Matchable`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`,`Traversable`],Either:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],Try:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],List:[`Collection`,`Doable`,`Iterable`,`Reshapeable`],Set:[`Collection`,`Iterable`],Map:[`Collection`,`Foldable`,`Iterable`,`KVTraversable`,`Serializable`],Obj:[`Doable`,`Promisable`,`Reshapeable`],Lazy:[`Applicative`,`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Serializable`,`Traversable`],LazyList:[`Foldable`,`Serializable`],Tuple:[`Foldable`,`Serializable`],Task:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Serializable`,`Traversable`]},n=e,r=(e,...n)=>Array.from(new Set([...t[e],...n])).sort(),i={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:r(`Option`),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()`,`.expect(() => never)`,`.orNull()`,`.match({Some, None})`,`.toEither(left | () => left)`,`.toList()`,`.toArray()`],check:[`.isSome()`,`.isNone()`,`.isEmpty`],other:[`Option.sequence(arr)`,`Option.traverse(arr, f)`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:r(`Either`,`Traversable`),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()`,`.expect((l) => never)`,`.match({Left, Right})`],check:[`.isRight()`,`.isLeft()`],other:[`Either.sequence(arr)`,`Either.traverse(arr, f)`,`Either.fromNullable(v, e)`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:r(`Try`,`Matchable`,`Traversable`),methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`,`Try.async(() => Promise<T>)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(f, s)`,`.orElse(d)`,`.orThrow()`,`.expect((e) => never)`,`.toOption()`,`.toEither(left | (err) => left)`,`.toList()`,`.toArray()`],check:[`.isSuccess()`,`.isFailure()`],other:[`Try.sequence(arr)`,`Try.traverse(arr, f)`]}},List:{description:`Immutable array with functional operations`,interfaces:r(`List`,`Functor`,`Monad`,`Foldable`,`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:r(`Set`,`Functor`,`Foldable`,`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:r(`Obj`,`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`),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:r(`Map`),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. Note: `serialize()` and `toValue()` FORCE the thunk (visible side effect) since a closure cannot be JSON-serialized — there is no representable 'unevaluated post-serialize' state. Thunk failures are captured via SerializedError and rethrown on access after fromJSON.",interfaces:r(`Lazy`),methods:{create:[`Lazy(() => expr)`,`Lazy.fromValue(value) — wrap a non-deferred value`,`Lazy.evaluated(value) — reads as 'already-forced'; used by fromJSON`,`Lazy.fail(error) — Lazy that throws on access`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`,`.toJSON()`,`Lazy.fromJSON(json)`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:r(`LazyList`,`Functor`,`Monad`,`Iterable`),methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`,`LazyList.fromJSON(json)`],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()`,`.toJSON()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:r(`Task`),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)`,`Task.fromJSON(json) — reconstruct from serialize() output`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},TaskOutcome:{description:`Result of a Task execution — Ok<T> or Err<T>. Implements Functor, AsyncMonad, Foldable, Extractable, Serializable. Construct via Ok(v) / Err(e) or as the resolved value of Task(...).Sync() / Task(...).Async().`,interfaces:[`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Serializable`],methods:{create:[`Ok(value)`,`Err(error)`,`Task.ok(value)`,`Task.err(error)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`,`.mapAsync(f)`,`.flatMapAsync(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],check:[`.isOk()`,`.isErr()`,`.isSuccess()`,`.isFailure()`]}},TaskResult:{description:"Type alias for `Promise<TaskOutcome<T>>`. Returned by Task(params).Async(...) and adapter functions like Fs.readFile, Process.exec. Await it to get the inner TaskOutcome; chain Promise methods on the outside, TaskOutcome methods after the await.",interfaces:[],methods:{create:[`Task(params).Async(fn, errFn) → TaskResult<T>`,`Task.fromPromise(fn) → (...args) => TaskResult<U>`],other:[`await taskResult → TaskOutcome<T>`,`// then use any TaskOutcome method (.fold, .map, .toEither, ...)`]}},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)`,`.retryWhile({ n, while, delayMs? })`,`.retryWithBackoff({ n, baseMs, maxMs?, factor?, jitter?, while? })`,`.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:r(`Tuple`,`Typeable`,`Valuable`,`Iterable`),methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`,`Tuple.fromJSON(json)`],extract:[`.first`,`.second`,`.toArray()`,`.toJSON()`],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<T>>. Pass `decode: Decoder<T>` (Either-returning) for typed responses; the deprecated `validate: (data) => T` field is still accepted for throw-pattern back-compat. Request bodies auto-flatten functype ADTs to primitives; `flatten: false` preserves tagged emission for functype-to-functype services. Per-call `params` (HttpQueryParams) appends query strings with proper encoding. Http.client accepts `beforeRequest` and `afterResponse` (both effectful IO transformers). `afterResponse` runs on the success path only — error handling belongs in .catchTag. Composes via .tap/.map/.flatMap/.catchTag/.retry/.retryWhile/.retryWithBackoff/.timeout.",interfaces:[],methods:{create:[`Http.get(url, { decode, params }?)`,`Http.post(url, { body, decode, params }?)`,`Http.put(url, { body, decode, params }?)`,`Http.patch(url, { body, decode, params }?)`,`Http.delete(url, { decode, params }?)`,`Http.request({ url, decode, params })`,`Http.client({ baseUrl, defaultHeaders, fetch, beforeRequest, afterResponse })`],transform:[`.tap(f)`,`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.retryWhile({ n, while, delayMs? })`,`.retryWithBackoff({ n, baseMs, maxMs?, factor?, jitter?, while? })`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`,`.runExit()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.recover(fallback)`,`decode: Decoder<T> (Either-returning, structural failures preserved)`,`validate: (data) => T (deprecated, throws — for back-compat / Zod .parse)`,`flatten: boolean (default true; false preserves tagged emission)`,`params: HttpQueryParams (scalar | array; undefined/null dropped; percent-encoded)`,`beforeRequest: (req) => IO<never, HttpError, HttpRequestView>`,`afterResponse: (HttpResponse<unknown>) => IO<never, HttpError, HttpResponse<unknown>> — success path only; refresh-on-401 uses .catchTag`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError (also exported as ResponseDecodeError alias)`,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 })`]}},Decoder:{description:"Either-returning decoder contract: `Decoder<A> = (raw: unknown) => Either<DecoderError, A>`. Bundled combinators for primitives + functype ADTs (Option/Either/List/Map, null-bias). `Decoder.tagged.*` round-trips the `{_tag, value}` shape for functype-to-functype services.",interfaces:[],methods:{create:[`Decoder.string / .number / .boolean / .unknown / .nullable(inner)`,`Decoder.option(inner)`,`Decoder.either.envelope({ok, err})`,`Decoder.either.discriminated({tag, leftTag, rightTag}, l, r)`,`Decoder.list(inner) / .array(inner) / .map(inner)`,`Decoder.object({k: Decoder<V>, ...}) — accumulates field failures into Composite`,`Decoder.tagged.option/either/try/list/map/obj(inner?) — round-trips {_tag, value}`],other:[`Pluggable by construction: any (raw) => Either<DecoderError, T> IS a Decoder<T>`,`Composes across sources: Decoder.object({a: Decoder.fromZod(s), b: Decoder.option(myAjv)})`]}},DecoderError:{description:"Recursive ADT for decoder failures: Leaf | Composite. Children mirror the input tree so multi-field failures preserve structural paths. Distinct from `HttpError.DecodeError` — this is the inner structural cause that the HTTP wrapper carries.",interfaces:[],methods:{create:[`DecoderError.leaf(path, message, cause?)`,`DecoderError.composite(path, children: List<DecoderError>)`],check:[`DecoderError.isLeaf(e)`,`DecoderError.isComposite(e)`],other:[`DecoderError.match(e, { Leaf, Composite })`,`DecoderError.prepend(segment, e) — used by combinators to attribute child failures`,`DecoderError.flatten(e): List<{path, message}> — collect leaves`,`DecoderError.format(e): string — render tree as multi-line`]}},Serialization:{description:"Universal `@functype`-marked JSON serialization. `deserialize` walks parsed JSON and reconstructs any functype value found — no type argument needed. Lenient: plain JSON passes through. Strict on unknown markers (defends against Effect/fp-ts `_tag` collision). 1.2.1 adds `toEnvelope`/`fromEnvelope` for nesting inside structured serializers (SuperJSON, DBOS), and `deserializeStrict` for boundaries that require functype on the wire.",interfaces:[],methods:{create:[],transform:[`Serialization.serialize(value: unknown): string — lenient JSON codec`,`Serialization.deserialize(json: string): Try<unknown> — lenient; pass-through for unmarked JSON`,`Serialization.deserializeStrict(json: string): Try<unknown> — Failure if no @functype marker at top level`,`Serialization.toEnvelope(value: unknown): JSONValue — parsed JSON shape (1.2.2 tightened from unknown)`,`Serialization.fromEnvelope(envelope: unknown): Try<unknown> — inverse of toEnvelope; input stays permissive (Postel's law)`,`Serialization.JSONValue — exported recursive type for the envelope shape`],check:[`Serialization.isFunctypeValue(v): v is Serializable<unknown>`],other:[`Plain JSON passthrough: non-functype data walks through unchanged (use deserializeStrict to reject)`,`Strict policy on unknown markers: unknown @functype marker → Try.Failure`,`Dispatch table covers all 12 Serializable types (Option, Either, Try, List, Set, Map, Obj, Stack, Tuple, LazyList, Lazy, Task)`,`Algebraic square: serialize ≡ JSON.stringify ∘ toEnvelope; deserialize ≡ fromEnvelope ∘ JSON.parse`,`No DBOS / SuperJSON facade — consumers wire host serializer in ~8 lines via toEnvelope/fromEnvelope`]}},SerializedError:{description:"Canonical Error projection used by Try.Failure, Task.Err, Lazy-with-thrown-thunk. Round-trips name + message + stack + cause chain. `e.name === 'TypeError'` survives; `instanceof TypeError` does NOT.",interfaces:[],methods:{create:[`serializeError(err: unknown): SerializedError`,`deserializeError(s: SerializedError | string): Error`],other:[`Shape: { name: string; message: string; stack?: string; cause?: SerializedError | string }`,`Non-Error throwables (strings, plain objects) projected under name: 'NonErrorThrowable'`,`Cause chain is recursive — arbitrary nesting depth survives`]}},Logger:{description:'Minimal 4-method ecosystem-wide logging interface (1.3.0+). Type-only — no runtime, no `console` dependency, no opinion on output format. Every functype-* package targets this shape. Reachable from the top barrel (`import type { Logger } from "functype"`) and the `functype/logger` subpath. Concrete impls live in consumer packages: `consoleBootLogger` in `functype-os/config`, `DirectLogger` from `functype-log/direct` (structurally satisfies Logger — no adapter). Clock/Random/Tracer NOT being added — those are framework abstractions; Logger is uniquely justified because every production TS app already has one.',interfaces:[],methods:{create:[`interface Logger { debug, info, warn, error: (msg, meta?) => void }`,`import type { Logger } from "functype"`],check:[],other:[`All 4 methods MANDATORY (no defensive logger.debug?.() at call sites)`,`Signature: (message: string, metadata?: Record<string, unknown>) => void`,`DirectLogger from functype-log/direct structurally satisfies Logger (superset shape)`,`IO-shaped Logger from functype-log does NOT satisfy core Logger (methods return IO<>, not void) — bridge via toDirectLogger(ioLogger)`,`Used by: bootDiagnostics({ logger? }) in functype-os/config`]}}},a={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`,`.expect(handler: (e?) => never): 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`]}},o={Core:[`Option`,`Either`,`Try`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`TaskOutcome`,`TaskResult`,`Http`,`HttpError`,`Decoder`,`DecoderError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`],Serialization:[`Serialization`,`SerializedError`],Service:[`Logger`]},s={Option:`export interface Option<out T extends Type>
2
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
@@ -220,6 +220,10 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
220
220
  },
221
221
  tapLeft: (_f: (value: L) => void) => Right<L, R>(value),
222
222
  mapLeft: <L2 extends Type>(_f: (value: L) => L2) => Right<L2, R>(value),
223
+ filterOrElse: <L2 extends Type>(
224
+ predicate: (value: R) => boolean,
225
+ onUnsatisfied: (value: R) => L2,
226
+ ): Either<L | L2, R> => (predicate(value) ? Right<L | L2, R>(value) : Left<L | L2, R>(onUnsatisfied(value))),
223
227
  bimap: <L2 extends Type, R2 extends Type>(_fl: (value: L) => L2, fr: (value: R) => R2) => Right<L2, R2>(fr(value)),
224
228
  fold: <T extends Type>(_onLeft: (value: L) => T, onRight: (value: R) => T) => onRight(value),
225
229
  foldAsync: async <T extends Type>(_onLeft: (value: L) => T | Promise<T>, onRight: (value: R) => T | Promise<T>) =>
@@ -279,6 +283,19 @@ export interface EitherBase<out L extends Type, out R extends Type>
279
283
  tap: (f: (value: R) => void) => Either<L, R>
280
284
  tapLeft: (f: (value: L) => void) => Either<L, R>
281
285
  mapLeft: <L2 extends Type>(f: (value: L) => L2) => Either<L2, R>
286
+ /**
287
+ * Applies a predicate to the Right value. If the predicate fails, short-circuits
288
+ * to a Left carrying the value produced by \`onUnsatisfied\`. Left passes through
289
+ * unchanged (predicate not evaluated). Lets you turn a value-level guard into the
290
+ * Left channel without breaking the chain with an \`if/return Left(...)\` ladder.
291
+ * @param predicate - The predicate to test the Right value
292
+ * @param onUnsatisfied - Builds the new Left value when the predicate fails
293
+ * @returns Right if the predicate holds, Left(onUnsatisfied(value)) otherwise
294
+ */
295
+ filterOrElse: <L2 extends Type>(
296
+ predicate: (value: R) => boolean,
297
+ onUnsatisfied: (value: R) => L2,
298
+ ) => Either<L | L2, R>
282
299
  bimap: <L2 extends Type, R2 extends Type>(fl: (value: L) => L2, fr: (value: R) => R2) => Either<L2, R2>
283
300
  fold: <T extends Type>(onLeft: (value: L) => T, onRight: (value: R) => T) => T
284
301
  /**
@@ -395,6 +412,16 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
395
412
  * As with \`recover\`, the recovery Try may carry a wider type; the result widens accordingly.
396
413
  */
397
414
  recoverWith<U extends Type>(f: (error: Error) => Try<U>): Try<T | U>
415
+ /**
416
+ * Applies a predicate to the success value. If the predicate fails, short-circuits
417
+ * to a Failure with the error produced by \`onUnsatisfied\`. Failure passes through
418
+ * unchanged (predicate not evaluated). Lets you turn a value-level guard into the
419
+ * error channel without writing a manual \`throw\` inside a \`Try(() => ...)\` body.
420
+ * @param predicate - The predicate to test the success value
421
+ * @param onUnsatisfied - Builds the Error for the new Failure when the predicate fails
422
+ * @returns A Success if the predicate holds, a Failure carrying \`onUnsatisfied(value)\` otherwise
423
+ */
424
+ filterOrElse(predicate: (value: T) => boolean, onUnsatisfied: (value: T) => Error): Try<T>
398
425
  toValue(): { _tag: TypeNames; value: T | Error }
399
426
  /**
400
427
  * Custom JSON serialization. Success emits \`{"@functype":"Try","_tag":"Success","value":T}\`.
@@ -1,2 +1,2 @@
1
- import { Cn as FunctypeBase, Sn as Functype, wn as FunctypeCollection, xn as FunctypeSum } from "../index-Xwjf0L5u.js";
1
+ import { Cn as FunctypeBase, Sn as Functype, wn as FunctypeCollection, xn as FunctypeSum } from "../index-CGVJBR_H.js";
2
2
  export { Functype, FunctypeBase, FunctypeCollection, FunctypeSum };
@@ -522,6 +522,16 @@ interface EitherBase<out L extends Type, out R extends Type> extends FunctypeSum
522
522
  tap: (f: (value: R) => void) => Either<L, R>;
523
523
  tapLeft: (f: (value: L) => void) => Either<L, R>;
524
524
  mapLeft: <L2 extends Type>(f: (value: L) => L2) => Either<L2, R>;
525
+ /**
526
+ * Applies a predicate to the Right value. If the predicate fails, short-circuits
527
+ * to a Left carrying the value produced by `onUnsatisfied`. Left passes through
528
+ * unchanged (predicate not evaluated). Lets you turn a value-level guard into the
529
+ * Left channel without breaking the chain with an `if/return Left(...)` ladder.
530
+ * @param predicate - The predicate to test the Right value
531
+ * @param onUnsatisfied - Builds the new Left value when the predicate fails
532
+ * @returns Right if the predicate holds, Left(onUnsatisfied(value)) otherwise
533
+ */
534
+ filterOrElse: <L2 extends Type>(predicate: (value: R) => boolean, onUnsatisfied: (value: R) => L2) => Either<L | L2, R>;
525
535
  bimap: <L2 extends Type, R2 extends Type>(fl: (value: L) => L2, fr: (value: R) => R2) => Either<L2, R2>;
526
536
  fold: <T extends Type>(onLeft: (value: L) => T, onRight: (value: R) => T) => T;
527
537
  /**
@@ -1227,6 +1237,16 @@ interface Try<out T> extends FunctypeSum<T, TypeNames>, Extractable<T>, Pipe<T>,
1227
1237
  * As with `recover`, the recovery Try may carry a wider type; the result widens accordingly.
1228
1238
  */
1229
1239
  recoverWith<U extends Type>(f: (error: Error) => Try<U>): Try<T | U>;
1240
+ /**
1241
+ * Applies a predicate to the success value. If the predicate fails, short-circuits
1242
+ * to a Failure with the error produced by `onUnsatisfied`. Failure passes through
1243
+ * unchanged (predicate not evaluated). Lets you turn a value-level guard into the
1244
+ * error channel without writing a manual `throw` inside a `Try(() => ...)` body.
1245
+ * @param predicate - The predicate to test the success value
1246
+ * @param onUnsatisfied - Builds the Error for the new Failure when the predicate fails
1247
+ * @returns A Success if the predicate holds, a Failure carrying `onUnsatisfied(value)` otherwise
1248
+ */
1249
+ filterOrElse(predicate: (value: T) => boolean, onUnsatisfied: (value: T) => Error): Try<T>;
1230
1250
  toValue(): {
1231
1251
  _tag: TypeNames;
1232
1252
  value: T | Error;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as ExtractBrand, c as hasBrand, i as BrandedString, l as unwrapBrand, n as BrandedBoolean, o as Unwrap, r as BrandedNumber, s as createBrander, t as Brand } from "./Brand-bfnGXuum.js";
2
2
  import { i as Companion, n as InstanceType, r as isCompanion, t as CompanionMethods } from "./CompanionTypes-CAxuM7qS.js";
3
3
  import { a as isTypeable, c as SerializationMethods, d as Type, i as TypeableParams, l as Pipe, n as ExtractTag, o as Serializable, r as Typeable, s as SerializableEnvelope, t as Tuple, u as Foldable } from "./Tuple-8yRldBty.js";
4
- import { $ as LayerOutput, $n as Left, $t as TaskResult, A as HttpQueryParams, An as List, At as FailureError, B as ResponseDecodeError, Bn as createSerializer, Bt as DecoderErrorLeaf, C as TryKind, Cn as FunctypeBase, Cr as DoResult, Ct as formatStackTrace, D as HttpClient, Dn as MatchableUtils, Dt as DoAsync, E as Http, En as Matchable, Et as Do, F as DecodeError, Fn as FUNCTYPE_MARKER, Ft as isDoCapable, G as InterruptedError, Gn as fromYAML, Gt as Ok, H as TestClockTag, Hn as envelope, Ht as CancellationToken, I as HttpError, In as FunctypeEnvelope, It as unwrap, J as TimeoutError, Jn as deserializeError, Jt as Task$1, K as RIO, Kn as taggedEnvelope, Kt as Sync, L as HttpMethod, Ln as SerializationResult, Lt as Decoder, M as HttpRequestView, Mn as TypeNames, Mt as LeftError, N as HttpResponse, Nn as JSONValue, Nt as LeftErrorType, O as HttpClientConfig, On as Collection, Ot as DoGenerator, P as ParseMode, Pn as Serialization_d_exports, Pt as NoneError, Q as LayerInput, Qn as EitherBase, Qt as TaskParams, R as HttpStatusError, Rn as createCustomSerializer, Rt as DecoderError, S as OptionKind, Sn as Functype, Sr as ParseError, St as formatError, T as FoldableUtils, Tn as Traversable, Tr as Cond, Tt as $, U as TestContext, Un as fromBinary, Ut as CancellationTokenSource, V as TestClock, Vn as createTaggedSerializer, Vt as Async, W as IO, Wn as fromJSON, Wt as Err, X as Layer, Xn as LazyList, Xt as TaskMetadata, Y as UIO, Yn as serializeError, Yt as TaskFailure, Z as LayerError, Zn as Either, Zt as TaskOutcome, _ as Identity, _n as UUID, _r as Monad, _t as ErrorChainElement, a as OptionConstructor, an as ThrowableType, ar as TypeCheckRight, at as Tag, b as Kind, bn as ValidatedBrandCompanion, br as Extractable, bt as TaskErrorInfo, c as Valuable, cn as BoundedString, cr as tryCatch, ct as FormValidation, d as Obj, dn as IntegerNumber, dr as reduceRightWiden, dt as Validator, en as TaskSuccess, er as LeftOf, et as Exit, f as ESMap, fn as NonEmptyString, fr as reduceWiden, ft as ErrorCode, g as Lazy, gn as PositiveNumber, gr as Functor, gt as TypedErrorContext, h as KVTraversable, hn as PositiveInteger, hr as AsyncMonad, ht as TypedError, i as Option, in as Throwable, ir as TypeCheckLeft, it as HasService, j as HttpRequestOptions, jn as Try, jt as FailureErrorType, k as HttpMethodOptions, kn as Set, kt as EmptyListError, l as ValuableParams, ln as EmailAddress, lr as tryCatchAsync, lt as Validation, m as Map, mn as PatternString, mr as Applicative, mt as ErrorStatus, n as UntypedMatch, nn as isTaggedThrowable, nr as RightOf, nt as Context, o as Some, on as Base, or as isLeft, ot as TagService, p as ESMapType, pn as NonNegativeNumber, pr as Promisable, pt as ErrorMessage, q as Task, qn as SerializedError, qt as TaggedThrowable, r as None, rn as NAME, rr as TestEither, rt as ContextServices, s as Stack, sn as BoundedNumber, sr as isRight, st as FieldValidation, t as Match, tn as createCancellationTokenSource, tr as Right, tt as ExitTag, u as Ref, un as ISO8601Date, ur as Widen, ut as ValidationRule, v as EitherKind, vn as UrlString, vr as CollectionOps, vt as ErrorFormatterOptions, w as UniversalContainer, wn as FunctypeCollection, wr as Doable, wt as safeStringify, x as ListKind, xn as FunctypeSum, xr as isExtractable, xt as createErrorSerializer, y as HKT, yn as ValidatedBrand, yr as ContainerOps, yt as ErrorWithTaskInfo, z as NetworkError, zn as createSerializationCompanion, zt as DecoderErrorComposite } from "./index-Xwjf0L5u.js";
4
+ import { $ as LayerOutput, $n as Left, $t as TaskResult, A as HttpQueryParams, An as List, At as FailureError, B as ResponseDecodeError, Bn as createSerializer, Bt as DecoderErrorLeaf, C as TryKind, Cn as FunctypeBase, Cr as DoResult, Ct as formatStackTrace, D as HttpClient, Dn as MatchableUtils, Dt as DoAsync, E as Http, En as Matchable, Et as Do, F as DecodeError, Fn as FUNCTYPE_MARKER, Ft as isDoCapable, G as InterruptedError, Gn as fromYAML, Gt as Ok, H as TestClockTag, Hn as envelope, Ht as CancellationToken, I as HttpError, In as FunctypeEnvelope, It as unwrap, J as TimeoutError, Jn as deserializeError, Jt as Task$1, K as RIO, Kn as taggedEnvelope, Kt as Sync, L as HttpMethod, Ln as SerializationResult, Lt as Decoder, M as HttpRequestView, Mn as TypeNames, Mt as LeftError, N as HttpResponse, Nn as JSONValue, Nt as LeftErrorType, O as HttpClientConfig, On as Collection, Ot as DoGenerator, P as ParseMode, Pn as Serialization_d_exports, Pt as NoneError, Q as LayerInput, Qn as EitherBase, Qt as TaskParams, R as HttpStatusError, Rn as createCustomSerializer, Rt as DecoderError, S as OptionKind, Sn as Functype, Sr as ParseError, St as formatError, T as FoldableUtils, Tn as Traversable, Tr as Cond, Tt as $, U as TestContext, Un as fromBinary, Ut as CancellationTokenSource, V as TestClock, Vn as createTaggedSerializer, Vt as Async, W as IO, Wn as fromJSON, Wt as Err, X as Layer, Xn as LazyList, Xt as TaskMetadata, Y as UIO, Yn as serializeError, Yt as TaskFailure, Z as LayerError, Zn as Either, Zt as TaskOutcome, _ as Identity, _n as UUID, _r as Monad, _t as ErrorChainElement, a as OptionConstructor, an as ThrowableType, ar as TypeCheckRight, at as Tag, b as Kind, bn as ValidatedBrandCompanion, br as Extractable, bt as TaskErrorInfo, c as Valuable, cn as BoundedString, cr as tryCatch, ct as FormValidation, d as Obj, dn as IntegerNumber, dr as reduceRightWiden, dt as Validator, en as TaskSuccess, er as LeftOf, et as Exit, f as ESMap, fn as NonEmptyString, fr as reduceWiden, ft as ErrorCode, g as Lazy, gn as PositiveNumber, gr as Functor, gt as TypedErrorContext, h as KVTraversable, hn as PositiveInteger, hr as AsyncMonad, ht as TypedError, i as Option, in as Throwable, ir as TypeCheckLeft, it as HasService, j as HttpRequestOptions, jn as Try, jt as FailureErrorType, k as HttpMethodOptions, kn as Set, kt as EmptyListError, l as ValuableParams, ln as EmailAddress, lr as tryCatchAsync, lt as Validation, m as Map, mn as PatternString, mr as Applicative, mt as ErrorStatus, n as UntypedMatch, nn as isTaggedThrowable, nr as RightOf, nt as Context, o as Some, on as Base, or as isLeft, ot as TagService, p as ESMapType, pn as NonNegativeNumber, pr as Promisable, pt as ErrorMessage, q as Task, qn as SerializedError, qt as TaggedThrowable, r as None, rn as NAME, rr as TestEither, rt as ContextServices, s as Stack, sn as BoundedNumber, sr as isRight, st as FieldValidation, t as Match, tn as createCancellationTokenSource, tr as Right, tt as ExitTag, u as Ref, un as ISO8601Date, ur as Widen, ut as ValidationRule, v as EitherKind, vn as UrlString, vr as CollectionOps, vt as ErrorFormatterOptions, w as UniversalContainer, wn as FunctypeCollection, wr as Doable, wt as safeStringify, x as ListKind, xn as FunctypeSum, xr as isExtractable, xt as createErrorSerializer, y as HKT, yn as ValidatedBrand, yr as ContainerOps, yt as ErrorWithTaskInfo, z as NetworkError, zn as createSerializationCompanion, zt as DecoderErrorComposite } from "./index-CGVJBR_H.js";
5
5
  import { t as Logger } from "./Logger-BmprRS8v.js";
6
6
  export { $, type Applicative, Async, type AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, type BrandedBoolean as BrandedBooleanType, BrandedNumber, type BrandedNumber as BrandedNumberType, BrandedString, type BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, type CollectionOps, Companion, CompanionMethods, Cond, type ContainerOps, Context, type Context as ContextType, type ContextServices, type DecodeError, Decoder, DecoderError, type DecoderErrorComposite, type DecoderErrorLeaf, Do, DoAsync, DoGenerator, type DoResult, type Doable, ESMap, ESMapType, Either, EitherBase, EitherKind, EmailAddress, EmptyListError, Err, ErrorChainElement, ErrorCode, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, type Exit as ExitType, type ExitTag, type ExtractBrand, ExtractTag, type Extractable, FUNCTYPE_MARKER, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, type Functor, Functype, FunctypeBase, FunctypeCollection, FunctypeEnvelope, FunctypeSum, HKT, type HasService, Http, HttpClient, type HttpClientConfig, type HttpError, HttpError as HttpErrors, type HttpMethod, type HttpMethodOptions, type HttpQueryParams, type HttpRequestOptions, type HttpRequestView, type HttpResponse, type HttpStatusError, IO, type IO as IOType, type Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, type JSONValue, KVTraversable, Kind, Layer, type Layer as LayerType, type LayerError, type LayerInput, type LayerOutput, Lazy, type Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, LeftOf, List, ListKind, type Logger, Map, Match, type Matchable, MatchableUtils, type Monad, NAME, type NetworkError, NonEmptyString, NonNegativeNumber, None, NoneError, Obj, Ok, Option, OptionConstructor, OptionKind, ParseError, type ParseMode, PatternString, Pipe, PositiveInteger, PositiveNumber, type Promisable, type RIO, Ref, type Ref as RefType, type ResponseDecodeError, Right, RightOf, Serializable, SerializableEnvelope, Serialization_d_exports as Serialization, SerializationMethods, SerializationResult, SerializedError, Set, Some, Stack, Sync, Tag, type Tag as TagType, type TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, type TestClock as TestClockType, TestClockTag, TestContext, type TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, type UIO, UUID, UniversalContainer, UntypedMatch, type Unwrap, UrlString, ValidatedBrand, type ValidatedBrand as ValidatedBrandType, type ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, type Widen, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, createTaggedSerializer, deserializeError, envelope, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, reduceRightWiden, reduceWiden, safeStringify, serializeError, taggedEnvelope, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{t as s}from"./Companion-DiOMBHDG.js";import{a as c,c as l,d as u,f as d,i as f,l as p,n as m,o as h,r as g,s as _,t as v,u as y}from"./serialization-EQGLX3e3.js";import{$ as b,A as x,At as S,B as C,C as w,Ct as T,D as E,Dt as D,E as O,Et as k,F as A,G as j,H as M,I as N,J as P,K as F,L as I,M as L,Mt as R,N as z,O as B,Ot as V,P as H,Q as U,R as W,S as G,St as K,T as q,Tt as J,U as Y,V as X,W as Z,X as Q,Y as $,Z as ee,_ as te,_t as ne,a as re,at as ie,b as ae,bt as oe,c as se,ct as ce,d as le,dt as ue,et as de,f as fe,ft as pe,g as me,gt as he,h as ge,ht as _e,i as ve,it as ye,j as be,jt as xe,k as Se,kt as Ce,l as we,lt as Te,m as Ee,mt as De,n as Oe,nt as ke,o as Ae,ot as je,p as Me,pt as Ne,q as Pe,r as Fe,rt as Ie,s as Le,st as Re,t as ze,tt as Be,u as Ve,ut as He,v as Ue,vt as We,w as Ge,wt as Ke,x as qe,xt as Je,y as Ye,yt as Xe,z as Ze}from"./src-DCf63AzV.js";import{n as Qe,t as $e}from"./typeclass-C61yDVYd.js";import{t as et}from"./CompanionTypes-BVqO7Kc2.js";import{Tuple as tt}from"./tuple/index.js";export{be as $,ee as Base,de as BoundedNumber,Be as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,s as Companion,b as Cond,G as Context,C as Decoder,X as DecoderError,L as Do,z as DoAsync,Y as ESMap,Ne as Either,ke as EmailAddress,H as EmptyListError,Z as Err,qe as Exit,v as FUNCTYPE_MARKER,A as FailureError,we as FoldableUtils,se as HKT,Ve as Http,fe as HttpClient,le as HttpErrors,Ue as IO,Ie as ISO8601Date,Le as Identity,ye as IntegerNumber,Ye as InterruptedError,te as Layer,Ae as Lazy,k as LazyList,De as Left,N as LeftError,K as List,M as Map,U as Match,re as MatchableUtils,$ as NAME,ie as NonEmptyString,je as NonNegativeNumber,Ce as None,I as NoneError,ve as Obj,j as Ok,S as Option,xe as OptionConstructor,O as ParseError,Re as PatternString,ce as PositiveInteger,Te as PositiveNumber,D as Ref,_e as Right,Oe as Serialization,V as Set,R as Some,Fe as Stack,me as Tag,F as Task,Me as TestClock,Ee as TestClockTag,ge as TestContext,Q as Throwable,ae as TimeoutError,J as Try,tt as Tuple,he as TypeCheckLeft,ne as TypeCheckRight,T as Typeable,q as TypedError,He as UUID,ue as UrlString,pe as ValidatedBrand,Ge as Validation,ze as Valuable,i as createBrander,Pe as createCancellationTokenSource,m as createCustomSerializer,E as createErrorSerializer,g as createSerializationCompanion,f as createSerializer,c as createTaggedSerializer,u as deserializeError,h as envelope,B as formatError,Se as formatStackTrace,_ as fromBinary,l as fromJSON,p as fromYAML,a as hasBrand,et as isCompanion,W as isDoCapable,w as isExtractable,We as isLeft,Xe as isRight,P as isTaggedThrowable,Ke as isTypeable,$e as reduceRightWiden,Qe as reduceWiden,x as safeStringify,d as serializeError,y as taggedEnvelope,oe as tryCatch,Je as tryCatchAsync,Ze as unwrap,o as unwrapBrand};
1
+ import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{t as s}from"./Companion-DiOMBHDG.js";import{a as c,c as l,d as u,f as d,i as f,l as p,n as m,o as h,r as g,s as _,t as v,u as y}from"./serialization-EQGLX3e3.js";import{$ as b,A as x,At as S,B as C,C as w,Ct as T,D as E,Dt as D,E as O,Et as k,F as A,G as j,H as M,I as N,J as P,K as F,L as I,M as L,Mt as R,N as z,O as B,Ot as V,P as H,Q as U,R as W,S as G,St as K,T as q,Tt as J,U as Y,V as X,W as Z,X as Q,Y as $,Z as ee,_ as te,_t as ne,a as re,at as ie,b as ae,bt as oe,c as se,ct as ce,d as le,dt as ue,et as de,f as fe,ft as pe,g as me,gt as he,h as ge,ht as _e,i as ve,it as ye,j as be,jt as xe,k as Se,kt as Ce,l as we,lt as Te,m as Ee,mt as De,n as Oe,nt as ke,o as Ae,ot as je,p as Me,pt as Ne,q as Pe,r as Fe,rt as Ie,s as Le,st as Re,t as ze,tt as Be,u as Ve,ut as He,v as Ue,vt as We,w as Ge,wt as Ke,x as qe,xt as Je,y as Ye,yt as Xe,z as Ze}from"./src-4UEC-cVf.js";import{n as Qe,t as $e}from"./typeclass-C61yDVYd.js";import{t as et}from"./CompanionTypes-BVqO7Kc2.js";import{Tuple as tt}from"./tuple/index.js";export{be as $,ee as Base,de as BoundedNumber,Be as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,s as Companion,b as Cond,G as Context,C as Decoder,X as DecoderError,L as Do,z as DoAsync,Y as ESMap,Ne as Either,ke as EmailAddress,H as EmptyListError,Z as Err,qe as Exit,v as FUNCTYPE_MARKER,A as FailureError,we as FoldableUtils,se as HKT,Ve as Http,fe as HttpClient,le as HttpErrors,Ue as IO,Ie as ISO8601Date,Le as Identity,ye as IntegerNumber,Ye as InterruptedError,te as Layer,Ae as Lazy,k as LazyList,De as Left,N as LeftError,K as List,M as Map,U as Match,re as MatchableUtils,$ as NAME,ie as NonEmptyString,je as NonNegativeNumber,Ce as None,I as NoneError,ve as Obj,j as Ok,S as Option,xe as OptionConstructor,O as ParseError,Re as PatternString,ce as PositiveInteger,Te as PositiveNumber,D as Ref,_e as Right,Oe as Serialization,V as Set,R as Some,Fe as Stack,me as Tag,F as Task,Me as TestClock,Ee as TestClockTag,ge as TestContext,Q as Throwable,ae as TimeoutError,J as Try,tt as Tuple,he as TypeCheckLeft,ne as TypeCheckRight,T as Typeable,q as TypedError,He as UUID,ue as UrlString,pe as ValidatedBrand,Ge as Validation,ze as Valuable,i as createBrander,Pe as createCancellationTokenSource,m as createCustomSerializer,E as createErrorSerializer,g as createSerializationCompanion,f as createSerializer,c as createTaggedSerializer,u as deserializeError,h as envelope,B as formatError,Se as formatStackTrace,_ as fromBinary,l as fromJSON,p as fromYAML,a as hasBrand,et as isCompanion,W as isDoCapable,w as isExtractable,We as isLeft,Xe as isRight,P as isTaggedThrowable,Ke as isTypeable,$e as reduceRightWiden,Qe as reduceWiden,x as safeStringify,d as serializeError,y as taggedEnvelope,oe as tryCatch,Je as tryCatchAsync,Ze as unwrap,o as unwrapBrand};
@@ -1,2 +1,2 @@
1
- import { $ as LayerOutput, G as InterruptedError, H as TestClockTag, J as TimeoutError, K as RIO, Q as LayerInput, U as TestContext, V as TestClock, W as IO, X as Layer, Y as UIO, Z as LayerError, at as Tag, et as Exit, it as HasService, nt as Context, ot as TagService, q as Task, rt as ContextServices, tt as ExitTag } from "../index-Xwjf0L5u.js";
1
+ import { $ as LayerOutput, G as InterruptedError, H as TestClockTag, J as TimeoutError, K as RIO, Q as LayerInput, U as TestContext, V as TestClock, W as IO, X as Layer, Y as UIO, Z as LayerError, at as Tag, et as Exit, it as HasService, nt as Context, ot as TagService, q as Task, rt as ContextServices, tt as ExitTag } from "../index-CGVJBR_H.js";
2
2
  export { Context, type Context as ContextType, type ContextServices, Exit, type Exit as ExitType, type ExitTag, type HasService, IO, type IO as IOType, type Task as IOTask, InterruptedError, Layer, type Layer as LayerType, type LayerError, type LayerInput, type LayerOutput, type RIO, Tag, type Tag as TagType, type TagService, TestClock, type TestClock as TestClockType, TestClockTag, TestContext, type TestContext as TestContextType, TimeoutError, type UIO };
package/dist/io/index.js CHANGED
@@ -1 +1 @@
1
- import{S as e,_ as t,b as n,g as r,h as i,m as a,p as o,v as s,x as c,y as l}from"../src-DCf63AzV.js";export{e as Context,c as Exit,s as IO,l as InterruptedError,t as Layer,r as Tag,o as TestClock,a as TestClockTag,i as TestContext,n as TimeoutError};
1
+ import{S as e,_ as t,b as n,g as r,h as i,m as a,p as o,v as s,x as c,y as l}from"../src-4UEC-cVf.js";export{e as Context,c as Exit,s as IO,l as InterruptedError,t as Layer,r as Tag,o as TestClock,a as TestClockTag,i as TestContext,n as TimeoutError};
@@ -1,2 +1,2 @@
1
- import { g as Lazy } from "../index-Xwjf0L5u.js";
1
+ import { g as Lazy } from "../index-CGVJBR_H.js";
2
2
  export { Lazy, type Lazy as LazyType };
@@ -1 +1 @@
1
- import{o as e}from"../src-DCf63AzV.js";export{e as Lazy};
1
+ import{o as e}from"../src-4UEC-cVf.js";export{e as Lazy};
@@ -1,2 +1,2 @@
1
- import { An as List } from "../index-Xwjf0L5u.js";
1
+ import { An as List } from "../index-CGVJBR_H.js";
2
2
  export { List };
@@ -1 +1 @@
1
- import{St as e}from"../src-DCf63AzV.js";export{e as List};
1
+ import{St as e}from"../src-4UEC-cVf.js";export{e as List};
@@ -1,2 +1,2 @@
1
- import { m as Map } from "../index-Xwjf0L5u.js";
1
+ import { m as Map } from "../index-CGVJBR_H.js";
2
2
  export { Map };
package/dist/map/index.js CHANGED
@@ -1 +1 @@
1
- import{H as e}from"../src-DCf63AzV.js";export{e as Map};
1
+ import{H as e}from"../src-4UEC-cVf.js";export{e as Map};
@@ -1,2 +1,2 @@
1
- import { d as Obj } from "../index-Xwjf0L5u.js";
1
+ import { d as Obj } from "../index-CGVJBR_H.js";
2
2
  export { Obj };
package/dist/obj/index.js CHANGED
@@ -1 +1 @@
1
- import{i as e}from"../src-DCf63AzV.js";export{e as Obj};
1
+ import{i as e}from"../src-4UEC-cVf.js";export{e as Obj};
@@ -1,2 +1,2 @@
1
- import { a as OptionConstructor, i as Option, o as Some, r as None } from "../index-Xwjf0L5u.js";
1
+ import { a as OptionConstructor, i as Option, o as Some, r as None } from "../index-CGVJBR_H.js";
2
2
  export { None, Option, OptionConstructor, Some };
@@ -1 +1 @@
1
- import{At as e,Mt as t,jt as n,kt as r}from"../src-DCf63AzV.js";export{r as None,e as Option,n as OptionConstructor,t as Some};
1
+ import{At as e,Mt as t,jt as n,kt as r}from"../src-4UEC-cVf.js";export{r as None,e as Option,n as OptionConstructor,t as Some};
@@ -1,2 +1,2 @@
1
- import { Bn as createSerializer, Fn as FUNCTYPE_MARKER, Gn as fromYAML, Hn as envelope, In as FunctypeEnvelope, Jn as deserializeError, Kn as taggedEnvelope, Ln as SerializationResult, Nn as JSONValue, Rn as createCustomSerializer, Un as fromBinary, Vn as createTaggedSerializer, Wn as fromJSON, Yn as serializeError, qn as SerializedError, zn as createSerializationCompanion } from "../index-Xwjf0L5u.js";
1
+ import { Bn as createSerializer, Fn as FUNCTYPE_MARKER, Gn as fromYAML, Hn as envelope, In as FunctypeEnvelope, Jn as deserializeError, Kn as taggedEnvelope, Ln as SerializationResult, Nn as JSONValue, Rn as createCustomSerializer, Un as fromBinary, Vn as createTaggedSerializer, Wn as fromJSON, Yn as serializeError, qn as SerializedError, zn as createSerializationCompanion } from "../index-CGVJBR_H.js";
2
2
  export { FUNCTYPE_MARKER, FunctypeEnvelope, type JSONValue, SerializationResult, SerializedError, createCustomSerializer, createSerializationCompanion, createSerializer, createTaggedSerializer, deserializeError, envelope, fromBinary, fromJSON, fromYAML, serializeError, taggedEnvelope };
@@ -1,2 +1,2 @@
1
- import { kn as Set } from "../index-Xwjf0L5u.js";
1
+ import { kn as Set } from "../index-CGVJBR_H.js";
2
2
  export { Set };
package/dist/set/index.js CHANGED
@@ -1 +1 @@
1
- import{Ot as e}from"../src-DCf63AzV.js";export{e as Set};
1
+ import{Ot as e}from"../src-4UEC-cVf.js";export{e as Set};
@@ -1,8 +1,8 @@
1
1
  import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{Brand as t}from"./branded/index.js";import{mergeObjects as n}from"./util/index.js";import{t as r}from"./Companion-DiOMBHDG.js";import{a as i,d as a,f as o,i as s,p as c,t as l}from"./serialization-EQGLX3e3.js";import{n as u,t as ee}from"./typeclass-C61yDVYd.js";import{Tuple as te}from"./tuple/index.js";const d=e=>({[Symbol.toStringTag]:`Option`,_tag:`Some`,value:e,isEmpty:!1,isSome(){return!0},isNone(){return!1},orElse:t=>e,orThrow:()=>e,expect:t=>e,or:t=>d(e),orNull:()=>e,orUndefined:()=>e,map:t=>d(t(e)),ap:t=>t._tag===`Some`&&t.value?d(t.value(e)):f,filter(t){return t(e)?d(e):f},count:t=>+!!t(e),find:t=>t(e)?d(e):f,exists:t=>t(e),forEach:t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Some(e),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),reduce:t=>e,reduceRight:t=>e,foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),contains:t=>t===e,toList:()=>C([e]),toArray:()=>[e],size:1,toOption:()=>d(e),toEither:t=>w(e),toTry:()=>x(()=>e),toPromise:()=>Promise.resolve(e),toString:()=>`Some(${c(e)})`,toValue:()=>({_tag:`Some`,value:e}),toJSON:()=>({"@functype":`Option`,_tag:`Some`,value:e}),pipe:t=>t(e),serialize:()=>s(`Option`,`Some`,e),doUnwrap(){return{ok:!0,value:e}}}),f={[Symbol.toStringTag]:`Option`,_tag:`None`,value:void 0,isEmpty:!0,isSome(){return!1},isNone(){return!0},orElse:e=>e,orThrow(e){throw e??Error(`Cannot extract value from None`)},expect(e){return e()},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:e=>f,ap:e=>f,filter(e){return f},count:e=>0,find:e=>f,exists:e=>!1,forEach:e=>{},flatMap:e=>f,flatMapAsync:e=>Promise.resolve(f),reduce:e=>{throw Error(`Cannot reduce an empty Option`)},reduceRight:e=>{throw Error(`Cannot reduceRight an empty Option`)},fold:(e,t)=>e(),foldAsync:async(e,t)=>e(),match:e=>e.None(),foldLeft:e=>()=>e,foldRight:e=>()=>e,contains:()=>!1,toList:()=>C([]),toArray:()=>[],size:0,toOption:()=>f,toEither:e=>T(typeof e==`function`?e():e),toTry:()=>x(()=>{throw Error(`None`)}),toPromise:()=>Promise.reject(Error(`Cannot convert None to Promise`)),toString:()=>`None`,toValue:()=>({_tag:`None`,value:void 0}),toJSON:()=>({"@functype":`Option`,_tag:`None`,value:null}),pipe:e=>e(void 0),serialize:()=>s(`Option`,`None`,null),doUnwrap(){return{ok:!1,empty:!0}}},p=()=>f,ne=e=>e==null?p():d(e),re={from:e=>m(e),none:()=>p(),isSome:e=>e.isSome(),isNone:e=>e.isNone(),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Option`)throw Error(`Option.fromJSON: expected @functype="Option", got ${JSON.stringify(t[`@functype`])}`);return t._tag===`Some`?d(t.value):p()},fromYAML:e=>{let t=e.split(`
2
2
  `),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)return p();let i=r===`null`?null:JSON.parse(r);return n===`Some`?d(i):p()},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return re.fromJSON(t)},sequence:e=>e.reduce((e,t)=>e.isEmpty||t.isEmpty?p():d([...e.value,t.value]),d([])),traverse:(e,t)=>e.reduce((e,n,r)=>e.flatMap(e=>t(n,r).map(t=>[...e,t])),d([]))},m=r(ne,re),h=globalThis.Set,g=e=>{let t=new h(e),n={[Symbol.toStringTag]:`FunctypeSet`,_tag:`Set`,[Symbol.iterator]:()=>t[Symbol.iterator](),add:e=>g([...t,e]),remove:e=>{let n=new h(t);return n.delete(e),g(n)},contains:e=>t.has(e),has:e=>t.has(e),map:e=>g(Array.from(t).map(e)),ap:e=>{let n=new h;for(let r of t)for(let t of e)n.add(t(r));return g(n)},flatMap:e=>{let n=new h;for(let r of t)for(let t of e(r))n.add(t);return g(n)},flatMapAsync:async e=>{let n=new h;for(let r of t){let t=await e(r);for(let e of t)n.add(e)}return g(n)},fold:(e,n)=>{let r=e;for(let e of t)r=n(r,e);return r},foldLeft:e=>n=>{let r=e;for(let e of t)r=n(r,e);return r},foldRight:e=>n=>Array.from(t).reduceRight((e,t)=>n(t,e),e),get size(){return t.size},get isEmpty(){return t.size===0},reduce:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduce empty Set`);return u(n,e)},reduceRight:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduceRight empty Set`);return ee(n,e)},count:e=>{let n=0;for(let r of t)e(r)&&n++;return n},find:e=>{for(let n of t)if(e(n))return m(n);return m(null)},exists:e=>{for(let n of t)if(e(n))return!0;return!1},forEach:e=>{t.forEach(e)},filter:e=>{let n=new h;for(let r of t)e(r)&&n.add(r);return g(n)},filterNot:e=>{let n=new h;for(let r of t)e(r)||n.add(r);return g(n)},drop:e=>g(Array.from(t).slice(e)),dropRight:e=>g(Array.from(t).slice(0,-e)),dropWhile:e=>{let n=Array.from(t),r=n.findIndex(t=>!e(t));return g(r===-1?[]:n.slice(r))},flatten:()=>{let e=new h;for(let n of t)if(Array.isArray(n))for(let t of n)e.add(t);else if(n&&typeof n==`object`&&Symbol.iterator in n)for(let t of n)e.add(t);else e.add(n);return g(e)},get head(){return Array.from(t)[0]},get headOption(){let e=Array.from(t)[0];return m(e)},take:e=>g(Array.from(t).slice(0,Math.max(0,e))),takeWhile:e=>{let n=Array.from(t),r=[];for(let t of n){if(!e(t))break;r.push(t)}return g(r)},takeRight:e=>{let n=Array.from(t);return g(e<=0?[]:n.slice(-e))},get last(){let e=Array.from(t);return e[e.length-1]},get lastOption(){let e=Array.from(t);return m(e[e.length-1])},get tail(){return g(Array.from(t).slice(1))},get init(){let e=Array.from(t);return g(e.length===0?[]:e.slice(0,-1))},toList:()=>C(Array.from(t)),toSet:()=>n,toArray:()=>Array.from(t),toString:()=>`Set(${Array.from(t).toString()})`,toValue:()=>({_tag:`Set`,value:Array.from(t)}),toJSON:()=>({"@functype":`Set`,_tag:`Set`,value:Array.from(t)}),pipe:e=>e(Array.from(t)),serialize:()=>s(`Set`,Array.from(t))};return n},ie=e=>g(e),ae=g([]),oe={empty:()=>ae,of:(...e)=>g(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Set`)throw Error(`Set.fromJSON: expected @functype="Set", got ${JSON.stringify(t[`@functype`])}`);return se(t.value)},fromYAML:e=>{let t=e.split(`
3
- `)[1]?.split(`: `)[1];return se(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return oe.fromJSON(t)}},se=r(ie,oe),ce=e=>{let t=e;return{get(){return t},set(e){t=e},update(e){t=e(t)},getAndSet(e){let n=t;return t=e,n},updateAndGet(e){return t=e(t),t},getAndUpdate(e){let n=t;return t=e(t),n},compareAndSet(e,n){return t===e?(t=n,!0):!1},modify(e){let[n,r]=e(t);return t=n,r}}},_=r(ce,{of:e=>ce(e)}),le=(e=0)=>{let t=_(e),n=e;return{get:()=>t.get(),set:e=>t.set(e),increment:()=>t.updateAndGet(e=>e+1),decrement:()=>t.updateAndGet(e=>e-1),reset:()=>t.set(n),compareAndSet:(e,n)=>t.compareAndSet(e,n)}},ue=()=>{let e=_([]);return{add:t=>e.update(e=>[...e,t]),addAll:t=>e.update(e=>[...e,...t]),build:()=>e.get(),clear:()=>e.set([]),size:()=>e.get().length}},v=e=>{let t={[Symbol.toStringTag]:`LazyList`,_tag:`LazyList`,[Symbol.iterator]:()=>e[Symbol.iterator](),map:t=>v((function*(){for(let n of e)yield t(n)})()),flatMap:t=>v((function*(){for(let n of e)yield*t(n)})()),filter:t=>v((function*(){for(let n of e)t(n)&&(yield n)})()),take:t=>v((function*(){let n=le(0);for(let r of e){if(n.get()>=t)break;yield r,n.increment()}})()),drop:t=>v((function*(){let n=le(0);for(let r of e)n.get()>=t&&(yield r),n.increment()})()),takeWhile:t=>v((function*(){for(let n of e){if(!t(n))break;yield n}})()),dropWhile:t=>v((function*(){let n=_(!0);for(let r of e)n.get()&&t(r)||(n.set(!1),yield r)})()),concat:t=>v((function*(){yield*e,yield*t})()),zip:t=>v((function*(){let n=e[Symbol.iterator](),r=t[Symbol.iterator]();for(;;){let e=n.next(),t=r.next();if(e.done||t.done)break;yield[e.value,t.value]}})()),toList:()=>C(Array.from(e)),toArray:()=>Array.from(e),forEach:t=>{for(let n of e)t(n)},reduce:(t,n)=>{let r=_(n);for(let n of e)r.set(t(r.get(),n));return r.get()},find:t=>{for(let n of e)if(t(n))return m(n);return m.none()},some:t=>{for(let n of e)if(t(n))return!0;return!1},every:t=>{for(let n of e)if(!t(n))return!1;return!0},count:()=>{let t=le(0);for(let n of e)t.increment();return t.get()},get head(){let t=e[Symbol.iterator]().next();return t.done?void 0:t.value},get headOption(){let t=e[Symbol.iterator]().next();return t.done?m.none():m(t.value)},get last(){let t;for(let n of e)t=n;return t},get lastOption(){let t=_(void 0),n=_(!1);for(let r of e)t.set(r),n.set(!0);return n.get()?m(t.get()):m.none()},get tail(){return v((function*(){let t=e[Symbol.iterator]();t.next();let n=t.next();for(;!n.done;)yield n.value,n=t.next()})())},get init(){let t=Array.from(e);return v(t.length===0?[]:t.slice(0,-1))},takeRight:t=>{let n=Array.from(e);return v(t<=0?[]:n.slice(-t))},reverse:()=>v(Array.from(e).reverse()),distinct:()=>v((function*(){let t=new globalThis.Set;for(let n of e)t.has(n)||(t.add(n),yield n)})()),zipWithIndex:()=>v((function*(){let t=le(0);for(let n of e)yield[n,t.get()],t.increment()})()),fold:(t,n)=>{let r=t;for(let t of e)r=n(r,t);return r},foldLeft:t=>n=>{let r=_(t);for(let t of e)r.set(n(r.get(),t));return r.get()},foldRight:t=>n=>Array.from(e).reduceRight((e,t)=>n(t,e),t),pipe:e=>e(t),serialize:()=>s(`LazyList`,Array.from(e)),toJSON:()=>({"@functype":`LazyList`,_tag:`LazyList`,value:Array.from(e)}),toString:()=>{let t=[],n=le(0),r=_(!1);for(let i of e)if(n.get()<10)t.push(i),n.increment();else{r.set(!0);break}let i=t.map(e=>String(e)).join(`, `);return r.get()?`LazyList(${i}, ...)`:`LazyList(${i})`}};return t},de=r(e=>v(e),{empty:()=>v([]),of:e=>v([e]),from:(...e)=>v(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`LazyList`)throw Error(`LazyList.fromJSON: expected @functype="LazyList", got ${JSON.stringify(t[`@functype`])}`);return v(t.value)},iterate:(e,t)=>v((function*(){let n=_(e);for(;;)yield n.get(),n.set(t(n.get()))})()),generate:e=>v((function*(){for(;;)yield e()})()),range:(e,t,n=1)=>v((function*(){if(n===0)throw Error(`Step cannot be zero`);let r=_(e);if(n>0)for(;r.get()<t;)yield r.get(),r.set(r.get()+n);else for(;r.get()>t;)yield r.get(),r.set(r.get()+n)})()),repeat:(e,t)=>v((function*(){if(t===void 0)for(;;)yield e;else{let n=le(0);for(;n.get()<t;)yield e,n.increment()}})()),cycle:e=>v((function*(){let t=Array.from(e);if(t.length!==0)for(;;)yield*t})())}),y=e=>({[Symbol.toStringTag]:`Try`,_tag:`Success`,error:void 0,isSuccess(){return!0},isFailure(){return!1},orElse:t=>e,orThrow:t=>e,expect:t=>e,or:t=>y(e),orNull:()=>e,orUndefined:()=>e,toEither:t=>w(e),map:t=>x(()=>t(e)),ap:t=>t.map(t=>t(e)),flatMap:t=>t(e),flatMapAsync:async t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Success(e),recover:t=>y(e),recoverWith:t=>y(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),toString:()=>`Success(${c(e)})`,toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Success`,value:e}),toJSON:()=>({"@functype":`Try`,_tag:`Success`,value:e}),toOption:()=>d(e),toList:()=>C([e]),toArray:()=>[e],toTry:()=>y(e),pipe:t=>t(e),serialize:()=>s(`Try`,`Success`,e),contains:t=>e===t,exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),b=e=>({[Symbol.toStringTag]:`Try`,_tag:`Failure`,error:e,isSuccess(){return!1},isFailure(){return!0},orElse:e=>e,orThrow:t=>{throw t??e},expect:t=>t(e),or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:t=>T(typeof t==`function`?t(e):t),map:t=>b(e),ap:t=>b(e),flatMap:t=>b(e),flatMapAsync:t=>Promise.resolve(b(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),match:t=>t.Failure(e),recover:t=>x(()=>t(e)),recoverWith:t=>{try{return t(e)}catch(e){return b(e instanceof Error?e:Error(String(e)))}},foldLeft:e=>t=>e,foldRight:e=>t=>e,toString:()=>`Failure(${c(e)}))`,toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Failure`,value:e}),toJSON:()=>({"@functype":`Try`,_tag:`Failure`,error:o(e)}),toOption:()=>m(null),toList:()=>C([]),toArray:()=>[],toTry:()=>b(e),pipe:t=>{throw e},serialize:()=>i(`Try`,`Failure`,{error:o(e)}),contains:e=>!1,exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),fe=e=>{try{return y(e())}catch(e){return b(e instanceof Error?e:Error(String(e)))}},pe={success:e=>y(e),failure:e=>b(typeof e==`string`?Error(e):e),fromPromise:e=>e.then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e)))),async:e=>{try{return e().then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e))))}catch(e){return Promise.resolve(b(e instanceof Error?e:Error(String(e))))}},isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Try`)throw Error(`Try.fromJSON: expected @functype="Try", got ${JSON.stringify(t[`@functype`])}`);if(t._tag===`Success`)return y(t.value);if(t.error!==void 0&&typeof t.error==`object`)return b(a(t.error));let n=Error(typeof t.error==`string`?t.error:``);return t.stack&&(n.stack=t.stack),b(n)},fromYAML:e=>{let t=e.split(`
3
+ `)[1]?.split(`: `)[1];return se(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return oe.fromJSON(t)}},se=r(ie,oe),ce=e=>{let t=e;return{get(){return t},set(e){t=e},update(e){t=e(t)},getAndSet(e){let n=t;return t=e,n},updateAndGet(e){return t=e(t),t},getAndUpdate(e){let n=t;return t=e(t),n},compareAndSet(e,n){return t===e?(t=n,!0):!1},modify(e){let[n,r]=e(t);return t=n,r}}},_=r(ce,{of:e=>ce(e)}),le=(e=0)=>{let t=_(e),n=e;return{get:()=>t.get(),set:e=>t.set(e),increment:()=>t.updateAndGet(e=>e+1),decrement:()=>t.updateAndGet(e=>e-1),reset:()=>t.set(n),compareAndSet:(e,n)=>t.compareAndSet(e,n)}},ue=()=>{let e=_([]);return{add:t=>e.update(e=>[...e,t]),addAll:t=>e.update(e=>[...e,...t]),build:()=>e.get(),clear:()=>e.set([]),size:()=>e.get().length}},v=e=>{let t={[Symbol.toStringTag]:`LazyList`,_tag:`LazyList`,[Symbol.iterator]:()=>e[Symbol.iterator](),map:t=>v((function*(){for(let n of e)yield t(n)})()),flatMap:t=>v((function*(){for(let n of e)yield*t(n)})()),filter:t=>v((function*(){for(let n of e)t(n)&&(yield n)})()),take:t=>v((function*(){let n=le(0);for(let r of e){if(n.get()>=t)break;yield r,n.increment()}})()),drop:t=>v((function*(){let n=le(0);for(let r of e)n.get()>=t&&(yield r),n.increment()})()),takeWhile:t=>v((function*(){for(let n of e){if(!t(n))break;yield n}})()),dropWhile:t=>v((function*(){let n=_(!0);for(let r of e)n.get()&&t(r)||(n.set(!1),yield r)})()),concat:t=>v((function*(){yield*e,yield*t})()),zip:t=>v((function*(){let n=e[Symbol.iterator](),r=t[Symbol.iterator]();for(;;){let e=n.next(),t=r.next();if(e.done||t.done)break;yield[e.value,t.value]}})()),toList:()=>C(Array.from(e)),toArray:()=>Array.from(e),forEach:t=>{for(let n of e)t(n)},reduce:(t,n)=>{let r=_(n);for(let n of e)r.set(t(r.get(),n));return r.get()},find:t=>{for(let n of e)if(t(n))return m(n);return m.none()},some:t=>{for(let n of e)if(t(n))return!0;return!1},every:t=>{for(let n of e)if(!t(n))return!1;return!0},count:()=>{let t=le(0);for(let n of e)t.increment();return t.get()},get head(){let t=e[Symbol.iterator]().next();return t.done?void 0:t.value},get headOption(){let t=e[Symbol.iterator]().next();return t.done?m.none():m(t.value)},get last(){let t;for(let n of e)t=n;return t},get lastOption(){let t=_(void 0),n=_(!1);for(let r of e)t.set(r),n.set(!0);return n.get()?m(t.get()):m.none()},get tail(){return v((function*(){let t=e[Symbol.iterator]();t.next();let n=t.next();for(;!n.done;)yield n.value,n=t.next()})())},get init(){let t=Array.from(e);return v(t.length===0?[]:t.slice(0,-1))},takeRight:t=>{let n=Array.from(e);return v(t<=0?[]:n.slice(-t))},reverse:()=>v(Array.from(e).reverse()),distinct:()=>v((function*(){let t=new globalThis.Set;for(let n of e)t.has(n)||(t.add(n),yield n)})()),zipWithIndex:()=>v((function*(){let t=le(0);for(let n of e)yield[n,t.get()],t.increment()})()),fold:(t,n)=>{let r=t;for(let t of e)r=n(r,t);return r},foldLeft:t=>n=>{let r=_(t);for(let t of e)r.set(n(r.get(),t));return r.get()},foldRight:t=>n=>Array.from(e).reduceRight((e,t)=>n(t,e),t),pipe:e=>e(t),serialize:()=>s(`LazyList`,Array.from(e)),toJSON:()=>({"@functype":`LazyList`,_tag:`LazyList`,value:Array.from(e)}),toString:()=>{let t=[],n=le(0),r=_(!1);for(let i of e)if(n.get()<10)t.push(i),n.increment();else{r.set(!0);break}let i=t.map(e=>String(e)).join(`, `);return r.get()?`LazyList(${i}, ...)`:`LazyList(${i})`}};return t},de=r(e=>v(e),{empty:()=>v([]),of:e=>v([e]),from:(...e)=>v(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`LazyList`)throw Error(`LazyList.fromJSON: expected @functype="LazyList", got ${JSON.stringify(t[`@functype`])}`);return v(t.value)},iterate:(e,t)=>v((function*(){let n=_(e);for(;;)yield n.get(),n.set(t(n.get()))})()),generate:e=>v((function*(){for(;;)yield e()})()),range:(e,t,n=1)=>v((function*(){if(n===0)throw Error(`Step cannot be zero`);let r=_(e);if(n>0)for(;r.get()<t;)yield r.get(),r.set(r.get()+n);else for(;r.get()>t;)yield r.get(),r.set(r.get()+n)})()),repeat:(e,t)=>v((function*(){if(t===void 0)for(;;)yield e;else{let n=le(0);for(;n.get()<t;)yield e,n.increment()}})()),cycle:e=>v((function*(){let t=Array.from(e);if(t.length!==0)for(;;)yield*t})())}),y=e=>({[Symbol.toStringTag]:`Try`,_tag:`Success`,error:void 0,isSuccess(){return!0},isFailure(){return!1},orElse:t=>e,orThrow:t=>e,expect:t=>e,or:t=>y(e),orNull:()=>e,orUndefined:()=>e,toEither:t=>w(e),map:t=>x(()=>t(e)),ap:t=>t.map(t=>t(e)),flatMap:t=>t(e),flatMapAsync:async t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Success(e),recover:t=>y(e),recoverWith:t=>y(e),filterOrElse:(t,n)=>{try{return t(e)?y(e):b(n(e))}catch(e){return b(e instanceof Error?e:Error(String(e)))}},foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),toString:()=>`Success(${c(e)})`,toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Success`,value:e}),toJSON:()=>({"@functype":`Try`,_tag:`Success`,value:e}),toOption:()=>d(e),toList:()=>C([e]),toArray:()=>[e],toTry:()=>y(e),pipe:t=>t(e),serialize:()=>s(`Try`,`Success`,e),contains:t=>e===t,exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),b=e=>({[Symbol.toStringTag]:`Try`,_tag:`Failure`,error:e,isSuccess(){return!1},isFailure(){return!0},orElse:e=>e,orThrow:t=>{throw t??e},expect:t=>t(e),or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:t=>T(typeof t==`function`?t(e):t),map:t=>b(e),ap:t=>b(e),flatMap:t=>b(e),flatMapAsync:t=>Promise.resolve(b(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),match:t=>t.Failure(e),recover:t=>x(()=>t(e)),recoverWith:t=>{try{return t(e)}catch(e){return b(e instanceof Error?e:Error(String(e)))}},filterOrElse:(t,n)=>b(e),foldLeft:e=>t=>e,foldRight:e=>t=>e,toString:()=>`Failure(${c(e)}))`,toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Failure`,value:e}),toJSON:()=>({"@functype":`Try`,_tag:`Failure`,error:o(e)}),toOption:()=>m(null),toList:()=>C([]),toArray:()=>[],toTry:()=>b(e),pipe:t=>{throw e},serialize:()=>i(`Try`,`Failure`,{error:o(e)}),contains:e=>!1,exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),fe=e=>{try{return y(e())}catch(e){return b(e instanceof Error?e:Error(String(e)))}},pe={success:e=>y(e),failure:e=>b(typeof e==`string`?Error(e):e),fromPromise:e=>e.then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e)))),async:e=>{try{return e().then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e))))}catch(e){return Promise.resolve(b(e instanceof Error?e:Error(String(e))))}},isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Try`)throw Error(`Try.fromJSON: expected @functype="Try", got ${JSON.stringify(t[`@functype`])}`);if(t._tag===`Success`)return y(t.value);if(t.error!==void 0&&typeof t.error==`object`)return b(a(t.error));let n=Error(typeof t.error==`string`?t.error:``);return t.stack&&(n.stack=t.stack),b(n)},fromYAML:e=>{let t=e.split(`
4
4
  `),n=t[0]?.split(`: `)[1];if(!n)return b(Error(`Invalid YAML format for Try`));if(n===`Success`){let e=t[1]?.split(`: `)[1];return e?y(JSON.parse(e)):b(Error(`Invalid YAML format for Try Success`))}else{let e=t[1]?.split(`: `)[1];if(!e)return b(Error(`Invalid YAML format for Try Failure`));let n=t[2]?.split(`: `),r=n&&n.length>1?n.slice(1).join(`: `):void 0,i=Error(e);return r&&(i.stack=r),b(i)}},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return pe.fromJSON(t)},sequence:e=>x(()=>e.map(e=>e.orThrow())),traverse:(e,t)=>x(()=>e.map((e,n)=>t(e,n).orThrow()))},x=r(fe,pe);function me({_tag:e,impl:t}){return{...t,_tag:e}}function he(e,t){return!e||typeof e!=`object`||!(`_tag`in e)?!1:t?e._tag===t:!0}const S=e=>{let t=Array.from(e??[]),n={[Symbol.toStringTag]:`List`,_tag:`List`,[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:e=>S(t.map(e)),ap:e=>S(t.flatMap(t=>Array.from(e).map(e=>e(t)))),flatMap:e=>S(t.flatMap(t=>Array.from(e(t)))),flatMapAsync:async e=>S((await Promise.all(t.map(async t=>await e(t)))).flatMap(e=>Array.from(e))),forEach:e=>t.forEach(e),contains:e=>t.includes(e),count:e=>t.filter(e).length,exists:e=>t.some(e),filter:e=>S(t.filter(e)),filterNot:e=>S(t.filter(t=>!e(t))),filterType:e=>S(t.filter(t=>he(t,e))),find:(e,n)=>m(t.find(t=>e(t)&&(n?he(t,n):!0))),get head(){return t[0]},get headOption(){return t.length>0?m(t[0]):p()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:e=>u(t,e),reduceRight:e=>ee(t,e),fold:(e,n)=>t.reduce(n,e),foldLeft:e=>n=>t.reduce(n,e),foldRight:e=>n=>t.reduceRight((e,t)=>n(t,e),e),match:e=>t.length===0?e.Empty():e.NonEmpty([...t]),remove:e=>S(t.filter(t=>t!==e)),removeAt:e=>e<0||e>=t.length?n:S([...t.slice(0,e),...t.slice(e+1)]),add:e=>S([...t,e]),get:e=>m(t[e]),concat:e=>S([...t,...e.toArray()]),take:e=>S(t.slice(0,Math.max(0,e))),takeWhile:e=>{let n=[];for(let r of t){if(!e(r))break;n.push(r)}return S(n)},takeRight:e=>S(e<=0?[]:t.slice(-e)),get last(){return t[t.length-1]},get lastOption(){return t.length>0?m(t[t.length-1]):p()},get tail(){return S(t.slice(1))},get init(){return S(t.length===0?[]:t.slice(0,-1))},reverse:()=>S([...t].reverse()),indexOf:e=>t.indexOf(e),prepend:e=>S([e,...t]),distinct:()=>{let e=new globalThis.Set,n=[];for(let r of t)e.has(r)||(e.add(r),n.push(r));return S(n)},sorted:e=>S([...t].sort(e)),sortBy:(e,n)=>S([...t].sort((t,r)=>{let i=e(t),a=e(r);return n?n(i,a):i<a?-1:+(i>a)})),zip:e=>{let n=e.toArray(),r=Math.min(t.length,n.length),i=[];for(let e=0;e<r;e++)i.push([t[e],n[e]]);return S(i)},zipWithIndex:()=>S(t.map((e,t)=>[e,t])),groupBy:e=>{let n=new globalThis.Map;for(let r of t){let t=e(r),i=n.get(t)??[];i.push(r),n.set(t,i)}let r=new globalThis.Map;for(let[e,t]of n)r.set(e,S(t));return r},partition:e=>{let n=[],r=[];for(let i of t)e(i)?n.push(i):r.push(i);return[S(n),S(r)]},span:e=>{let n=t.findIndex(t=>!e(t));return n===-1?[S([...t]),S([])]:[S(t.slice(0,n)),S(t.slice(n))]},slice:(e,n)=>S(t.slice(e,n)),drop:e=>S(t.slice(e)),dropRight:e=>S(t.slice(0,-e)),dropWhile:e=>S(t.slice(t.findIndex(t=>!e(t)))),flatten:()=>S(t.flatMap(e=>Array.isArray(e)?e:[e])),toList:()=>n,toSet:()=>se(t),toOption:()=>t.length>0?m(t[0]):p(),toEither:e=>t.length>0?w(t[0]):T(e),toTry:()=>t.length>0?x(()=>t[0]):x(()=>{throw Error(`Empty list`)}),toString:()=>`List(${c(t)})`,toValue:()=>({_tag:`List`,value:t}),toJSON:()=>({"@functype":`List`,_tag:`List`,value:[...t]}),pipe:e=>e([...t]),serialize:()=>s(`List`,t),doUnwrap(){return t.length===0?{ok:!1,empty:!0}:{ok:!0,value:t[0]}}};return n},ge=e=>S(e),_e=S([]),ve={empty:()=>_e,of:(...e)=>S(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`List`)throw Error(`List.fromJSON: expected @functype="List", got ${JSON.stringify(t[`@functype`])}`);return C(t.value)},fromYAML:e=>{let t=e.split(`
5
- `)[1]?.split(`: `)[1];return C(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ve.fromJSON(t)}},C=r(ge,ve),ye=e=>({[Symbol.toStringTag]:`Either`,_tag:`Right`,value:e,isLeft(){return!1},isRight(){return!0},orElse:t=>e,orThrow:()=>e,expect:t=>e,or:t=>w(e),orNull:()=>e,orUndefined:()=>e,map:t=>w(t(e)),ap:t=>t._tag===`Right`?w(t.value(e)):T(t.value),mapAsync:t=>t(e).then(e=>w(e)).catch(e=>Promise.resolve(T(e))),merge:t=>t.isLeft()?T(t.value):w([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(e=>T(e)),toOption:()=>d(e),toList:()=>C([e]),toEither:t=>w(e),toTry:()=>x(()=>e),toJSON(){return{"@functype":`Either`,_tag:`Right`,value:e}},toString:()=>`Right(${c(e)})`,*[Symbol.iterator](){yield e},*yield(){yield e},traverse:t=>{let n=t(e);return n.isLeft()?T(n.value):w([n.value])},tap:t=>(t(e),w(e)),tapLeft:t=>w(e),mapLeft:t=>w(e),bimap:(t,n)=>w(n(e)),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),match:t=>t.Right(e),swap:()=>T(e),toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Right`,value:e}),pipeEither:(t,n)=>n(e),pipe:t=>t(e),serialize:()=>s(`Either`,`Right`,e),contains:t=>e===t,exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),be=e=>({[Symbol.toStringTag]:`Either`,_tag:`Left`,value:e,isLeft(){return!0},isRight(){return!1},orElse:e=>e,orThrow:t=>{throw t??e},expect:t=>t(e),or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:t=>T(e),ap:t=>T(e),mapAsync:t=>Promise.resolve(T(e)),merge:t=>T(e),flatMap:t=>T(e),flatMapAsync:t=>Promise.resolve(T(e)),toOption:()=>p(),toList:()=>C(),toEither:e=>T(e),toTry:()=>x(()=>{throw Error(String(e))}),toJSON(){return{"@functype":`Either`,_tag:`Left`,value:e}},toString:()=>`Left(${c(e)})`,*[Symbol.iterator](){},*yield(){},traverse:t=>T(e),tap:t=>T(e),tapLeft:t=>(t(e),T(e)),mapLeft:t=>T(t(e)),bimap:(t,n)=>T(t(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),foldLeft:e=>t=>e,foldRight:e=>t=>e,match:t=>t.Left(e),swap:()=>w(e),toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Left`,value:e}),pipeEither:(t,n)=>t(e),pipe:t=>t(e),serialize:()=>s(`Either`,`Left`,e),contains:e=>!1,exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),w=e=>ye(e),T=e=>be(e),xe=e=>e.isRight(),Se=e=>e.isLeft(),Ce=(e,t)=>{try{return w(e())}catch(e){return T(t(e))}},we=e=>ye(e);console.assert(we);const Te=e=>be(e);console.assert(Te);const Ee=async(e,t)=>{try{return w(await e())}catch(e){return T(t(e))}},De=(e,t)=>t?w(e):T(e),Oe={left:e=>T(e),right:e=>w(e),void:()=>w(void 0),isRight:e=>e.isRight(),isLeft:e=>e.isLeft(),sequence:e=>e.reduce((e,t)=>e.isLeft()?e:t.isLeft()?T(t.value):e.map(e=>[...e,t.value]),w([])),traverse:(e,t)=>Oe.sequence(e.map(t)),fromNullable:(e,t)=>e==null?T(t):w(e),fromPredicate:(e,t,n)=>t(e)?w(e):T(n),ap:(e,t)=>e.flatMap(e=>t.map(e)),fromPromise:async(e,t)=>{try{return w(await e)}catch(e){return T(t(e))}},fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Either`)throw Error(`Either.fromJSON: expected @functype="Either", got ${JSON.stringify(t[`@functype`])}`);return t._tag===`Right`?w(t.value):T(t.value)},fromYAML:e=>{let t=e.split(`
5
+ `)[1]?.split(`: `)[1];return C(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ve.fromJSON(t)}},C=r(ge,ve),ye=e=>({[Symbol.toStringTag]:`Either`,_tag:`Right`,value:e,isLeft(){return!1},isRight(){return!0},orElse:t=>e,orThrow:()=>e,expect:t=>e,or:t=>w(e),orNull:()=>e,orUndefined:()=>e,map:t=>w(t(e)),ap:t=>t._tag===`Right`?w(t.value(e)):T(t.value),mapAsync:t=>t(e).then(e=>w(e)).catch(e=>Promise.resolve(T(e))),merge:t=>t.isLeft()?T(t.value):w([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(e=>T(e)),toOption:()=>d(e),toList:()=>C([e]),toEither:t=>w(e),toTry:()=>x(()=>e),toJSON(){return{"@functype":`Either`,_tag:`Right`,value:e}},toString:()=>`Right(${c(e)})`,*[Symbol.iterator](){yield e},*yield(){yield e},traverse:t=>{let n=t(e);return n.isLeft()?T(n.value):w([n.value])},tap:t=>(t(e),w(e)),tapLeft:t=>w(e),mapLeft:t=>w(e),filterOrElse:(t,n)=>t(e)?w(e):T(n(e)),bimap:(t,n)=>w(n(e)),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),match:t=>t.Right(e),swap:()=>T(e),toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Right`,value:e}),pipeEither:(t,n)=>n(e),pipe:t=>t(e),serialize:()=>s(`Either`,`Right`,e),contains:t=>e===t,exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),be=e=>({[Symbol.toStringTag]:`Either`,_tag:`Left`,value:e,isLeft(){return!0},isRight(){return!1},orElse:e=>e,orThrow:t=>{throw t??e},expect:t=>t(e),or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:t=>T(e),ap:t=>T(e),mapAsync:t=>Promise.resolve(T(e)),merge:t=>T(e),flatMap:t=>T(e),flatMapAsync:t=>Promise.resolve(T(e)),toOption:()=>p(),toList:()=>C(),toEither:e=>T(e),toTry:()=>x(()=>{throw Error(String(e))}),toJSON(){return{"@functype":`Either`,_tag:`Left`,value:e}},toString:()=>`Left(${c(e)})`,*[Symbol.iterator](){},*yield(){},traverse:t=>T(e),tap:t=>T(e),tapLeft:t=>(t(e),T(e)),mapLeft:t=>T(t(e)),filterOrElse:(t,n)=>T(e),bimap:(t,n)=>T(t(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),foldLeft:e=>t=>e,foldRight:e=>t=>e,match:t=>t.Left(e),swap:()=>w(e),toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Left`,value:e}),pipeEither:(t,n)=>t(e),pipe:t=>t(e),serialize:()=>s(`Either`,`Left`,e),contains:e=>!1,exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),w=e=>ye(e),T=e=>be(e),xe=e=>e.isRight(),Se=e=>e.isLeft(),Ce=(e,t)=>{try{return w(e())}catch(e){return T(t(e))}},we=e=>ye(e);console.assert(we);const Te=e=>be(e);console.assert(Te);const Ee=async(e,t)=>{try{return w(await e())}catch(e){return T(t(e))}},De=(e,t)=>t?w(e):T(e),Oe={left:e=>T(e),right:e=>w(e),void:()=>w(void 0),isRight:e=>e.isRight(),isLeft:e=>e.isLeft(),sequence:e=>e.reduce((e,t)=>e.isLeft()?e:t.isLeft()?T(t.value):e.map(e=>[...e,t.value]),w([])),traverse:(e,t)=>Oe.sequence(e.map(t)),fromNullable:(e,t)=>e==null?T(t):w(e),fromPredicate:(e,t,n)=>t(e)?w(e):T(n),ap:(e,t)=>e.flatMap(e=>t.map(e)),fromPromise:async(e,t)=>{try{return w(await e)}catch(e){return T(t(e))}},fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Either`)throw Error(`Either.fromJSON: expected @functype="Either", got ${JSON.stringify(t[`@functype`])}`);return t._tag===`Right`?w(t.value):T(t.value)},fromYAML:e=>{let t=e.split(`
6
6
  `),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)throw Error(`Invalid YAML format for Either`);let i=JSON.parse(r);return n===`Right`?w(i):T(i)},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return Oe.fromJSON(t)}},ke=r(De,Oe);function E(e,n){return{brand:e,validate:n,of:r=>n(r)?m(t(e,r)):m.none(),from:r=>n(r)?w(t(e,r)):T(`Invalid ${e}: validation failed`),unsafeOf:r=>{if(!n(r))throw Error(`Invalid ${e}: validation failed`);return t(e,r)},is:e=>{try{return n(e)}catch{return!1}},unwrap:e=>e,refine:(e,t)=>E(e,e=>n(e)&&t(e))}}const Ae=E(`PositiveNumber`,e=>e>0),je=E(`NonNegativeNumber`,e=>e>=0),Me=E(`IntegerNumber`,e=>Number.isInteger(e)),Ne=Ae.refine(`PositiveInteger`,e=>Number.isInteger(e)),Pe=E(`NonEmptyString`,e=>e.length>0),Fe=E(`EmailAddress`,e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)),Ie=E(`UrlString`,e=>{try{return new URL(e),!0}catch{return!1}}),Le=E(`UUID`,e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)),Re=E(`ISO8601Date`,e=>!isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e));function ze(e,t,n){return E(e,e=>e>=t&&e<=n)}function Be(e,t,n){return E(e,e=>e.length>=t&&e.length<=n)}function Ve(e,t){return E(e,e=>t.test(e))}const He=e=>{let t=e=>typeof e==`function`?e():e,n={when:(r,i)=>e.resolved?n:r?He({resolved:!0,value:t(i)}):n,elseWhen:(r,i)=>e.resolved?n:r?He({resolved:!0,value:t(i)}):n,else:n=>e.resolved?e.value:t(n),orThrow:()=>{if(!e.resolved)throw Error(`Conditional expression has no matching condition`);return e.value}};return n},Ue=()=>He({resolved:!1}),We=r(Ue,{of:()=>Ue(),match:e=>t=>{let n=t[e];if(n===void 0)throw Error(`No case defined for value: ${String(e)}`);return typeof n==`function`?n():n},lazy:()=>{let e={resolved:!1},t={when:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),elseWhen:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),else:t=>e.resolved?e.value:t()};return t}}),Ge=(e,t)=>t===e?!0:typeof t==`function`?t(e):t&&typeof t==`object`&&`_`in t?t._(e):typeof t==`object`&&t&&typeof e==`object`&&e?Object.entries(t).every(([t,n])=>{let r=e[t];return Ge(r,n)}):!1,D=e=>{let t=(e,t)=>typeof e==`function`?e(t):e,n=()=>{for(let{pattern:n,result:r}of e.patterns)if(Ge(e.value,n))return{matched:!0,result:t(r,e.value)};return{matched:!1}},r={case:(n,i)=>e.resolved?r:Ge(e.value,n)?D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]}):D({...e,patterns:[...e.patterns,{pattern:n,result:i}]}),caseValue:(t,n)=>{if(e.resolved)return r;if(e.value===t){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},caseValues:(t,n)=>{if(e.resolved)return r;if(t.includes(e.value)){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},when:(e,t)=>r.case(e,t),caseAny:(n,i)=>{if(e.resolved)return r;for(let r of n)if(Ge(e.value,r))return D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]});return D({...e,patterns:[...e.patterns,...n.map(e=>({pattern:e,result:i}))]})},default:n=>e.resolved?e.result:t(n,e.value),exhaustive:()=>{if(e.resolved)return e.result;let t=n();if(!t.matched)throw Error(`Non-exhaustive match. No pattern matched value: ${JSON.stringify(e.value)}`);return t.result},orThrow:t=>{if(e.resolved)return e.result;let r=n();if(!r.matched)throw Error(t??`No matching pattern for value: ${JSON.stringify(e.value)}`);return r.result},toOption:()=>{if(e.resolved)return m(e.result);let t=n();return t.matched?m(t.result):m.none()}};return r},Ke=e=>{let t=(e,t)=>typeof e==`function`?e(t):e;return{case:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return Ge(e,n)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseValue:(t,n)=>D(e===t?{value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}:{value:e,resolved:!1,patterns:[]}),caseValues:(t,n)=>t.includes(e)?D({value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}):D({value:e,resolved:!1,patterns:[]}),when:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return n(e)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseAny:(n,r)=>{for(let i of n)if(Ge(e,i))return D({value:e,resolved:!0,result:t(r,e),patterns:n.map(e=>({pattern:e,result:r}))});return D({value:e,resolved:!1,patterns:n.map(e=>({pattern:e,result:r}))})}}},qe=r(e=>Ke(e),{exhaustive:e=>t=>{let n=e[t];if(n===void 0)throw Error(`No case defined for value: ${String(t)}`);return n},partial:e=>({withDefault:t=>n=>{let r=e[n];return r===void 0?typeof t==`function`?t(n):t:typeof r==`function`?r(n):r}}),withGuards:e=>({withDefault:t=>n=>{for(let[t,r]of e)if(t(n))return typeof r==`function`?r(n):r;return typeof t==`function`?t(n):t}}),struct:()=>{let e=[],t={case:(n,r)=>(e.push({pattern:n,handler:r}),t),build:()=>t=>{for(let{pattern:n,handler:r}of e)if(Ge(t,n))return r(t);throw Error(`No matching pattern for value: ${JSON.stringify(t)}`)}};return t},builder:()=>{let e=[],t,n={case:(t,r)=>(e.push({pattern:t,result:r}),n),when:(t,r)=>(e.push({pattern:t,result:r}),n),default:n=>(t=n,{build:()=>n=>{for(let{pattern:t,result:r}of e)if(Ge(n,t))return typeof r==`function`?r(n):r;if(t!==void 0)return typeof t==`function`?t(n):t;throw Error(`No matching pattern for value: ${JSON.stringify(n)}`)}})};return n}});function Je(e,t){return{...me({_tag:e,impl:t}),toString(){return`${e}()`},doUnwrap(){if(`isSome`in t&&`isNone`in t){if(typeof t.isSome==`function`&&t.isSome()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isNone==`function`&&t.isNone())return{ok:!1,empty:!0}}if(`isLeft`in t&&`isRight`in t){if(typeof t.isRight==`function`&&t.isRight()&&`value`in t)return{ok:!0,value:t.value};if(typeof t.isLeft==`function`&&t.isLeft()&&`value`in t)return{ok:!1,empty:!1,error:t.value}}if(`isSuccess`in t&&`isFailure`in t){if(typeof t.isSuccess==`function`&&t.isSuccess()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isFailure==`function`&&t.isFailure()&&`getError`in t&&typeof t.getError==`function`)return{ok:!1,empty:!1,error:t.getError()}}if(`isEmpty`in t&&`head`in t){if(typeof t.isEmpty==`function`&&t.isEmpty())return{ok:!1,empty:!0};if(typeof t.head==`function`)return{ok:!0,value:t.head()};if(`head`in t)return{ok:!0,value:t.head}}return{ok:!0,value:t}}}}const Ye=`Throwable`;var Xe=class e extends Error{constructor(e,t){super(e,{cause:t?.cause}),this._tag=Ye,this.name=t?.taskInfo?.name??`Throwable`,Object.defineProperties(this,{_tag:{value:Ye,writable:!1,configurable:!1},data:{value:t?.data,writable:!1,configurable:!1},taskInfo:{value:t?.taskInfo,writable:!1,configurable:!1},name:{value:t?.taskInfo?.name??`Throwable`,writable:!1,configurable:!1}}),t?.cause&&Object.defineProperty(this,"cause",{value:t.cause,writable:!1,configurable:!1}),t?.stack?this.stack=t.stack:Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static apply(t,n,r){if(t instanceof Error){let i=new e(t.message,{data:n,cause:t.cause??void 0,stack:t.stack??void 0,taskInfo:r});for(let e of Object.keys(t))if(!(e in i)){let n=i;n[e]=t[e]}return i}if(t&&typeof t==`object`){let i=t,a=new e(typeof i.message==`string`?i.message:typeof i.error==`string`?i.error:`Object error: ${JSON.stringify(i,Object.getOwnPropertyNames(i).filter(e=>i[e]!==void 0))}`,{data:n??i,taskInfo:r});for(let e of Object.keys(i))if(!(e in a)){let t=a;t[e]=i[e]}return a}if(typeof t==`function`){let i=t.name??`anonymous function`,a=t.toString().substring(0,100)+(t.toString().length>100?`...`:``);return new e(`Function error: ${i}`,{data:n??{functionType:typeof t,functionName:i,functionString:a},taskInfo:r})}let i=typeof t,a=t===null?`null`:t===void 0?`undefined`:String(t);if(i===`number`){let a=t;return new e(Number.isNaN(a)?`Number error: NaN`:Number.isFinite(a)?`Number error: ${a}`:`Number error: ${a>0?`Infinity`:`-Infinity`}`,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}if(i===`bigint`)return new e(`BigInt error: ${t}n`,{data:n??{errorType:i,errorValue:String(t),originalError:t},taskInfo:r});if(i===`boolean`)return new e(`Boolean error: ${t}`,{data:n??{errorType:i,errorValue:t,originalError:t},taskInfo:r});if(i===`symbol`){let a=t.description??`unnamed symbol`;return new e(`Symbol error: Symbol(${a})`,{data:n??{errorType:i,symbolDescription:a,originalError:t},taskInfo:r})}return new e(typeof t==`string`?t:`${i.charAt(0).toUpperCase()+i.slice(1)} error: ${a}`,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}};function Ze(e){return e instanceof Error&&typeof e==`object`&&e._tag===`Throwable`}const Qe=(e,t)=>{if(e.isRight())return k(e.orThrow(),t);if(e.isLeft())return O(e.fold(e=>e,()=>Error(`Unexpected right value`)),void 0,t);throw Error(`Unrecognized task outcome`)},O=(e,t,n)=>{let r={name:n?.name??`Task`,description:n?.description??``},a=Xe.apply(e,t,r),s={...Je(`Err`,{error:a,meta:r}),[Symbol.toStringTag]:`TaskOutcome`,_tag:`Err`,_meta:r,value:void 0,error:a,isSuccess(){return!1},isFailure(){return!0},isOk(){return!1},isErr(){return!0},map:e=>O(a,t,n),flatMap:e=>O(a,t,n),ap:e=>O(a,t,n),mapAsync:e=>Promise.resolve(O(a,t,n)),flatMapAsync:e=>Promise.resolve(O(a,t,n)),mapError:e=>O(e(a),t,n),recover:e=>k(e,n),recoverWith:e=>k(e(a),n),orThrow:e=>{throw e??a},orElse:e=>e,or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:()=>T(a),toTry:()=>x(()=>{throw a}),toOption:()=>p(),toList:()=>C([]),fold:(e,t)=>e(a),match:e=>e.Err(a),foldLeft:e=>t=>e,foldRight:e=>t=>e,size:0,isEmpty:!0,contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce empty Err`)},reduceRight:e=>{throw Error(`Cannot reduceRight empty Err`)},count:e=>0,find:e=>p(),exists:e=>!1,forEach:e=>{},toPromise:()=>Promise.reject(a),doUnwrap(){return{ok:!1,empty:!1,error:a}},toJSON:()=>({"@functype":`Task`,_tag:`Err`,error:o(a)}),serialize:()=>i(`Task`,`Err`,{error:o(a)}),pipe:e=>e(s)};return s},k=(e,t)=>{let n={name:t?.name??`Task`,description:t?.description??``},r={...Je(`Ok`,{value:e,meta:n}),[Symbol.toStringTag]:`TaskOutcome`,_tag:`Ok`,_meta:n,value:e,error:void 0,isSuccess(){return!0},isFailure(){return!1},isOk(){return!0},isErr(){return!1},map:n=>k(n(e),t),flatMap:n=>{let r=n(e);return r&&typeof r==`object`&&`isLeft`in r&&`isRight`in r?Qe(r,t):r},ap:n=>n.isOk()?k(n.value(e),t):O(n.error,void 0,t),mapAsync:async n=>k(await n(e),t),flatMapAsync:async t=>await t(e),mapError:n=>k(e,t),recover:n=>k(e,t),recoverWith:n=>k(e,t),orThrow:t=>e,orElse:t=>e,or:n=>k(e,t),orNull:()=>e,orUndefined:()=>e,toEither:()=>w(e),toTry:()=>x(()=>e),toOption:()=>d(e),toList:()=>C([e]),fold:(t,n)=>n(e),match:t=>t.Ok(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),size:1,isEmpty:!1,contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>+!!t(e),find:t=>t(e)?d(e):p(),exists:t=>t(e),forEach:t=>t(e),toPromise:()=>Promise.resolve(e),doUnwrap(){return{ok:!0,value:e}},toJSON:()=>({"@functype":`Task`,_tag:`Ok`,value:e}),serialize:()=>s(`Task`,`Ok`,e),pipe:e=>e(r)};return r},$e=()=>{let e=new AbortController,t=ue();return{token:{get isCancelled(){return e.signal.aborted},get signal(){return e.signal},onCancel(n){e.signal.aborted?n():t.add(n)}},cancel(){e.signal.aborted||(e.abort(),t.build().forEach(e=>{try{e()}catch(e){console.error(`Error in cancellation callback:`,e)}}))}}},et=e=>{let t=e?.name??`Task`,n=e?.description??``,r={Async:(e,r=e=>e,i=()=>{},a)=>new Promise(o=>{(async()=>{let s=_(!1),c=_(null),l=_(()=>{});if(a){if(a.isCancelled){try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}o(O(Error(`Task was cancelled before execution started`),void 0,{name:t,description:n}));return}a.onCancel(()=>{s.set(!0),c.set(Error(`Task was cancelled during execution`))}),l.set(()=>{})}try{let r=await e();try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(O(c.get(),void 0,{name:t,description:n})):o(O(Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}if(r&&typeof r==`object`&&`_tag`in r){let e=r;e._tag===`Ok`||e._tag===`Err`?o(e):o(k(r,{name:t,description:n}))}else o(k(r,{name:t,description:n}))}catch(e){try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(O(c.get(),void 0,{name:t,description:n})):o(O(Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}try{if(e instanceof Error&&Ze(e)){let i=Error(`${t}: ${e.message}`),a=Xe.apply(i,void 0,{name:t,description:n});Object.defineProperty(a,"cause",{value:e,writable:!1,configurable:!1}),Promise.resolve().then(()=>{try{r(e)}catch(e){console.error(`Error in error handler:`,e)}}),o(O(a,void 0,{name:t,description:n}))}else{let i=await r(e);if(i&&typeof i==`object`&&`_tag`in i){let e=i;e._tag===`Ok`||e._tag===`Err`?o(e):o(O(i,void 0,{name:t,description:n}))}else o(O(i,void 0,{name:t,description:n}))}}catch(e){o(O(e,void 0,{name:t,description:n}))}}finally{l.get()()}})().catch(e=>o(O(e,void 0,{name:t,description:n})))}),Sync:(e,r=e=>e,i=()=>{})=>{try{return k(e(),{name:t,description:n})}catch(e){return O(r(e),void 0,{name:t,description:n})}finally{i()}},AsyncWithProgress:(e,t,n=e=>e,i=()=>{},a)=>{let o=e=>{let n=Math.max(0,Math.min(100,e));n<=100&&t(n)};return r.Async(()=>e(o),n,i,a)}};return{...Je(`Task`,r),_type:`Task`}},tt={success:(e,t)=>k(e,t),fail:(e,t,n)=>O(e,t,n),ok:(e,t)=>k(e,t),err:(e,t,n)=>O(e,t,n),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Task`)throw Error(`Task.fromJSON: expected @functype="Task", got ${JSON.stringify(t[`@functype`])}`);if(t._tag===`Ok`)return k(t.value);if(t._tag===`Err`)return O(t.error!==void 0&&typeof t.error==`object`?a(t.error):Error(typeof t.error==`string`?t.error:`Unknown Task error`));throw Error(`Task.fromJSON: unrecognized _tag ${JSON.stringify(t._tag)}`)},fromEither:(e,t)=>Qe(e,t),fromTry:(e,t)=>e.isSuccess()?k(e.orThrow(),t):O(e.fold(e=>e,()=>Error(`Unexpected success`)),void 0,t),getErrorChain:e=>{if(!e)return[];let t=ue();t.add(e);let n=_(e);for(;n.get()&&n.get().cause;){let{cause:e}=n.get();if(e)t.add(e),n.set(e);else break;if(t.size()>100)break}return t.build()},formatErrorChain:(e,t)=>{let n=tt.getErrorChain(e),r=t?.separator??`
7
7
  `;return n.map((e,n)=>{if(!e)return`${n>0?`↳ `:``}Unknown error`;let{taskInfo:r}=e,i=t?.includeTasks&&r?.name?`[${r.name}] `:``,a=e.message??`No message`,o=_(`${n>0?`↳ `:``}${i}${a}`);return t?.includeStackTrace&&e.stack&&o.set(`${o.get()}\n${e.stack.split(`
8
8
  `).slice(1).join(`
@@ -1,2 +1,2 @@
1
- import { Mn as TypeNames, jn as Try } from "../index-Xwjf0L5u.js";
1
+ import { Mn as TypeNames, jn as Try } from "../index-CGVJBR_H.js";
2
2
  export { Try, TypeNames };
package/dist/try/index.js CHANGED
@@ -1 +1 @@
1
- import{Tt as e}from"../src-DCf63AzV.js";export{e as Try};
1
+ import{Tt as e}from"../src-4UEC-cVf.js";export{e as Try};
@@ -1,2 +1,2 @@
1
- import { _r as Monad, dr as reduceRightWiden, fr as reduceWiden, gr as Functor, hr as AsyncMonad, mr as Applicative, pr as Promisable, ur as Widen, vr as CollectionOps, yr as ContainerOps } from "../index-Xwjf0L5u.js";
1
+ import { _r as Monad, dr as reduceRightWiden, fr as reduceWiden, gr as Functor, hr as AsyncMonad, mr as Applicative, pr as Promisable, ur as Widen, vr as CollectionOps, yr as ContainerOps } from "../index-CGVJBR_H.js";
2
2
  export { type Applicative, type AsyncMonad, type CollectionOps, type ContainerOps, type Functor, type Monad, type Promisable, type Widen, reduceRightWiden, reduceWiden };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "1.4.4",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "description": "A functional programming library for TypeScript, using immutable data structures and type classes",
6
6
  "keywords": [
@@ -37,11 +37,11 @@
37
37
  "eslint-plugin-functional": "^9.0.5",
38
38
  "fast-check": "^4.8.0",
39
39
  "globals": "^17.6.0",
40
- "ts-builds": "^3.2.0",
40
+ "ts-builds": "^3.2.1",
41
41
  "tsdown": "^0.22.3",
42
42
  "tsx": "^4.22.4",
43
43
  "typedoc": "^0.28.19",
44
- "eslint-config-functype": "2.104.4"
44
+ "eslint-config-functype": "2.105.0"
45
45
  },
46
46
  "types": "./dist/index.d.ts",
47
47
  "module": "./dist/index.js",