Effect CommunityEC
Effect Community2y ago
5 replies
whatplan

Question about `Equal.equals` and `Hash.hash` Behaviors

import { Equal, Data, Hash } from "effect";

class Bar extends Data.Class<{
  bar: string;
  baz: number;
  bil: {
    bar: string;
    baz: number;
  };
}> {}

const b1 = new Bar({ bar: "hello", baz: 42, bil: { bar: "world", baz: 24 } });
const b2 = new Bar({ bar: "hello", baz: 42, bil: { bar: "world", baz: 24 } });

console.log(Equal.equals(b1, b2)); // false?
console.log(Hash.hash(b1) === Hash.hash(b2)); // false?


is this intended behavior?
I swear the data implementations were deep equality
Was this page helpful?