Skip to content

[WIP] Add an UnorderedFoldable that we can give instances for Set/Map/&c - #2021

Closed
hrhino wants to merge 1 commit into
typelevel:masterfrom
hrhino:feature/unordered-things
Closed

[WIP] Add an UnorderedFoldable that we can give instances for Set/Map/&c#2021
hrhino wants to merge 1 commit into
typelevel:masterfrom
hrhino:feature/unordered-things

Conversation

@hrhino

@hrhino hrhino commented Nov 9, 2017

Copy link
Copy Markdown
Contributor

Set, e.g., is not a lawful Foldable, since iteration order between multiple sets can be observed via toList. If we promise never to observe the order in which elements are folded, by strengthening the Monoid required by foldMap to a CommutativeMonoid, we can have a broader type class UnorderedFoldable that contains such unordered collections.

I mentioned this on gitter and no one said no. It's a work in progress:

  • The name is bikesheddable debatable
  • I need to add more tests, and possibly more instances
  • We presumably need an UnorderedFoldableSuite somewhere in there
  • Does this imply a TraverseRandomly UnorderedTraverse?

but I'm making a PR so people can say what they think about the idea before I put any more effort into it, rather than after.

…/&c.

`Set`, e.g., is not a lawful `Foldable`, since iteration order
between multiple sets can be observed via `toList`. If we promise
never to observe the order in which elements are folded, by
strengthening the `Monoid` required by `foldMap` to a `CommutativeMonoid`,
we can have a broader typeclass `UnorderedFoldable` that contains
such unordered collections.

Based entirely off a gitter comment.
@kailuowang

Copy link
Copy Markdown
Contributor

Are you aware of #1981?

@hrhino

hrhino commented Nov 9, 2017

Copy link
Copy Markdown
Contributor Author

Mm... Now I am. Sorry about that!

@hrhino hrhino closed this Nov 9, 2017
@kailuowang

Copy link
Copy Markdown
Contributor

@hrhino no worries at all. If you are interested in the topic, a review of #1981 from you will be greatly appreciated.

@kailuowang kailuowang added this to the 1.0.0 milestone Nov 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants