Skip to content

Undocumented change to Set.from{Asc,Desc}List in containers-0.8? #1118

Closed
@jonathanknowles

Description

@jonathanknowles

There seems to be a small difference in the behaviour of Set.from{Asc,Desc}List between containers-0.7 and containers-0.8, specifically when these functions are applied to lists with duplicate elements.

  • In containers-0.7 these functions keep the first of any duplicates.
  • In containers-0.8 these functions keep the last of any duplicates.

I'm guessing the change was introduced in #1083, which fixes #1032.

As I understand it, this change makes the behaviour of Set.from{Asc,Desc}List more consistent with the equivalent Map.from{Asc,Desc}List functions, which seems very reasonable!

Though perhaps we could add something about this to the changelog for 0.8? (Even though this behaviour was previously unspecified!)

Perhaps something like this:

Breaking changes

  • The fromAscList and fromDescList functions for Set, when applied to lists with duplicate elements, now keep the last of any duplicates. This is a change from the behaviour of containers-0.7, where these functions would keep the first of any duplicates. The new behaviour is now consistent with the equivalent functions for Map, which also keep the last of any key-value mappings that share a duplicate key.

If people are happy with this wording (or similar), I'd be happy to create a PR to add it.

I ran into this while looking at nonempty-containers, which is affected by this change. See:

I'm guessing that other downstream libraries could also be affected. (But I don't currently have other examples to share.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions