rivo
Version:
🤖 The ultimate library you need for composable type-level programming in TypeScript, powered by HKT.
51 lines (46 loc) • 1.85 kB
TypeScript
import type { List } from ".";
import type { Flatten } from "./Flatten";
import type { Map } from "./Map";
import type { GenericReturn1W } from "..";
import type { Args, Fn1, GenericFn, GenericResolver, Param0W, ReturnW } from "../HKT";
import type { Applicative, TypeClass$$Applicative } from "../typeclass";
declare module "../typeclass/Applicative" {
interface ApplicativeImpl {
List: ImplApplicativeFor<List, List$$Applicative>;
}
}
/**
* Implementation of the {@link Applicative} type class for {@link List}.
*/
export interface List$$Applicative extends TypeClass$$Applicative<List> {
Ap: List$$Applicative$ApFn;
Of: List$$Applicative$OfFn;
}
interface ApResolver extends GenericResolver<[List<Fn1>, List<unknown>], List<unknown>> {
on1_: ([fab]: Args<this>) => [[Param0W<(typeof fab)[number]>], ReturnW<(typeof fab)[number]>];
on_1: ([, f]: Args<this>) => [[List<Fn1<(typeof f)[number], unknown>>], List<unknown>];
on11: ([fab, f]: Args<this>) => [
[],
List<GenericReturn1W<(typeof fab)[number], (typeof f)[number]>>,
];
}
/**
* [Fn] Apply an {@link List} of a function to an {@link List} of a value if both are
* {@link Some}, otherwise return {@link None}.
*/
interface List$$Applicative$ApFn extends GenericFn<ApResolver> {
def: ([fab, f]: Args<this>) => List$$Applicative$Ap<typeof fab, typeof f>;
}
type List$$Applicative$Ap<FAB extends List<Fn1>, F extends List> = Flatten<{
[K in keyof FAB]: Map<FAB[K], F>;
}>;
interface OfResolver extends GenericResolver<[unknown], List<unknown>> {
on1: ([x]: Args<this>) => [[], List<typeof x>];
}
/**
* [Fn] Build a {@link List} from a value (convert it to `readonly [x]`).
*/
interface List$$Applicative$OfFn extends GenericFn<OfResolver> {
def: ([x]: Args<this>) => List$$Applicative$Of<typeof x>;
}
type List$$Applicative$Of<T> = readonly [T];