with Serializable final case class Left[+A, +B](a: A) extends Either[A, B] final case class Right[+A, +B](b: B) extends Either[A, B] https://github.com/scala/scala/blob/d6f66ec0f38e42c19f79cbe9d32d29c65dee1e05/src/library/scala/util/ Either.scala#L69 https://github.com/scala/scala/blob/d6f66ec0f38e42c19f79cbe9d32d29c65dee1e05/src/library/scala/util/ Either.scala#L182-L202
+ 1 } yield b <console>:24: error: value map is not a member of Product with Serializable with scala.util.Either[Nothing,(Int, Int)] a <- Right(1).right FJUIFS͔Βग़͖ͯͨΛӈࣜʹ࣋ͭ࣌
yield a + b <console>:19: error: constructor cannot be instantiated to expected type; found : (T1, T2) required: scala.util.Either[Nothing,(Int, Int)] (a, b) <- Right((1, 2)).right ^
0 } yield a) match { case Right(num) => println(num) case Left(_) => println("left!!") } <console>:28: error: constructor cannot be instantiated to expected type; found : scala.util.Right[A,B] required: Option[scala.util.Either[Nothing,Int]] case Right(n) => println(n) ύλʔϯϚον͡Όͳ͍͚Ͳ͜Εμϝ
true case _ => false }).map(_ match { case (a, b) => a + b }) <console>:19: error: constructor cannot be instantiated to expected type; found : (T1, T2) required: scala.util.Either[Nothing,(Int, Int)] (a, b) <- Right((1, 2)).right ^
B]] = e match { case Left(_) => None case Right(b) => if(p(b)) Some(Right(b)) else None } https://github.com/scala/scala/blob/d6f66ec0f38e42c19f79cbe9d32d29c65dee1e05/src/library/ scala/util/Either.scala#L546-L549
B]] = e match { case Left(_) => None case Right(b) => if(p(b)) Some(Right(b)) else None } https://github.com/scala/scala/blob/d6f66ec0f38e42c19f79cbe9d32d29c65dee1e05/src/library/ scala/util/Either.scala#L546-L549
true case _ => false }).map(_ match { case (a, b) => a + b }) <console>:19: error: constructor cannot be instantiated to expected type; found : (T1, T2) required: scala.util.Either[Nothing,(Int, Int)] (a, b) <- Right((1, 2)).right ^ Either[Nothing, (Int, Int)]
final case class -\/[+A](a: A) extends (A \/ Nothing) final case class \/-[+B](b: B) extends (Nothing \/ B) scala.Either ͱҧͬͯ scalaz.\/ ʹ map flatMap ͕ੜ ͑ͯΔʂ
Boolean) (implicit M: Monoid[AA]): (AA \/ B) = this match { case -\/(_) => this case \/-(b) => if(p(b)) this else -\/(M.zero) } https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/main/scala/scalaz/ Either.scala#L145-L150
ೋ߲ԋࢉ ͕ू߹ʹ͍ͭͯด͍ͯ͡Δ (ೋ߲ԋࢉͷҾͱฦΓͷܕ͕ಉ͡) 2. ԋࢉ͕݁߹Λຬͨ͢ (a |+| b) |+| c == a |+| (b |+| c) 3. ୯Ґݩe ͕ଘࡏ͢Δ (forall s: S) s |+| e == e && e |+| s == e ࠓճॏཁͳͷ ͜ͷੑ࣭ʂʂ
Boolean) (implicit M: Monoid[AA]): (AA \/ B) = this match { case -\/(_) => this case \/-(b) => if(p(b)) this else -\/(M.zero) } aʹͳΔ͍ΖΜͳܕʹ͍ͭͯ౷Ұతͳ ΠϯλʔϑΣʔε .POPJE<9>[FSP ͰྵݩΛฦ͢͜ͱ͕Ͱ͖Δ