Argument order for Data.Map.adjustF
Akio Takano
tkn.akio at gmail.com
Thu May 12 05:11:23 UTC 2016
On 7 May 2016 at 20:45, David Feuer <david.feuer at gmail.com> wrote:
> I managed to find an implementation of Control.Lens.At.at for Data.Map
> that's fast enough to be useful. The function will be named alterF to match
> the name of Data.Map.alter. The remaining question is what order the
> arguments should go in. I had thought to follow those of alter for
> consistency, giving
>
> alterF :: (Functor f, Ord k) => (Maybe a -> f (Maybe a)) -> k -> Map k a ->
> f (Map k a)
I would vote for this order. The other order would be very surprising
for anyone who is familiar with other functions of this family.
Also I think this function is something a significant number of people
will use directly, not as a lens. alter is the most general way to
update the value for a key, and the need for its monadic variant will
come up from time to time. At least I wanted this function a few times
in the past.
Regards,
Takano Akio
More information about the Libraries
mailing list