2 ms·
> Ocaml has both structural and referential equality tests automatically. Yep, and Ocaml equality is a giant pain. As for ==, referential equality is almost ne
by wyager 9y ago
> Ocaml has both structural and referential equality tests automatically.
Yep, and Ocaml equality is a giant pain. As for ==, referential equality is almost never what you want, so it’s (IMO) unwise to expose it except as an unsafe primitive. As for =, OCaml’s “polymorphic”/“structural” equality is usually wrong for any non-trivial data structure, so all the comparison-based standard library are functorized over comparison anyway. Use of polymorphic ‘=‘ is basically banned in the codebase I work on.
Haskell’s Eq/Ord typeclasses are vastly easier to use and harder to mess up. I think this particular use case is a more or less unambiguous win for typeclasses.