[m-dev.] map.map_values_foldl
Zoltan Somogyi
zoltan.somogyi at runbox.com
Mon Jun 10 22:40:29 AEST 2024
There is a bit of an inconsistency between map.map_values
and map.map_values_foldl. The predicate that expected to be passed
to map.map_values has the signature pred(K, V, W), where K is the key type
of the map, and V and W are the value types in the initial and final maps
respectively. There is a separate map.map_values_only predicate
which expects a predicate with the signature pred(V, W). So the
predicate being mapped
- has a K parameter in map.map_values, but
- has no K parameter in map.map_values_only.
That works. Sometimes you need the K parameter, and sometimes
you don't, in which case having to add an always-ignored argument
to the predicate you would pass to map.map_values would be
an annoyance.
The problem is that map.map_values_foldl, and map.map_values_foldlN
for N=2, 3 do not follow this convention. They all take a predicate
whose signature lacks the K paramater. This makes the naming scheme
inconsistent.
The obvious fix would be to rename those three predicates by doing
s/values/values_only/, and reuse their old names for versions that
expect predicates that do take a K parameter. This would be a breaking
change, though the break would be trivially fixable by a rename.
Would anyone object if I made that change?
Zoltan.
More information about the developers
mailing list