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

Reducible examples are broken #4041

Closed
chessman opened this issue Nov 10, 2021 · 4 comments · Fixed by #4238
Closed

Reducible examples are broken #4041

chessman opened this issue Nov 10, 2021 · 4 comments · Fixed by #4238

Comments

@chessman
Copy link

https://typelevel.org/cats/typeclasses/reducible.html

def countChars(s: String) = s.toCharArray.groupBy(identity).mapValues(_.length)

Reducible[NonEmptyList].nonEmptyTraverse_(NonEmptyList.of("Hello", "World"))(countChars)
// res8: Map[Char, Unit] = Map('l' -> (), 'o' -> ())
Reducible[NonEmptyVector].nonEmptyTraverse_(NonEmptyVector.of("Hello", ""))(countChars)
// res9: Map[Char, Unit] = Map()

I tried to run those examples in Ammonite REPL and got:

cmd1.sc:1: Could not find an instance of Apply for [+V]scala.collection.MapView[Char,V]
val res1 = Reducible[NonEmptyList].nonEmptyTraverse_(NonEmptyList.of("Hello", "World"))(countChars)
                                                                                       ^
Compilation Failed
@LukaJCB
Copy link
Member

LukaJCB commented Nov 10, 2021

Good catch! This looks likely to be an issue with the collections api. We should change it from .mapValues(_.length) to .view.mapValues(_.length).toMap

@emilhotkowski
Copy link
Contributor

May I pick this up as my first contribution?

@armanbilge
Copy link
Member

armanbilge commented Jun 22, 2022

@emilhotkowski Thanks for volunteering. Actually, it seems I recently fixed this issue in #4238 without knowing it 😅

Sorry! But I hope you can find another issue to contribute ... if you're having trouble, let me know and we can find you something to work on. Contributions are very appreciated!

@emilhotkowski
Copy link
Contributor

I'm just glad it's fixed. I'll look for another task.

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 a pull request may close this issue.

4 participants