Hello everyone I have a problem like that:
implicit class mapValue[T](f: Future[T]){
def mapValue[T]( f: Future[T] )(implicit ec: ExecutionContext): Future[Try[T]] = {
val prom = Promise[Try[T]]()
f onComplete prom.success
prom.future
}
}
implicit class traverseFilteringErrors[A, B](seq: Seq[A])(f: A => Future[B]){ // >*It says implicit class must have a primary constructor with exactly one argument in first parameter list here
def traverseFilteringErrors[A, B](seq: Seq[A])(f: A => Future[B])(implicit ec: ExecutionContext): Future[Seq[B]] = {
Future.traverse( seq )( f andThen mapValue ) map ( _ collect{ case Success( x ) => x } ) // >and Type mismatch. Required: Future[B] => NotInferredA, found: Future[Nothing] => mapValue[Nothing] here.
}
}
It says:
implicit class must have a primary constructor with exactly one argument in first parameter list at def traverseFilteringErrors
and
Type mismatch. Required: Future[B] => NotInferredA, found: Future[Nothing] => mapValue[Nothing] at f and Then mapValue part
I'm new to scala so what should I do to fix the problem?