Hi all,
I’m trying to figure out the correct syntax to concatenate two functor opertor. This is my code snippet:
def calcolaFA : Option[String] = {
val optionValue : Option[Int] = Some(5);
val result : Option[String] = optionValue.map(item => item + 1).
map(item => item.toString);
val applicativeValue : Option[String] = optionValue <*> {item : Option[Int] => item.getOrElse(0).toInt + 1} <*> {item : Option[Int] => item.toString};
println("Il valore di result è: " + result);
println("Il valore di applicativeValue è: " + applicativeValue);
return applicativeValue;
}
And this is the sbt error output:
type mismatch;
[error] found : Option[Int] => Int
[error] required: Option[?]
[error] val applicativeValue : Option[String] = optionValue <*> {item : Option[Int] => item.getOrElse(0).toInt + 1} <*> {item : Option[Int] => item.toString};
Someone of you is aware of cats and could please help me?
Thank you !