У меня есть следующий код, который не компилируется:
import cats._
import cats.implicits._
import cats.data._
import cats.syntax.applicative._ // for pure
import cats.syntax.applicativeError._ // for raiseError etc
final class DbSystemEnvironment[F[_]: MonadError[*[_], Throwable]] private(env: Environment[F])
extends DbSetting[F] {
override def read(url: String, user: String, pw: String): F[DbParameter] =
(for {
a <- OptionT(env.get(url))
b <- OptionT(env.get(user))
c <- OptionT(env.get(pw))
} yield DbParameter(a, b, c))
.value
.flatMap {
case Some(v) => v.pure[F]
case None => DbSettingError.raiseError[F, DbParameter]
}
}
компилятор жалуется:
[error] /home/developer/scala/user-svc/src/main/scala/io/databaker/db/DbSystemEnvironment.scala:20:27: value pure is not a member of io.databaker.db.DbParameter
[error] did you mean url?
[error] case Some(v) => v.pure[F]
[error] ^
[error] /home/developer/scala/user-svc/src/main/scala/io/databaker/db/DbSystemEnvironment.scala:21:37: value raiseError is not a member of object io.databaker.db.DbSettingError
[error] case None => DbSettingError.raiseError[F, DbParameter]
[error] ^
[error] two errors found
Что мне не хватает?