import type { Semigroup } from './Semigroup' import type { SemimonoidalFunctor } from './SemimonoidalFunctor' import * as HKT from './HKT' export interface SemigroupKind extends HKT.Base { readonly combine_: CombineKindFn_ readonly combine: CombineKindFn } export interface SemigroupKindComposition { readonly combine_: CombineKindFnComposition_ readonly combine: CombineKindFnComposition } export interface CombineKindFn_ { ( x: HKT.Kind, y: HKT.Kind< F, C, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, A > ): HKT.Kind< F, C, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, A > } export interface CombineKindFn { (y: HKT.Kind): < N extends string, K, Q, W, X, I, S, R, E >( x: HKT.Kind< F, C, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, A > ) => HKT.Kind< F, C, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, A > } export interface CombineKindFnComposition_ { < NF extends string, KF, QF, WF, XF, IF, SF, RF, EF, NG extends string, KG, QG, WG, XG, IG, SG, RG, EG, NF1 extends string, KF1, QF1, WF1, XF1, IF1, SF1, RF1, EF1, NG1 extends string, KG1, QG1, WG1, XG1, IG1, SG1, RG1, EG1 >( x: HKT.Kind< F, TCF, NF1, KF1, QF1, WF1, XF1, IF1, SF1, RF1, EF1, HKT.Kind >, y: HKT.Kind< F, TCF, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Kind< G, TCG, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, A > > ): HKT.Kind< F, TCF, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Kind< G, TCG, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, A > > } export interface CombineKindFnComposition { < NF1 extends string, KF1, QF1, WF1, XF1, IF1, SF1, RF1, EF1, NG1 extends string, KG1, QG1, WG1, XG1, IG1, SG1, RG1, EG1 >( y: HKT.Kind< F, CF, NF1, KF1, QF1, WF1, XF1, IF1, SF1, RF1, EF1, HKT.Kind > ): ( x: HKT.Kind< F, CF, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Kind< G, CG, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, HKT.Intro, A > > ) => HKT.Kind< F, CF, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Kind< G, CG, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, HKT.Mix, A > > } /* * ------------------------------------------- * Instances * ------------------------------------------- */ export function liftSemigroup( F: SemimonoidalFunctor ): (S: Semigroup) => SemigroupKind { return (S: Semigroup) => { const combine_: SemigroupKind['combine_'] = (fx, fy) => F.crossWith_(fx, fy, S.combine_) return HKT.instance>({ combine_, combine: (fy) => (fx) => combine_(fx, fy) }) } }