effect-io-ai

Package: @effect/typeclass
Module: Record

Record.getSemigroupIntersection

A Semigroup that creates an intersection of two records.

This Semigroup takes two records and combines them into a new record containing only the keys that are present in both records. The values for matching keys are combined using the provided Semigroup instance.

Example

import * as NumberInstances from "@effect/typeclass/data/Number"
import { getSemigroupIntersection } from "@effect/typeclass/data/Record"

console.log(getSemigroupIntersection(NumberInstances.MonoidSum).combine({ a: 1 }, { a: 1, b: 3 }))
// { a: 2 }

Signature

declare const getSemigroupIntersection: <A>(value: semigroup.Semigroup<A>) => semigroup.Semigroup<Record.ReadonlyRecord<string, A>>

Source

Since v0.29.4