我对 scalaz 很陌生,我正试图弄清楚将各种类型转换为 monad 转换器。
我一直在尝试将 a 转换Int
为 a OptionT[Future, Int]
,甚至转换为EitherT[Future, String, Int]
.
我找到了一堆教程/SO 答案,它们解释了如何使用 来执行此操作point
,但由于某种原因,我无法编译它们。
例如,这里的这个片段:
1.point[({ type L[x] = EitherT[Future, String, x] })#L]
错误:(9, 9) 找不到类型的证据参数的隐式值
scalaz.Applicative[[x]scalaz.EitherT[scala.concurrent.Future,String,x]]
另一个来自Scalaz Monad 变形金刚
type Result[A] = OptionT[Future, A]
"".point[Result]
错误:(8, 10) 找不到类型的证据参数的隐式值
scalaz.Applicative[A$A35.this.Result]
我相信这个应该也可以,但是它说方法liftM
不是以下成员Future[Int]
:
1.point[Future].liftM[OptionT] //doesnt compile
1.point[List].liftM[OptionT] //compiles
所有这些示例都失败了,但是如果我替换Future
为List
. 现在,这是对我有用的唯一方法,但它有点冗长 - 我真的很想能够使用point
:
OptionT(Future.successful(1.some))
为什么这不编译?Future
在最近的版本中,是否从 scalaz 中删除了 applicative/monad ?
我正在使用 scala 2.11.7 和 scalaz 7.1.3。对于它的价值,这些是我的进口:
import scala.concurrent.Future
import scalaz._
import Scalaz._