我是很新,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