/** * Failable is a compound structure. It represents the idea of failure. As such * it includes methods for creating a `failed` data, providing alternative * data, and recovering from a failed state (effectively flatMapping from the * failed value). * * @module Failable * @since 2.0.0 */ import "./_dnt.polyfills.js"; import type { $, Hold, Kind } from "./kind.js"; import type { Flatmappable } from "./flatmappable.js"; import type { NonEmptyArray } from "./array.js"; /** * A Failable structure is a Flatmappable that allows for alternative instances, * failures, and recovery. * * @since 2.0.0 */ export interface Failable extends Flatmappable, Hold { readonly alt: (second: $) => (first: $) => $; readonly fail: (value: B) => $; readonly recover: (fbti: (b: B) => $) => (ua: $) => $; } /** * Create a tryAll function from an instance of Failable. The tryAll function * allows the trying any number of Failable structures in order until a * non-failed one is found. * * @since 2.0.0 */ export declare function createTryAll({ alt }: Failable): (...uas: NonEmptyArray<$>) => $;