Skip to content
Effect Days 2026 Get your ticket

SemiProduct

8 exports Added in v0.24.0 Source

Constructors

productMany

Added in v0.24.0 Source

Returns a default productMany implementation.

Signature

declare function productMany<F extends TypeLambda>(map: {
<A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>;
<R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Kind<F, R, O, E, B>;
}, product: <R1, O1, E1, A, R2, O2, E2, B>(self: Kind<F, R1, O1, E1, A>, that: Kind<F, R2, O2, E2, B>) => Kind<F, R1 & R2, O1 | O2, E1 | E2, [A, B]>): <R, O, E, A>(self: Kind<F, R, O, E, A>, collection: Iterable<Kind<F, R, O, E, A>>) => Kind<F, R, O, E, [A, ...Array<A>]>

Do Notation

andThenBind

Added in v0.24.0 Source

Signature

declare function andThenBind<F extends TypeLambda>(F: SemiProduct<F>): {
<N extends string, A extends object, R2, O2, E2, B>(name: Exclude<N, keyof A>, that: Kind<F, R2, O2, E2, B>): <R1, O1, E1>(self: Kind<F, R1, O1, E1, A>) => Kind<F, R1 & R2, O2 | O1, E2 | E1, { [K in string | number | symbol]: K extends keyof A ? A[K] : B }>;
<R1, O1, E1, A extends object, N extends string, R2, O2, E2, B>(self: Kind<F, R1, O1, E1, A>, name: Exclude<N, keyof A>, that: Kind<F, R2, O2, E2, B>): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in string | number | symbol]: K extends keyof A ? A[K] : B }>;
}

Other

appendElement

Added in v0.24.0 Source

Appends an element to the end of a tuple.

Signature

declare function appendElement<F extends TypeLambda>(F: SemiProduct<F>): {
<R2, O2, E2, B>(that: Kind<F, R2, O2, E2, B>): <R1, O1, E1, A extends readonly Array<any>>(self: Kind<F, R1, O1, E1, A>) => Kind<F, R1 & R2, O2 | O1, E2 | E1, [...Array<A>, B]>;
<R1, O1, E1, A extends readonly Array<any>, R2, O2, E2, B>(self: Kind<F, R1, O1, E1, A>, that: Kind<F, R2, O2, E2, B>): Kind<F, R1 & R2, O1 | O2, E1 | E2, [...Array<A>, B]>;
}

nonEmptyStruct

Added in v0.24.0 Source

Signature

declare function nonEmptyStruct<F extends TypeLambda>(F: SemiProduct<F>): <R extends {
[x: string]: Kind<F, any, any, any, any>;
}>(fields: EnforceNonEmptyRecord<R> & {
[x: string]: Kind<F, any, any, any, any>;
}) => Kind<F, [R[keyof R]] extends [Kind<F, R, any, any, any>] ? R : never, [R[keyof R]] extends [Kind<F, any, O, any, any>] ? O : never, [R[keyof R]] extends [Kind<F, any, any, E, any>] ? E : never, { [K in string | number | symbol]: [R[K]] extends [Kind<F, any, any, any, A>] ? A : never }>

nonEmptyTuple

Added in v0.24.0 Source

Signature

declare function nonEmptyTuple<F extends TypeLambda>(F: SemiProduct<F>): <T extends readonly [Kind<F, any, any, any, any>, Kind<F, any, any, any, any>]>(...elements: T) => Kind<F, [T[number]] extends [Kind<F, R, any, any, any>] ? R : never, [T[number]] extends [Kind<F, any, O, any, any>] ? O : never, [T[number]] extends [Kind<F, any, any, E, any>] ? E : never, { [I in string | number | symbol]: [T[I]] extends [Kind<F, any, any, any, A>] ? A : never }>

Returns a default product composition.

Signature

declare function productComposition<F extends TypeLambda, G extends TypeLambda>(F: SemiApplicative<F>, G: SemiProduct<G>): <FR1, FO1, FE1, GR1, GO1, GE1, A, FR2, FO2, FE2, GR2, GO2, GE2, B>(self: Kind<F, FR1, FO1, FE1, Kind<G, GR1, GO1, GE1, A>>, that: Kind<F, FR2, FO2, FE2, Kind<G, GR2, GO2, GE2, B>>) => Kind<F, FR1 & FR2, FO1 | FO2, FE1 | FE2, Kind<G, GR1 & GR2, GO1 | GO2, GE1 | GE2, [A, B]>>

Returns a default productMany composition.

Signature

declare function productManyComposition<F extends TypeLambda, G extends TypeLambda>(F: SemiApplicative<F>, G: SemiProduct<G>): <FR, FO, FE, GR, GO, GE, A>(self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>, collection: Iterable<Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>>) => Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, [A, ...Array<A>]>>

Type Class

SemiProduct interface

Added in v0.24.0 Source

Signature

interface SemiProduct<F extends TypeLambda> extends Invariant<F> {
readonly product: <R1, O1, E1, A, R2, O2, E2, B>(self: Kind<F, R1, O1, E1, A>, that: Kind<F, R2, O2, E2, B>) => Kind<F, R1 & R2, O1 | O2, E1 | E2, [A, B]>;
readonly productMany: <R, O, E, A>(self: Kind<F, R, O, E, A>, collection: Iterable<Kind<F, R, O, E, A>>) => Kind<F, R, O, E, [A, ...Array<A>]>;
}