Again, a slight change to the code leads to a compilation failure which I dont quite understand:
runs fine:
val one: OptionTransformer[Future, Int] = OptionTransformer(Future(Option(1)))
fails to compile:
val one: OptionTransformer[Future, Int] = OptionTransformer(Future(Some(1)))
[error]... no type parameters for method apply: (value: T[Option[A]])(implicit m: com.example.monadT.Monad[T])com.example.monadT.OptionTransformer[T,A] in object OptionTransformer exist so that it can be applied to arguments (scala.concurrent.Future[Some[Int]])
[error] --- because ---
[error] argument expression's type is not compatible with formal parameter type;
[error] found : scala.concurrent.Future[Some[Int]]
[error] required: ?T[Option[?A]]
[error] val one: OptionTransformer[Future, Int] = OptionTransformer(Future(Some(1)))
A method returning Future(Some(1)) does compile and run:
val getFO: (Int) => Future[Option[Int]] = (in) => Future.successful(Some(in + 1))
...
resultOne <- OptionTransformer(getFO(0))
Again, a slight change to the code leads to a compilation failure which I dont quite understand:
runs fine:
val one: OptionTransformer[Future, Int] = OptionTransformer(Future(Option(1)))fails to compile:
val one: OptionTransformer[Future, Int] = OptionTransformer(Future(Some(1)))A method returning
Future(Some(1))does compile and run: