/** * Represents an asynchronous computation that produces a value of type `T`. * 非同期の計算を表し、型 `T` の値を生成します。 */ export type Task = { readonly isTask: true; /** * Transforms the result of the `Task` using the provided function and returns a new `Task`. * `Task` の結果を指定された関数で変換し、新しい `Task` を返します。 * @param fn - A function to transform the result. / 結果を変換する関数。 */ readonly map: (fn: (value: T) => U) => Task; /** * Transforms the result of the `Task` using the provided function and returns a new `Task`. * Alias for `map`. * `Task` の結果を指定された関数で変換し、新しい `Task` を返します。 * `map` のエイリアス。 * @param fn - A function to transform the result. / 結果を変換する関数。 */ readonly "<$>": (fn: (value: T) => U) => Task; /** * Chains another `Task` based on the result of this `Task` and flattens the result. * この `Task` の結果をもとに別の `Task` を連結し、その結果を平坦化して返します。 * @param fn - A function that returns a `Task`. / `Task` を返す関数。 */ readonly flatMap: (fn: (value: T) => Task) => Task; /** * Chains another `Task` based on the result of this `Task` and flattens the result. * Alias for `flatMap`. * この `Task` の結果をもとに別の `Task` を連結し、その結果を平坦化して返します。 * `flatMap` のエイリアス。 * @param fn - A function that returns a `Task`. / `Task` を返す関数。 */ readonly ">>=": (fn: (value: T) => Task) => Task; /** * Applies a `Task` that contains a function to a `Task` that contains a value and returns a new `Task`. * 関数を含む `Task` を値を含む別の `Task` に適用し、新しい `Task` を返します。 * @param taskValue - A `Task` containing the value. / 値を含む `Task`。 */ readonly apply: (taskValue: Task) => Task; /** * Applies a `Task` that contains a function to a `Task` that contains a value and returns a new `Task`. * Alias for `apply`. * 関数を含む `Task` を値を含む別の `Task` に適用し、新しい `Task` を返します。 * `apply` のエイリアス。 * @param taskValue - A `Task` containing the value. / 値を含む `Task`。 */ readonly "<*>": (taskValue: Task) => Task; /** * Executes the asynchronous computation and returns a `Promise` that resolves with the result. * 非同期計算を実行し、その結果で解決する `Promise` を返します。 */ readonly run: () => Promise; }; /** * Adapter type for Do's `$` parameter. * `$` は `yield* $(Task.pack(...))` のためのアダプタ関数です。 */ export type $Task = (fa: Task) => Generator; /** * Creates a new `Task` from an asynchronous computation function. * 非同期計算関数から新しい `Task` を作成します。 * @param fn - A function that performs the asynchronous computation. / 非同期計算を実行する関数。 */ declare const task: (fn: () => Promise) => Task; /** * Creates a `Task` that attempts the given computation, and falls back to a recovery function on failure. * 指定された計算を試み、失敗時にはリカバリー関数にフォールバックする `Task` を作成します。 * @param fn - A function that performs the computation. / 計算を実行する関数。 * @param onError - A recovery function for handling errors. / エラーを処理するリカバリー関数。 */ declare const tryCatch: (fn: () => T | Promise, onError: (error: any) => T | Promise) => Task; /** * Creates a `Task` that performs the given computation, propagating any errors that occur. * 指定された計算を実行し、発生したエラーを伝播する `Task` を作成します。 * @param fn - A function that performs the computation. / 計算を実行する関数。 */ declare const tryTask: (fn: () => T | Promise) => Task; /** * Lifts a value into a `Task`, which resolves immediately with the value. * 値を `Task` に持ち上げ、即座にその値で解決される `Task` を返します。 * @param value - The value to lift into the `Task`. / `Task` に持ち上げる値。 */ declare const lift: (value: T) => Task; /** * Runs multiple Tasks in parallel and collects their results like Promise.all. * 複数の Task を並列に実行し、結果を配列として収集します(Promise.all 相当)。 */ declare const all: (tasks: readonly Task[]) => Task; /** * Checks if the given value is a `Task`. * 指定された値が `Task` かどうかを判定します。 * @param value - The value to check. / 判定する値。 */ declare const isTask: (value: any) => value is Task; declare function Do(generatorFunc: () => Generator, U | Task, T>): Task; declare function Do(g: ($: (fa: Task) => Generator) => Generator): Task; /** * Task utility object containing constructors and helper functions. * コンストラクタとヘルパー関数を含む `Task` ユーティリティオブジェクト。 */ export declare const Task: { do: typeof Do; from: typeof task; pack: typeof lift; all: typeof all; tryCatch: typeof tryCatch; tryTask: typeof tryTask; isTask: typeof isTask; }; export {};