import type { Applicative } from './Applicative' import type { Either } from './Either' import type { FilterableWithIndexMin } from './FilterableWithIndex' import type { Option } from './Option' import type { TraversableWithIndexMin } from './TraversableWithIndex' import { FilterableWithIndex } from './FilterableWithIndex' import * as HKT from './HKT' import { TraversableWithIndex } from './TraversableWithIndex' export interface WitherableWithIndex extends FilterableWithIndex, TraversableWithIndex { readonly icompactA_: WitherWithIndexFn_ readonly icompactA: WitherWithIndexFn readonly iseparateA_: WiltWithIndexFn_ readonly iseparateA: WiltWithIndexFn } export type WitherableWithIndexMin = FilterableWithIndexMin & TraversableWithIndexMin & { readonly icompactA_: WitherWithIndexFn_ readonly iseparateA_: WiltWithIndexFn_ } export function WitherableWithIndex( F: WitherableWithIndexMin ): WitherableWithIndex { return HKT.instance({ ...FilterableWithIndex(F), ...TraversableWithIndex(F), iseparateA_: F.iseparateA_, iseparateA: (A) => { const iseparateA_ = F.iseparateA_(A) return (f) => (wa) => iseparateA_(wa, f) }, icompactA_: F.icompactA_, icompactA: (A) => { const icompactA_ = F.icompactA_(A) return (f) => (wa) => icompactA_(wa, f) } }) } export interface WitherWithIndexFn { (F: Applicative): < NG extends string, KG, QG, WG, XG, IG, SG, RG, EG, A, B, NF extends string, KF >( f: ( k: HKT.IndexFor, HKT.OrFix<'K', C, KF>>, a: A ) => HKT.Kind> ) => ( wa: HKT.Kind ) => HKT.Kind> } export interface WitherWithIndexFn_ { (F: Applicative): < NF extends string, KF, QF, WF, XF, IF, SF, RF, EF, NG extends string, KG, QG, WG, XG, IG, SG, RG, EG, A, B >( wa: HKT.Kind, f: ( k: HKT.IndexFor, HKT.OrFix<'K', C, KF>>, a: A ) => HKT.Kind> ) => HKT.Kind> } export function implementWitherWithIndex(): ( i: (_: { A: A B: B G: G NF: NF FK: KF FQ: QF FW: WF FX: XF FI: IF FS: SF FR: RF FE: EF }) => ( G: Applicative> ) => ( f: (i: HKT.IndexFor, HKT.OrFix<'K', F, KF>>, a: A) => HKT.HKT> ) => ( wa: HKT.Kind ) => HKT.HKT> ) => WitherWithIndexFn export function implementWitherWithIndex() { return (i: any) => i() } export function implementWitherWithIndex_(): ( i: (_: { A: A B: B G: G NF: NF FK: KF FQ: QF FW: WF FX: XF FI: IF FS: SF FR: RF FE: EF }) => ( G: Applicative> ) => ( wa: HKT.Kind, f: (i: HKT.IndexFor, HKT.OrFix<'K', C, KF>>, a: A) => HKT.HKT> ) => HKT.HKT> ) => WitherWithIndexFn_ export function implementWitherWithIndex_() { return (i: any) => i() } export interface WiltWithIndexFn { (F: Applicative): < NG extends string, KG, QG, WG, XG, IG, SG, RG, EG, A, B, B2, NF extends string, KF >( f: ( k: HKT.IndexFor, HKT.OrFix<'K', C, KF>>, a: A ) => HKT.Kind> ) => ( wa: HKT.Kind ) => HKT.Kind< G, GC, NG, KG, QG, WG, XG, IG, SG, RG, EG, readonly [ HKT.Kind, HKT.Kind ] > } export interface WiltWithIndexFn_ { (F: Applicative): < NF extends string, KF, QF, WF, XF, IF, SF, RF, EF, NG extends string, KG, QG, WG, XG, IG, SG, RG, EG, A, B, B2 >( wa: HKT.Kind, f: ( k: HKT.IndexFor, HKT.OrFix<'K', C, KF>>, a: A ) => HKT.Kind> ) => HKT.Kind< G, GC, NG, KG, QG, WG, XG, IG, SG, RG, EG, readonly [ HKT.Kind, HKT.Kind ] > } export function implementWiltWithIndex(): ( i: (_: { A: A B: B B2: B2 G: G NF: NF FK: KF FQ: QF FW: WF FX: XF FI: IF FS: SF FR: RF FE: EF }) => ( G: Applicative> ) => ( f: (i: HKT.IndexFor, HKT.OrFix<'K', C, KF>>, a: A) => HKT.HKT> ) => ( wa: HKT.Kind ) => HKT.HKT< G, readonly [ HKT.Kind, HKT.Kind ] > ) => WiltWithIndexFn export function implementWiltWithIndex() { return (i: any) => i() } export function implementWiltWithIndex_(): ( i: (_: { A: A B: B B2: B2 G: G NF: NF FK: KF FQ: QF FW: WF FX: XF FI: IF FS: SF FR: RF FE: EF }) => ( G: Applicative> ) => ( wa: HKT.Kind, f: (i: HKT.IndexFor, HKT.OrFix<'K', C, KF>>, a: A) => HKT.HKT> ) => HKT.HKT< G, readonly [ HKT.Kind, HKT.Kind ] > ) => WiltWithIndexFn_ export function implementWiltWithIndex_() { return (i: any) => i() }