2016-12-14 64 views
3
value unsafePerformSync is not a member of scalaz.concurrent.Task[String] 
[error]  val x = task.unsafePerformSync 
[error]    ^
[error] one error found 

如何解決上述(2.11.8)scalac錯誤?謝謝。value unsafePerformSync不是scalaz.concurrent.Task的成員[String]

從下面的代碼片斷:

import org.http4s._, org.http4s.dsl._         
import org.http4s.client.blaze._ 
import scalaz._, Scalaz._ 
import scalaz.concurrent.Task 

object Client extends App { 
    val client = PooledHttp1Client() 
    val httpize = Uri.uri("http://httpize.herokuapp.com") 

    def post() = { 
    val req = Request(method = Method.POST, uri = httpize/"post").withBody("hello") 
    val task = client.expect[String](req) 
    val x = task.unsafePerformSync 
    println(x) 
} 
+0

這是哪個scalaz版本? – rethab

回答

2

由於第一0.13釋放http4s已交發表了Scalaz 7.1.x和7.2.x中在Scalaz 7.1.x中,unsafePerformSync僅僅是run(作爲一個名字,太吸引人的理由是你永遠不應該直接調用,或者在你的程序中最多調用一次)。

所以你有兩種選擇。如果你想使用Scalaz 7.2(你應該,除非你有其他的限制),發現這樣一行在構建配置:

libraryDependencies += "org.http4s" %% "http4s-core" % "0.15.0" 

它改成這樣:

libraryDependencies += "org.http4s" %% "http4s-core" % "0.15.0a" 

另外,您可以堅持使用Scalaz 7.1,只需更改代碼即可使用run

相關問題