import type { CovariantComposition } from "@tsplus/stdlib/prelude/Covariant" /** * @tsplus type ForEach */ export type ForEach = { readonly Law: { readonly ForEach: "ForEach" } readonly forEachF: ForEach.Fn } & Covariant /** * @tsplus type ForEach/Ops */ export interface ForEachOps {} export const ForEach: ForEachOps = {} /** * @tsplus type ForEachComposition */ export type ForEachComposition = { readonly Law: { readonly ForEach: "ForEach" } readonly forEachF: ForEach.CompositionFn } & CovariantComposition export declare namespace ForEach { export interface Fn { (G: IdentityBoth & Covariant): ( f: (a: A) => HKT.Kind ) => ( fa: HKT.Kind ) => HKT.Kind> } export interface Fn_ { ( fa: HKT.Kind, G: IdentityBoth & Covariant ): ( f: (a: A) => HKT.Kind ) => HKT.Kind> } export interface CompositionFn { (H: IdentityBoth & Covariant): ( f: (a: A) => HKT.Kind ) => ( fa: HKT.Kind> ) => HKT.Kind>> } } /** * @tsplus static ForEach/Ops implementForEachF */ export function implementForEachF(): ( i: (_: { A: A B: B G: G N: N R: R E: E }) => ( G: IdentityBoth & Covariant ) => ( f: (a: A) => HKT.Kind ) => (fa: HKT.Kind) => HKT.Kind> ) => ForEach.Fn export function implementForEachF() { return (i: any) => i() } /** * @tsplus static ForEach/Ops getComposition */ export function getComposition( F_: ForEach, G_: ForEach ): ForEachComposition { return HKT.instance>({ ...Covariant.getComposition(F_, G_), forEachF: (H) => (f) => (fa) => pipe(fa, F_.forEachF(H)(G_.forEachF(H)(f))) }) } /** * @tsplus static ForEach/Ops sequenceF */ export function sequenceF(T: ForEach) { return ( App: Covariant & IdentityBoth ): ( _: HKT.Kind> ) => HKT.Kind> => { const traverse = T.forEachF(App) return traverse(identity) } }