"implementation is left-biased" - but fromList(With) is not
The actual behaviour of fromListWith surprised me, given the general "left-biased" feeling of the library.
I think I was expecting that these be equivalent
fromListWith (++) [ (0,"foo"), (1,"bar"), (0,"oof") ]
unionsWith (++) [ singleton 0 "foo", singleton 1 "bar", singleton 0 "oof" ]
but they are not. Perhaps add a warning in the documentation of fromListWith? Currently, you have to parse the example to infer the semantics.
Yes, this trips me up too. The idea is that it does a left fold with insert, which indeed is unexpected. Feel free to open a PR, or I'll try to fix it myself.
On Sep 4, 2016 5:32 AM, "jwaldmann" [email protected] wrote:
The actual behaviour of fromList surprised me, given the general "left-biased" feeling of the library. I think I was expecting that these be equivalent
fromListWith (++) [ (0,"foo"), (1,"bar"), (0,"oof") ] unionsWith (++) [ singleton 0 "foo", singleton 1 "bar", singleton 0 "oof" ]
but they are not. Perhaps add a warning in the documentation of fromListWith? Currently, you have to parse the example to infer the semantics.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/haskell/containers/issues/333, or mute the thread https://github.com/notifications/unsubscribe-auth/ABzi_R9-ewnRWJDxUaBBNkj0KYVn_RwIks5qmpBFgaJpZM4J0fuU .
Related: https://github.com/haskell-unordered-containers/unordered-containers/issues/264