<A>(isEquivalent: (self: A, that: A) => boolean): {
(a: A): (self: Chunk<A>) => boolean
(self: Chunk<A>, a: A): boolean
}Returns a function that checks if a Chunk contains a given value using a provided isEquivalent function.
Example (Checking membership with custom equivalence)
import { Chunk } from "effect"
const chunk = Chunk.make({ id: 1, name: "Alice" }, { id: 2, name: "Bob" })
// Custom equivalence by id
const containsById = Chunk.containsWith<{ id: number; name: string }>((a, b) =>
a.id === b.id
)
console.log(containsById(chunk, { id: 1, name: "Different" })) // true
console.log(containsById(chunk, { id: 3, name: "Charlie" })) // false
// Case-insensitive string comparison
const words = Chunk.make("Apple", "Banana", "Cherry")
const containsCaseInsensitive = Chunk.containsWith<string>((a, b) =>
a.toLowerCase() === b.toLowerCase()
)
console.log(containsCaseInsensitive(words, "apple")) // true
console.log(containsCaseInsensitive(words, "grape")) // falseexport const const containsWith: <A>(
isEquivalent: (self: A, that: A) => boolean
) => {
(a: A): (self: Chunk<A>) => boolean
(self: Chunk<A>, a: A): boolean
}
Returns a function that checks if a Chunk contains a given value using a provided isEquivalent function.
Example (Checking membership with custom equivalence)
import { Chunk } from "effect"
const chunk = Chunk.make({ id: 1, name: "Alice" }, { id: 2, name: "Bob" })
// Custom equivalence by id
const containsById = Chunk.containsWith<{ id: number; name: string }>((a, b) =>
a.id === b.id
)
console.log(containsById(chunk, { id: 1, name: "Different" })) // true
console.log(containsById(chunk, { id: 3, name: "Charlie" })) // false
// Case-insensitive string comparison
const words = Chunk.make("Apple", "Banana", "Cherry")
const containsCaseInsensitive = Chunk.containsWith<string>((a, b) =>
a.toLowerCase() === b.toLowerCase()
)
console.log(containsCaseInsensitive(words, "apple")) // true
console.log(containsCaseInsensitive(words, "grape")) // false
containsWith: <function (type parameter) A in <A>(isEquivalent: (self: A, that: A) => boolean): {
(a: A): (self: Chunk<A>) => boolean;
(self: Chunk<A>, a: A): boolean;
}
A>(
isEquivalent: (self: A, that: A) => booleanisEquivalent: (self: Aself: function (type parameter) A in <A>(isEquivalent: (self: A, that: A) => boolean): {
(a: A): (self: Chunk<A>) => boolean;
(self: Chunk<A>, a: A): boolean;
}
A, that: Athat: function (type parameter) A in <A>(isEquivalent: (self: A, that: A) => boolean): {
(a: A): (self: Chunk<A>) => boolean;
(self: Chunk<A>, a: A): boolean;
}
A) => boolean
) => {
(a: Aa: function (type parameter) A in <A>(isEquivalent: (self: A, that: A) => boolean): {
(a: A): (self: Chunk<A>) => boolean;
(self: Chunk<A>, a: A): boolean;
}
A): (self: Chunk<A>(parameter) self: {
length: number;
right: Chunk<A>;
left: Chunk<A>;
backing: Backing<A>;
depth: number;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface Chunk<out A>A Chunk is an immutable, ordered collection optimized for efficient concatenation and access patterns.
Example (Inspecting chunk values)
import { Chunk } from "effect"
const chunk: Chunk.Chunk<number> = Chunk.make(1, 2, 3)
console.log(chunk.length) // 3
console.log(Chunk.toArray(chunk)) // [1, 2, 3]
A namespace containing utility types for Chunk operations.
Example (Working with Chunk utility types)
import type { Chunk } from "effect"
// Extract the element type from a Chunk
declare const chunk: Chunk.Chunk<string>
type ElementType = Chunk.Chunk.Infer<typeof chunk> // string
// Create a preserving non-emptiness
declare const nonEmptyChunk: Chunk.NonEmptyChunk<number>
type WithString = Chunk.Chunk.With<typeof nonEmptyChunk, string> // Chunk.NonEmptyChunk<string>
Chunk<function (type parameter) A in <A>(isEquivalent: (self: A, that: A) => boolean): {
(a: A): (self: Chunk<A>) => boolean;
(self: Chunk<A>, a: A): boolean;
}
A>) => boolean
(self: Chunk<A>(parameter) self: {
length: number;
right: Chunk<A>;
left: Chunk<A>;
backing: Backing<A>;
depth: number;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface Chunk<out A>A Chunk is an immutable, ordered collection optimized for efficient concatenation and access patterns.
Example (Inspecting chunk values)
import { Chunk } from "effect"
const chunk: Chunk.Chunk<number> = Chunk.make(1, 2, 3)
console.log(chunk.length) // 3
console.log(Chunk.toArray(chunk)) // [1, 2, 3]
A namespace containing utility types for Chunk operations.
Example (Working with Chunk utility types)
import type { Chunk } from "effect"
// Extract the element type from a Chunk
declare const chunk: Chunk.Chunk<string>
type ElementType = Chunk.Chunk.Infer<typeof chunk> // string
// Create a preserving non-emptiness
declare const nonEmptyChunk: Chunk.NonEmptyChunk<number>
type WithString = Chunk.Chunk.With<typeof nonEmptyChunk, string> // Chunk.NonEmptyChunk<string>
Chunk<function (type parameter) A in <A>(isEquivalent: (self: A, that: A) => boolean): {
(a: A): (self: Chunk<A>) => boolean;
(self: Chunk<A>, a: A): boolean;
}
A>, a: Aa: function (type parameter) A in <A>(isEquivalent: (self: A, that: A) => boolean): {
(a: A): (self: Chunk<A>) => boolean;
(self: Chunk<A>, a: A): boolean;
}
A): boolean
} = import RARA.containsWith