Skip to main content Link Search Menu Expand Document (external link)

Record overview

Added in v0.24.0


Table of contents


instances

Covariant

Signature

export declare const Covariant: covariant.Covariant<Record.ReadonlyRecordTypeLambda<K>>

Added in v0.24.0

Filterable

Signature

export declare const Filterable: filterable.Filterable<Record.ReadonlyRecordTypeLambda<K>>

Added in v0.24.0

Invariant

Signature

export declare const Invariant: invariant.Invariant<Record.ReadonlyRecordTypeLambda<K>>

Added in v0.24.0

Traversable

Signature

export declare const Traversable: traversable.Traversable<Record.ReadonlyRecordTypeLambda<K>>

Added in v0.24.0

TraversableFilterable

Signature

export declare const TraversableFilterable: traversableFilterable.TraversableFilterable<
  Record.ReadonlyRecordTypeLambda<K>
>

Added in v0.24.0

getCovariant

Signature

export declare const getCovariant: <K extends string>() => covariant.Covariant<Record.ReadonlyRecordTypeLambda<K>>

Added in v0.24.0

getFilterable

Signature

export declare const getFilterable: <K extends string>() => filterable.Filterable<Record.ReadonlyRecordTypeLambda<K>>

Added in v0.24.0

getInvariant

Signature

export declare const getInvariant: <K extends string>() => invariant.Invariant<Record.ReadonlyRecordTypeLambda<K>>

Added in v0.24.0

getMonoidUnion

A Monoid that creates a union of two records.

It allows combining two records where values for matching keys are combined using the provided Monoid instance. If a key exists in only one of the records, that key-value pair is included as is in the resulting record.

The empty value for this Monoid is an empty record {}.

Signature

export declare const getMonoidUnion: <A>(value: monoid.Monoid<A>) => monoid.Monoid<Record.ReadonlyRecord<string, A>>

Example

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

const monoid = getMonoidUnion(NumberInstances.MonoidSum)

assert.deepStrictEqual(monoid.combine({ a: 1 }, { a: 1, b: 3 }), { a: 2, b: 3 })
assert.deepStrictEqual(monoid.combine({ a: 1 }, monoid.empty), { a: 1 })

Added in v0.29.4

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.

Signature

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

Example

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

assert.deepStrictEqual(getSemigroupIntersection(NumberInstances.MonoidSum).combine({ a: 1 }, { a: 1, b: 3 }), { a: 2 })

Added in v0.29.4

getSemigroupUnion

A Semigroup that creates a union of two records.

This Semigroup takes two records and combines them into a single record. If a key exists in both records, the provided Semigroup instance is used to combine the values for that key. If a key exists in only one of the records, that key-value pair is included as is in the resulting record.

For example, when using the MonoidSum, values for matching keys will be summed.

Signature

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

Example

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

assert.deepStrictEqual(getSemigroupUnion(NumberInstances.MonoidSum).combine({ a: 1 }, { a: 1, b: 3 }), { a: 2, b: 3 })

Added in v0.29.4

getTraversable

Signature

export declare const getTraversable: <K extends string>() => traversable.Traversable<Record.ReadonlyRecordTypeLambda<K>>

Added in v0.24.0

getTraversableFilterable

Signature

export declare const getTraversableFilterable: <K extends string>() => traversableFilterable.TraversableFilterable<
  Record.ReadonlyRecordTypeLambda<K>
>

Added in v0.24.0