Open samuelgruetter opened 3 years ago
For the records (apologies for the bad pun), I've started using the above Ltac2 hack in this file, so users of it don't need to declare any eta instances any more, and I also added support for OCaml-like syntax for updating several fields at once, eg { oldRecord with fieldC := true; fieldA ::= Nat.add 2 }
, as well as a simplifier that simplifies get-of-set, set-of-same-set, set-of-different-set, set-of-constructor, get-of-constructor etc. It's not yet tested & clean enough for a PR, but in case someone is about to reinvent that wheel, let it be known that some code already exists.
A while back, @JasonGross pointed out that you can obtain an eta expansion of a record's constructor without relying on user-provided typeclass instances like
and his solution looks as follows:
It creates an eta-expanded version of the constructor
mkX
:However, @tchajed (and myself, too) did not like that solution because it does not reuse the existing getters, but creates new ones.
Now, for those who like Ltac2 hacks, here's a way to obtain an eta-expanded constructor that does reuse the existing getters:
I haven't tried yet whether it could replace the current typeclass-based approach, nor spent any thought on whether such code is morally acceptable, but just wanted to paste it here for whoever might find it entertaining :wink: