Hi guys. I wanted to let you know about ppx_update
. This is a small utility ppx that rewrites some record update expressions to make them more efficient.
When updating the contents of a record functionally, one might want to avoid reallocating the record if the contents haven’t changed. Similarly, when updating the contents of a mutable field of a record, one might want to avoid the cost of the write barrier in case the field content hasn’t changed. Instead of having to write error-prone code checking each field with physical equality, ppx_update
does the added physical comparisons for you behind the scenes.
You can install ppx_update
via opam
and easily apply it to your code with dune
.