import type { Kind } from '../../kinds/index.js'; import type { GenericFn } from '../../utils/functions'; import type { TOption } from '../../data/option/option.types'; import type { TypeSkell } from '../../typeskell/index.js'; import type { ToParams, ToResult } from './to.types'; export declare namespace To { type $getOrElse = GenericFn>; type $getOr = TypeSkell<'b -> F a ..e -> Or a b', { F: F; Or: Kind.Or; }>; } /** * To is a typeclass that provides a way to extract a value from a type. */ export interface To { /** * to :: `(e -> b) -> F a -> a | b` * * to :: `(f: (...args: E)=> B) => (fa: $) => A | B` * * At the moment typeskell don't support spreading outside a type constructor * So we have to use a workaround with a custom `ToParams` and `ToResult` * * @param f `f (e -> a)` * @returns `F a -> a` * */ getOrElse: To.$getOrElse; } /** * getOr :: `To F -> b -> F a -> a | b` * * getOr :: `(to: To) => (b: B) => (fa: $) => A | B` * * @param to `To F` * @param b `b` * @returns `F a -> a | b` */ export declare const getOr: (to: To) => To.$getOr; export declare namespace OptionalTo { type $get = TypeSkell<'F a ..e -> Option a', { F: F; Option: TOption; }>; } export interface OptionalTo extends To { get: OptionalTo.$get; }