This is a follow-up to my previous question:
Suppose I have a few functions that return scalaz.Validaton
:
type Status[A] = ValidationNel[String, A]
val isPositive: Int => Status[Int] =
x => if (x > 0) x.success else s"$x not positive".failureNel
val isNegative: Int => Status[Int] =
x => if (x < 0) x.success else s"$x not negative".failureNel
I can write a new function makeX
case class X(x1: Int, // should be positive
x2: Int, // should be positive
x3: Int) // should be negative
val makeX: (Int, Int, Int) => Status[X] = (x1, x2, x3) =>
(isPositive(x1) |@| isPositive(x2) |@| isNegative(x3)) (X.apply _)
My question is: How to write makeX
in point-free style