
Johan Tibell wrote:
Thomas DuBuisson wrote:
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?
I think this problem should be solved by making the API more general/flexible, not by adding more specialized versions. For instance, the function focus :: k -> Map k a -> (Maybe a, Maybe a -> Map k a) that returns the element together with its context ("map with a hole where the element was") can express all the insert, update etc. functions as well as their monadic versions. You can also use it for lookup , though that has a performance cost since the context is generated and then discarded. Of course, there ought to be a optimization pass that can catch these situations with a few hints and eliminate the superfluous work. Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com