2016-12-14 3 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 오류를 해결하는 방법은 무엇입니까? 감사. 다음 코드에서값 unsafePerformSync is scalaz.concurrent.Task의 구성원이 아닙니다. [문자열]

:

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

어느 스카 츠 버전입니까? – rethab

답변

2

최초의 0.13 버전 http4s 이후는 Scalaz의 7.1.x 및 7.2.x.에 대한 교차 게시되었습니다 Scalaz 7.1.x에서 unsafePerformSync은 단순히 run이었습니다 (이 이름은 이상적으로 직접 호출해서는 안되며, 프로그램에서 한 번만 호출하면됩니다).

두 가지 선택 사항이 있습니다.

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

그리고이로 변경 :

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

또는 당신은 당신이 (당신이 다른 제약 조건이 없다면 당신이해야한다), 빌드 설정에서이 같은 라인을 찾을 수 Scalaz 7.2을 사용하려면 Scalaz 7.1을 고수하고 run을 사용하도록 코드를 변경하면됩니다.