kongware / scriptum

Functional Programming Unorthodoxly Adjusted to Client-/Server-side Javascript
MIT License
383 stars 21 forks source link

Define `Eq` type class and implement all instances #377

Closed ivenmarquardt closed 1 year ago

ivenmarquardt commented 1 year ago

If we rely on the overloaded === operator we run into trouble with ad-hoc lazy evaluation powered by Proxy based thunks. The expression thunk === null, for instance, doesn't force the evaluation of thunk to weak head normal form because === doesn't provide a trap thunk's Proxy could hook into.

Eq should probably include eq/neq in two flavors, one with reference equality for object types as usual and another that pursues structural/value equality. The underlying issue will also be addressed by immutable records/tuples but this doesn't render the type class approach redundant.