Returns a function that checks equality with value