I've just been looking at the Data.Map function "fromListWith". According to the docs, it has the type:

* fromListWith* :: Ord <http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Ord.html#t%3AOrd> k => (a -> a -> a) -> [(k, a)] -> Map <http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Map.html#t%3AMap> k a

I'd have thought that a better type would be

* fromListWith* :: Ord <http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Ord.html#t%3AOrd> k => (a -> b -> b) -> [(k, a)] -> Map <http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Map.html#t%3AMap> k b

This wouldn't break any existing code, but would allow things like "fromListWith (:)" to do the Right Thing.

Would this be a sensible change (along with the other "with" functions in the module).

Paul.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to