Monadic version of functions for containers (adjustM, updateWithKeyM, etc)

Thomas DuBuisson thomas.dubuisson at gmail.com
Tue Sep 28 00:08:24 EDT 2010


Johan said:
>> Is there a reason not to have monadic version of the functions in
>> containers? I've a need for functions of type:
>
> Ack! Haskell needs effect polymorphism. The API already has 150
> functions. How many more do we need to add if we want to cover all the
> monadic versions?

If the number of functions becomes a concern we can be effective and
still conservative.  Take Data.Map as an example, we can make
updateLookupWithKeyM and omit alterM, alterWithKeyM,
insertLookupWithKeyM, etc as those can be built using
updateLookupWithKeyM - no power lost.  This strategy might cut the
number of functions down from ~2 dozen to a bare handful ( I expect a
'map' variant will be sensible, probably one or two others).

Cheers,
Thomas


More information about the Libraries mailing list