rcl/golden
Ruud van Asseldonk 258f0e2384 Rename Set.{map,flat_map}, add _dedup suffix
The map function in particular is a footgun that hit me twice in two
weeks, in a case similar to this one:

    {"apple", "orange", "banana"}.map(x => x.len()).sum()

This looks like it sums the lengths of the strings. Except it doesn't,
it sums the *unique* lengths of the strings, so we get 11 instead of 17.
That's surprising, and I don't want that kind of surprise in RCL.

At first I thought to remove Set.map and Set.flat_map entirely. You
would just have to convert to a list first and map there, and if you
wanted the set, convert back with List.to_set_dedup, which makes it
explicit. That's why I added these conversion functions. Then I
implemented deletion ... and as I was writing the PR description and
changelog entry for how to handle the break, it dawned on me, if we
have the _dedup anyway in to_set_dedup, we might as well use it here.
We don't have to delete these methods, we can just call them _dedup.

    {"apple", "orange", "banana"}.map_dedup(x => x.len()).sum()

Now the snippet is no longer so sneaky! It's clear that there is
deduplication going on! So I'm fine keeping them in this form. At least
in the Nix transitive closure test, the map_dedup behavior is what I
want, which validates demand for at least map_dedup. But even then,
a changelog entry for a breaking change that says "renamed to X" is a
much better experience than "have been deleted here are some much longer
alternatives".

Also, this change is relatively safe to make: it will break existing
callers, but they will get an error message and there is a clear path
to fixing this. It doesn't silently change the output of something: it's
being called on sets, so there can't even be fields named 'map' or
'flat_map' because sets don't have fields. So I feel comfortable making
a small breaking change here.
2025-12-17 19:28:26 +01:00
..
build Update and extend golden tests for Int->Number rename 2025-02-24 20:42:59 +01:00
cmd Use ':' in assertions rather than ',' 2025-09-29 20:28:15 +02:00
error Add goldens to cover new List and Set methods 2025-12-14 19:50:20 +01:00
error_json Use ':' in assertions rather than ',' 2025-09-29 20:28:15 +02:00
error_raw Add golden tests for raw output 2023-12-21 23:00:32 +01:00
fmt Allow comments after '=>' in functions 2025-12-13 16:00:04 +01:00
html Highlight null and bool as keyword in fmt output 2024-06-25 23:13:00 +02:00
json Use ':' in assertions rather than ',' 2025-09-29 20:28:15 +02:00
json_lines Add goldens for json-lines output format 2025-06-30 22:49:37 +02:00
raw Add golden tests for raw output 2023-12-21 23:00:32 +01:00
rcl Rename Set.{map,flat_map}, add _dedup suffix 2025-12-17 19:28:26 +01:00
toml Save body span info in the loader 2024-06-18 20:22:33 +02:00
types Rename 'scalar' to 'single' in error messages 2025-11-22 21:33:24 +01:00
yaml_stream Add yaml-stream output format 2024-02-19 19:02:41 +01:00
run.py Support arbitrary commands in goldens, test patch 2025-08-25 22:58:11 +02:00