// @ts-ignore - `Err` is only used in doc comments import type { Err, Ok, Result } from "."; import type { Args, Call1W, Fn1, GenericFn, GenericResolver, GenericReturn1W, Param0, Return, } from "../HKT"; /** * Apply a function to a {@link Result} value if it is {@link Ok}, otherwise return the {@link Err}. * * Sig: `(f: (x: T) => U, r: Result) => Result` */ export type Map> = R extends Ok ? Ok> : R; interface Resolver extends GenericResolver<[Fn1, Result], Result> { on1_: ([f]: Args) => [ [Result, unknown>], Result, unknown>, ]; on_1: ([, r]: Args) => [ [typeof r extends Result ? Fn1 : never], Result ? E : never>, ]; on11: ([f, r]: Args) => [ [], typeof r extends Result ? Result, E> : never, ]; } /** * [Fn] Apply a function to a {@link Result} value if it is {@link Ok}, otherwise return the * {@link Err}. * * Sig: `(f: (x: T) => U, r: Result) => Result` */ export default interface MapFn extends GenericFn { def: ([f, r]: Args) => Map; }