import type { Applicative } from './Applicative' import type { Either } from './Either' import type { FilterableMin } from './Filterable' import type { Option } from './Option' import type { TraversableMin } from './Traversable' import { Filterable } from './Filterable' import * as HKT from './HKT' import { Traversable } from './Traversable' export interface Witherable extends Filterable, Traversable { readonly separateA_: WiltFn_ readonly separateA: WiltFn readonly compactA_: WitherFn_ readonly compactA: WitherFn } export type WitherableMin = FilterableMin & TraversableMin & { readonly separateA_: WiltFn_ readonly compactA_: WitherFn_ } export function Witherable(F: WitherableMin): Witherable { return HKT.instance({ ...Filterable(F), ...Traversable(F), separateA_: F.separateA_, separateA: (A) => { const separateA_ = F.separateA_(A) return (f) => (wa) => separateA_(wa, f) }, compactA_: F.compactA_, compactA: (A) => { const compactA_ = F.compactA_(A) return (f) => (wa) => compactA_(wa, f) } }) } export interface WitherFn { (F: Applicative): ( f: (a: A) => HKT.Kind> ) => ( wa: HKT.Kind ) => HKT.Kind> } export interface WitherFn_ { (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: (a: A) => HKT.Kind> ) => HKT.Kind> } export function implementWither(): ( i: (_: { A: A B: B G: G NF: NF FK: FK FQ: FQ FW: FW FX: FX FI: FI FS: FS FR: FR FE: FE }) => ( G: Applicative> ) => ( f: (a: A) => HKT.HKT> ) => ( wa: HKT.Kind ) => HKT.HKT> ) => WitherFn export function implementWither() { return (i: any) => i() } export function implementWither_(): ( i: (_: { A: A B: B G: G NF: NF FK: FK FQ: FQ FW: FW FX: FX FI: FI FS: FS FR: FR FE: FE }) => ( G: Applicative> ) => ( wa: HKT.Kind, f: (a: A) => HKT.HKT> ) => HKT.HKT> ) => WitherFn_ export function implementWither_() { return (i: any) => i() } export interface WiltFn { (F: Applicative): < NG extends string, KG, QG, WG, XG, IG, SG, RG, EG, A, B, B1 >( f: (a: A) => HKT.Kind> ) => ( wa: HKT.Kind ) => HKT.Kind< G, CG, NG, KG, QG, WG, XG, IG, SG, RG, EG, readonly [ HKT.Kind, HKT.Kind ] > } export interface WiltFn_ { (F: Applicative): < NF extends string, KF, QF, WF, XF, IF, SF, RF, EF, NG extends string, KG, QG, WG, XG, IG, SG, RG, EG, B1, A, B >( wa: HKT.Kind, f: (a: A) => HKT.Kind> ) => HKT.Kind< G, CG, NG, KG, QG, WG, XG, IG, SG, RG, EG, readonly [ HKT.Kind, HKT.Kind ] > } export function implementWilt(): ( i: (_: { A: A B: B B1: B1 G: G NF: NF KF: KF QF: QF WF: WF XF: XF IF: IF SF: SF RF: RF EF: EF }) => ( G: Applicative> ) => ( f: (a: A) => HKT.HKT> ) => ( wa: HKT.Kind ) => HKT.HKT< G, readonly [ HKT.Kind, HKT.Kind ] > ) => WiltFn export function implementWilt() { return (i: any) => i() }