Effect CommunityEC
Effect Community14mo ago
2 replies
Nostalgia

Equal for Recursive Structure

interface BinaryTreeNode<T> {
    value: T;
    left: BinaryTreeNode<T> | null;
    right: BinaryTreeNode<T> | null;
}

const BTree = Data.case<BinaryTreeNode<number>>()

const tree_2 = BTree({ value: 0, left: { value: 1, left: null, right: null }, right: null })
const tree_3 = BTree({ value: 0, left: { value: 1, left: null, right: null }, right: null })
Effect.runSync(Console.log(Equal.equals(tree_2, tree_3))) // false

Hello, I'm new to Effect and here a minimal code. Is this a intentional design for recursive structure? I read doc and it said that "two values created using these constructors are considered equal if they have the same structure and values."
Was this page helpful?