我是很新,scalaz创建OptionT [未来,A],而我试图找出转换不同类型单子变压器。从较低kinded型
我一直在试图将Int
转换为OptionT[Future, Int]
,甚至转换为EitherT[Future, String, Int]
。
我发现了一堆教程/ SO解释如何使用point
做到这一点的答案,但由于某种原因,我不能编译它们。
例如,该段从here:
1.point[({ type L[x] = EitherT[Future, String, x] })#L]
Error:(9, 9) could not find implicit value for evidence parameter of type
scalaz.Applicative[[x]scalaz.EitherT[scala.concurrent.Future,String,x]]
type Result[A] = OptionT[Future, A]
"".point[Result]
Error:(8, 10) could not find implicit value for evidence parameter of type
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
的应用/ monad从scalaz中删除?
我使用的是scala 2.11.7和scalaz 7.1.3。对于它的价值,这是我进口:
import scala.concurrent.Future
import scalaz._
import Scalaz._
点上!原来'futureMonoid'需要一个隐含的执行上下文......我希望这些教程已经提到过这个细节* *。 – dcastro