Closed
Description
As discussed in https://gitter.im/lampepfl/dotty?at=6033a71be634904e60b71e22
Compiler version
3.0.0-RC1
Minimized code
trait Functor[F[_]] {
def map[A, B](fa: F[A]): F[B]
}
object data {
opaque type OptionT[F[_], A] = F[Option[A]]
extension [F[_], A](value: OptionT[F, A]) {
def fold[B](default: => B)(f: A => B)(using F: Functor[F]): F[B] =
F.map(value)(_.fold(default)(f))
def cata[B](default: => B, f: A => B)(using x: Functor[F]): F[B] =
fold(default)(f)(using x)
}
}
Output
Compiler error
[error] -- [E050] Type Error: /Users/tim/dev/cheetahs/core/src/main/scala/io/github/timwspence/cheetahs/data.scala:30:11
[error] 30 | F.map(value)(_.fold(default)(f))
[error] | ^^^^^^^^^^^^
[error] | method map in trait Functor does not take more parameters
[error] -- [E007] Type Mismatch Error: /Users/tim/dev/cheetahs/core/src/main/scala/io/github/timwspence/cheetahs/data.scala:33:29
[error] 33 | fold(default)(f)(using x)
[error] | ^
[error] |Found: (x : io.github.timwspence.cheetahs.Functor[F])
[error] |Required: io.github.timwspence.cheetahs.Functor[F²]
[error] |
[error] |where: F is a type in method cata with bounds <: [_$3] =>> Any
[error] | F² is a type variable with constraint >: [X0] =>> io.github.timwspence.cheetahs.data.OptionT[F, X0] | F[X0] and <: [_$3] =>> Any