Skip to content

fromListWith is confusing #264

@sjakobi

Description

@sjakobi
Member

This is rather surprising:

> fromListWith (++) [(False,"x"),(False,"y")]
fromList [(False,"yx")]

"Intuitively", the value in the result should be "xy".

Note that the versions of fromListWith[Key] in Data.Map and Data.IntMap from containers have the same issue.

Activity

sjakobi

sjakobi commented on Jun 2, 2020

@sjakobi
MemberAuthor

@treeowl suggested less ambiguous types for versions of fromListWithKey in #246 (comment):

flwk
  :: (Hashable k, Eq k)
  => (k -> Maybe b -> a -> Box b) -> [(k,a)] -> HashMap k b

(where data Box a = Box a)

flwkm
  :: (Hashable k, Eq k)
  => (k -> Maybe b -> a -> Maybe b) -> [(k,a)] -> HashMap k b
sjakobi

sjakobi commented on Jun 3, 2020

@sjakobi
MemberAuthor

FWIW, there's another issue about fromListWith, but that one seems to be primarily concerned with performance: #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sjakobi

        Issue actions

          fromListWith is confusing · Issue #264 · haskell-unordered-containers/unordered-containers