Skip to content

Commit

Permalink
use Functor[SortedMap[B, ?]].map instead of mapValues
Browse files Browse the repository at this point in the history
  • Loading branch information
pk044 committed May 26, 2020
1 parent 3d9b795 commit 4ca92bb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/main/scala/cats/syntax/list.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cats
package syntax

import cats.data.{NonEmptyChain, NonEmptyList}

import scala.collection.immutable.SortedMap

trait ListSyntax {
Expand Down Expand Up @@ -73,7 +72,9 @@ final class ListOps[A](private val la: List[A]) extends AnyVal {
implicit val ordering: Ordering[B] = B.toOrdering

toNel.fold(F.pure(SortedMap.empty[B, NonEmptyList[A]]))(nel =>
F.map(nel.traverse(a => F.tupleLeft(f(a), a)))(_.groupBy(_._2).mapValues(_.map(_._1)))
F.map(nel.traverse(a => F.tupleLeft(f(a), a)))(list =>
Functor[SortedMap[B, ?]].map(list.groupBy(_._2))(_.map(_._1))
)
)
}

Expand Down

0 comments on commit 4ca92bb

Please sign in to comment.