-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
contramap on Function1 broke between 0.9 to 1.0.0-MF #1850
Comments
In 0.9.0 it works due to |
For those wondering how @durban figured out that it worked with scala> scala.reflect.runtime.universe.reify {
((_: Int).toString).contramap((_: Int) * 2)
}
res0: reflect.runtime.universe.Expr[Int => String] = Expr[Int => java.lang.String](
`package`.contravariant.catsSyntaxUContravariant(((x$1: Int) => (x$1: Int).toString()))(
Unapply.catsUnapply2left(`package`.function.catsStdContravariantForFunction1)
).contramap(((x$2: Int) => (x$2: Int).$times(2)))
)
|
Yes, that's a useful thing to know; although I've used |
This is due to the fact that the
Contravariant[? => B].contramap(f)(...) Update: as suggested by @edmundnoble below I see a couple of options ahead.
What do you guys think? |
I'd say 1. is our best option here. Unapply has a huge cost in compilation time and doesn't scale to different arities. In general, the story for type classes in multiple type parameters is bad, in every functional programming language I know of. Afaik the best solution for now is to just need a type class which combines every type class for every type parameter of the type constructor, like in this case Profunctor, specifically using |
In cats 0.9 you could call
.contramap
on aFunction1[A,R]
. In 1.0.0-MF it no longer works. @sellout hypothesised that there might have been an explicit method onFunction1Ops
.Discussion happened here: https://gitter.im/typelevel/cats?at=599dfc7e19147ac32315dcc7
The text was updated successfully, but these errors were encountered: