0
내가 ValidatedNel
의 HList
에 Xor
의 HList
을지도하려고으로이 컴파일 오류를 수정하고 오류 도착 방법 : 위의 그것을 해결하는 방법을폴리 기능
scala> type Result[A] = Xor[String, A]
defined type alias Result
scala> type Validation[A] = ValidatedNel[String, A]
defined type alias Validation
scala> val r0 = Xor.right(0)
r0: cats.data.Xor[Nothing,Int] = Right(0)
scala> val r1 = Xor.left("xxx")
r1: cats.data.Xor[String,Nothing] = Left(xxx)
scala> import shapeless._
import shapeless._
scala> val rs = r0 :: r1 :: HNil
rs: shapeless.::[cats.data.Xor[Nothing,Int],shapeless.::[cats.data.Xor[String,Nothing],shapeless.HNil]] = Right(0) :: Left(xxx) :: HNil
scala> object toValidation extends (Result ~> Validation) { def apply[T](r: Result[T]): Validation[T] = r.toValidatedNel }
defined object toValidation
scala> rs map toValidation
<console>:41: error: type mismatch;
found : toValidation.type
required: shapeless.Poly
rs map toValidation
코드로 잘못 무엇을 ?
감사합니다. 너는 맞을지 모르지만 나는 또 다른 문제가있다. 나는 그것에 대해 또 다른 질문을 게시 할 것이다. – Michael
이것은 질문입니다, 그건 그렇고 : http://stackoverflow.com/q/39374015/521070 – Michael