モナドトランスフォーマーを学んでいます。モナドを入れ子にする方法を学びたいと思っています。 それでは、私は今、私は val p1 = 1.pure[FutureEitherOption]
を行うと、私は OptionT(EitherT(Future(Success(Right(Some(1))))))
を取得し、私は type Error = String
type FutureEithe
モノイド型のリストまたは配列Aもモノイドです。今私はcatsを使用してcombine整数の配列にしたいと思います。 scala> 1 |+| 2
res1: Int = 3
scala> Array(1, 2, 3) |+| Array(1, 2, 3)
<console>:21: error: value |+| is not a member of Array[Int]
Ar
入力を繰り返す関数echo: String => Stringをspecs2でテストしたとします。 私はそのようないくつかのテストを書くことができます: class EchoSpec extends SpecificationWithJUnit {
"echo should handle ASCII alphanumeric names" in {
echo("abc") m
が、私は二つのタイプIntResultとStringResultを持っていると仮定します。 import cats._
import cats.data._
import cats.implicits._
scala> case class MyError(msg: String)
defined class MyError
scala> type Result[A] = Eithe