Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions core/src/main/scala/cats/Foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1073,13 +1073,22 @@ object Foldable {
typeClassInstance.traverseVoid[G, A, B](self)(f)(G)
def traverse_[G[_], B](f: A => G[B])(implicit G: Applicative[G]): G[Unit] =
traverseVoid[G, B](f)
// TODO: looks like these two methods below duplicate the same named methods from `NestedFoldableOps`.
// Moreover, the other two methods take precedence, thereby these two are not in use whatsoever.
// Perhaps it makes sense to deprecate one pair of them either here or there.
@deprecated(
"Use catsSyntaxNestedFoldable (via cats.syntax.all._) to call sequenceVoid on F[G[A]]",
"2.13.0"
)
def sequenceVoid[G[_], B](implicit ev$1: A <:< G[B], ev$2: Applicative[G]): G[Unit] =
typeClassInstance.sequenceVoid[G, B](self.asInstanceOf[F[G[B]]])
@deprecated(
"Use catsSyntaxNestedFoldable (via cats.syntax.all._) to call sequence_ on F[G[A]]",
Comment on lines +1077 to +1083
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation message suggests switching to catsSyntaxNestedFoldable/cats.syntax.all._, but these deprecated methods are selected specifically when the receiver is typed as F[A] with only an A <:< G[B] evidence (i.e., not an F[G[B]]), where NestedFoldableOps will not apply. Consider updating the message to a replacement that compiles in that scenario (e.g., using traverseVoid(ev$1) / traverse_ for sequencing).

Suggested change
"Use catsSyntaxNestedFoldable (via cats.syntax.all._) to call sequenceVoid on F[G[A]]",
"2.13.0"
)
def sequenceVoid[G[_], B](implicit ev$1: A <:< G[B], ev$2: Applicative[G]): G[Unit] =
typeClassInstance.sequenceVoid[G, B](self.asInstanceOf[F[G[B]]])
@deprecated(
"Use catsSyntaxNestedFoldable (via cats.syntax.all._) to call sequence_ on F[G[A]]",
"Use traverseVoid(ev$1) or traverse_(ev$1) for sequencing when you have evidence A <:< G[B].",
"2.13.0"
)
def sequenceVoid[G[_], B](implicit ev$1: A <:< G[B], ev$2: Applicative[G]): G[Unit] =
typeClassInstance.sequenceVoid[G, B](self.asInstanceOf[F[G[B]]])
@deprecated(
"Use traverse_(ev$1) for sequencing when you have evidence A <:< G[B].",

Copilot uses AI. Check for mistakes.
"2.13.0"
)
def sequence_[G[_], B](implicit ev$1: A <:< G[B], ev$2: Applicative[G]): G[Unit] =
sequenceVoid[G, B]
Comment on lines +1082 to 1087
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as sequenceVoid: the suggested migration in the deprecation message (catsSyntaxNestedFoldable) may not be applicable when this overload is chosen (receiver not typed as F[G[_]]). Consider pointing users to a replacement that works with the existing A <:< G[B] evidence (e.g., traverse_(ev$1) / traverseVoid(ev$1)).

Copilot uses AI. Check for mistakes.
@deprecated(
"Use catsSyntaxNestedFoldable (via cats.syntax.all._) to call foldK on F[G[A]]",
"2.13.0"
)
def foldK[G[_], B](implicit ev$1: A <:< G[B], G: MonoidK[G]): G[B] =
typeClassInstance.foldK[G, B](self.asInstanceOf[F[G[B]]])(G)
Comment on lines +1088 to 1093
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation message points users at catsSyntaxNestedFoldable, but this foldK overload is picked when the value is not statically F[G[B]] (only A <:< G[B]). A migration hint that works in that case would be more actionable (e.g., foldMap(ev$1)(G.algebra[B]) using the existing MonoidK[G]).

Copilot uses AI. Check for mistakes.
def find(f: A => Boolean): Option[A] = typeClassInstance.find[A](self)(f)
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/scala/cats/syntax/foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ private[syntax] trait FoldableSyntaxBinCompat1 {
}

final class NestedFoldableOps[F[_], G[_], A](private val fga: F[G[A]]) extends AnyVal {
// TODO: looks like these two methods below duplicate the same named methods from `Foldable.Ops`.
// Perhaps it makes sense to deprecate one pair of them either here or there.
def sequenceVoid(implicit F: Foldable[F], G: Applicative[G]): G[Unit] = F.sequenceVoid(fga)
def sequence_(implicit F: Foldable[F], G: Applicative[G]): G[Unit] = sequenceVoid

Expand All @@ -64,8 +62,6 @@ final class NestedFoldableOps[F[_], G[_], A](private val fga: F[G[A]]) extends A
* res0: Set[Int] = Set(1, 2, 3, 4)
* }}}
*/
// TODO: looks like this method below duplicate the same named one from `Foldable.Ops`.
// Perhaps it makes sense to deprecate one of them.
def foldK(implicit F: Foldable[F], G: MonoidK[G]): G[A] = F.foldK(fga)
}

Expand Down
Loading