Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.
Docs menu / Equivalence

Schema to Equivalence

The Schema.equivalence function allows you to generate an Equivalence based on a schema definition. This function is designed to compare data structures for equivalence according to the rules defined in the schema.

Example (Comparing Structs for Equivalence)

import { Schema } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number,
})
// Generate an equivalence function based on the schema
const PersonEquivalence = Schema.equivalence(Person)
const john = { name: "John", age: 23 }
const alice = { name: "Alice", age: 30 }
// Use the equivalence function to compare objects