Type / Value equality utils.
It'd be helpful to know if too instances of the same type had value equality and case equality without peering into the underlying structure.
For example, in superouter, you might want to know if a generated Route
object from a href is the same .case
as the active route in the state
tree. You can just go route.case == state.route.case
but then if they are different types it will not error.
Maybe stags.equals
is type+case+value equality. And stags.caseEquals
is type+case
equality.
When dealing with equality for the value
I don't want to rely on reference equality, but I also don't want stags to have a copy of R.equals
in the library. caseEquals
is easy to ship so we should do that first. .equals
may have a visitor function for testing equality for the value only:
stags.equals (R.equals) (
Route.of.Example({ a: 1 }),
Route.of.Example({ a: 2 })
)
But at that point, you may as well just use R.equals
, it will work exactly the same, and I don't want to encourage the use of ==
as stags is all about reference equality being a footgun (serialization).
So maybe caseEquals
is all we ever need?
Maybe you could have a stags.compareValue
stags.compareValue ( (route1,route2) => route1.a == route2.a ) ( route1, route 2)
I'm not sure...