import type ApFn from "./Ap"; import type { Fn1, Fn2, PartialApply } from "../../HKT"; import type { ValueOf } from "../../Obj/ValueOf"; import type { Eq, Lazied, Lazied$Get } from "../../helpers"; import type { Functor } from "../Functor"; import type { HKT, Kind } from "../HKT"; /** * A type class for types that can be converted to a string. */ export type Applicative = Lazied$Get>; /** * {@link Lazied} version of {@link Applicative}. */ export type ApplicativeL = Lazied>; /** * Type class constraints for type class {@link Applicative}. */ export interface TypeClass$$Applicative { /** * Apply an {@link Applicative} of a function to an {@link Applicative} of a value. * * **⚠️ Warning:** Correctness of the method is not fully checked, so be careful when implementing * this method. * * Sig: `, T, U>(fab: F<(x: T) => U>, f: F) => F` */ Ap: Fn2, F, F>; /** * Build an {@link Applicative} from a value. * * **⚠️ Warning:** Correctness of the method is not fully checked, so be careful when implementing * this method. * * Sig: `, T>(x: T) => F` */ Of: Fn1; } /** * Implementations for type class {@link Applicative}. */ export interface ApplicativeImpl {} /** * Helper type for implementing type class {@link Applicative}. */ export type ImplApplicativeFor> = [ F, TypeClass, ]; /** * Get the matching entry of {@link ApplicativeImpl} for `F`. * @private */ type _Applicative$GetMatch = ValueOf<{ [P in keyof ApplicativeImpl as F extends ApplicativeImpl[P][0] ? P : never]: ApplicativeImpl[P]; }>; /** * Get the constructor of `F` from {@link ApplicativeImpl}. */ export type Applicative$GetConstruct = Eq extends true ? Applicative : _Applicative$GetMatch extends [infer F extends HKT, unknown] ? F : never; /** * The **unsafe** version of {@link Applicative$GetConstruct} (i.e. no type checking with `F`). */ export type Applicative$GetConstructW = F extends Applicative ? Applicative$GetConstruct : never; /** * Get the type class of `F` from {@link ApplicativeImpl}. */ export type Applicative$GetTypeClass = _Applicative$GetMatch extends [unknown, infer TypeClass] ? TypeClass : never; /** * The **unsafe** version of {@link Applicative$GetTypeClass} (i.e. no type checking with `F`). */ export type Applicative$GetTypeClassW = F extends Applicative ? Applicative$GetTypeClass : never; /*********** * Methods * ***********/ /** * Methods for `Applicative`. */ export namespace Applicative { /** * [Fn] Apply an {@link Applicative} of a function to an {@link Applicative} of a value. * * Sig: `, T, U>[f: F](fab: F<(x: T) => U>) => F` */ export type Ap = PartialApply; }