Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe provide an escape hatch for UnorderedTraverse's commutative requirement #2516

Open
LukaJCB opened this issue Sep 19, 2018 · 1 comment

Comments

@LukaJCB
Copy link
Member

LukaJCB commented Sep 19, 2018

A question that comes up a LOT in the gitter room is how to traverse a Map, our standard answer is that you can't unless you import alleycats instances or use SortedMap instead.

UnorderedFoldable and UnorderedTraverse are a very principled way of dealing with this issue, but maybe there needs to be a way to relax the strict requirement of commutativity.
I'm not exactly sure how best to address this issue, the only thing I can think of right now is to allow a traverseDontCareABoutOrdering, but that's hardly optimal either. Interested to hear more thoughts.

@johnynek
Copy link
Contributor

Well I guess with a CommutativeApplicative it is okay too.

We could add a method using that and try to make sure as many as possible of the Applicative/Monad follow this.

I can see adding a method to Alleycats like traverseMap and sequenceMap which internally uses the unsafe traverse instance. This way users don’t import and unsafe instance and instead use an unsafe method at a particular call site.

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

No branches or pull requests

2 participants