[m-dev.] map.map_values_foldl
Zoltan Somogyi
zoltan.somogyi at runbox.com
Sun Jun 8 11:02:03 AEST 2025
On 2024-06-11 17:11 +10:00 AEST, "Julien Fischer" <jfischer at opturion.com> wrote:
> On Mon, 10 Jun 2024 at 22:40, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
>>
>> 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?
>
> No, go ahead.
The attachec committed diff does the first half of this change:
adding the map_values_only_foldlN predicates.
Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.mvof
Type: application/octet-stream
Size: 231 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20250608/ea8847ca/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.mvof
Type: application/octet-stream
Size: 12141 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20250608/ea8847ca/attachment-0001.obj>
More information about the developers
mailing list