Welcome! Got a question? Do you have -Ypartial-unification turned on? Other FAQs: http://typelevel.org/cats/faq.html
final class Foo(val b: Boolean = true) extends AnyVal
trait Forall[F[_]] { def apply[A]: F[A] }
version is better than nothing.
Hm... I know implicit conversions are bad, but is
implicit def forallA[F[_], A](forall: ForAll[F]): F[A] = forall.apply[A]
bad?
traverseWithIndex
not traverseWithIndexM
?
zip
on two Mu[ListF[A, ?]]
using only catamorphisms :smile:
could not find implicit value for parameter e: cats.Applicative[R2]
mapN
with a function that operates on A
(only operating on the second element of the tuple), you'd need something like Nested
ValidatedNel[String,A]
then there was also an instance of ValidatedNel[String,(A,A)]
, but maybe I'm missing something...
ValidatedNel[String, A]
for all A
, you can then instantiate the A
type variable to any type, including (A, A)
. But the opposite is not true: if you look for ValidatedNel[String, (A, A)]
, ValidatedNel[String, A]
does not apply.
ValidatedNel
to show this, Option
is enough
(('a -> 1).some, ('b -> 2).some)).mapN { case ((x,y), (z,w)) => ???}
the compiler looks for Applicative[Option[?]]
, and after finding it, instantiates the A
(as in, there's an instance for Applicative[Option[A]]
forall A
s), to Tuple2[Symbol, Int]
.
ValidatedNel[String, (A, ?)]
, but that's different (and requires Nested
)
when you do implicitly[Applicative[R1]]
, you are saying, find me something of type [A] => Applicative[Option[A]]
; once you have this, you can specialise [A]
to (B, B)
. Given the the instance for Option
fits the shape [A] => Applicative[Option[A]]
, it compiles.
When you do implicitly[Applicative[R2]]
, you are saying, find me something of type [A] => Applicative[Option[(A,A]]
. The instance for Option
does not have this shape, so it doesn't compile.
* I'm using the fake type [A] => Foo[A]
to represent polymorphic methods def foo[A]: Foo[A]
, Scala does not have first class polymorphic functions
val m = mock[PageRepository[IO]].smart
m.tearDown returns IO { None }
and I get a codegen.java.lang.Object$MockitoMock$862296327 cannot be cast to cats.effect.IO
exception. Does anyone know how to fix this? I'm quite new to cats and I'm unsure how to solve this, especially since the IO
class is relatively new and I can't find anything about this issue on google :) thanks!