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

contramapN should come from syntax.contravariant._ #3329

Open
mrdziuban opened this issue Feb 28, 2020 · 2 comments
Open

contramapN should come from syntax.contravariant._ #3329

mrdziuban opened this issue Feb 28, 2020 · 2 comments

Comments

@mrdziuban
Copy link
Contributor

When using a la carte imports, I need to import cats.syntax.apply._ to be able to call contramapN, but I expected to import cats.syntax.contravariant._. Here's a scastie to demonstrate: https://scastie.scala-lang.org/mrdziuban/IZmraJ4BRlugdmXfeUWoLg/3

@travisbrown
Copy link
Contributor

I was just taking a look at this, and contramapN also requires a Semigroupal instance, so you'll need contravariantSemigroupal instead of contravariant, which does work now:

import cats.Eq
import cats.instances.eq._
import cats.instances.int._
import cats.instances.string._
import cats.syntax.contravariantSemigroupal._

case class Test(i: Int, s: String)

(Eq[Int], Eq[String]).contramapN((t: Test) => (t.i, t.s))

The current behavior is still wrong, though. There's definitely no reason syntax.apply._ should bring in contramapN, or that syntax.contravariantSemigroupal._ should give you e.g. traverseN.

@vasilmkd
Copy link
Member

vasilmkd commented Jul 8, 2020

It seems that all of these syntax functions come from TupleSemigroupalSyntax.scala which is autogenerated boilerplate code. Any ideas on how this should be handled? Should these TupleNSemigroupalOps classes be split into smaller classes offering 1 method each? (e.g. one class for mapN, one for imapN, one for contramapN, etc.)

Edit: I only see this occur for tuples.

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

No branches or pull requests

3 participants