Sorry, but with this definition of equals in Value, g is not a function:Value(0,1) == Value(0,2), but g(Value(0, 1) != g(Value(0, 2)).This may bring a bigger discussion regarding how functions should preserve equality, but anyway, this example does not seem valid to me.