WIP: Change HasField to support updates
class HasField x r a | x r -> a where getField :: r -> a
class HasField x r a | x r -> a where hasField :: r -> (a -> r, a)
The essence of the implementation is described in
Note [Record updaters] and the updated
Note [HasField instances]. It follows the approach suggested by @simonpj in #16232, namely generating an updater function alongside the selector function. The
Name of this function is stored in
DataCon, hence the changes to
FieldLabel. I have not changed
mkRecSelBind to derive the selector binding from the updater, although in principle this is possible.
The commits are conceptually distinct steps but not individually buildable; I've kept them separate for ease of review/rebasing but I will squash them before merge.
Still to do: update the user docs. Now with user docs!