import scalaz._
import Scalaz._
"abc".parseInt
This will return a Validation[NumberFormatException, Int].
Is there a way I can apply a function on the failure side (such as toString) to get a Validation[String, Int]?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a pair of methods
<-:and:->defined onMAB[M[_,_], A, B]that map on the left and right side of anyM[A, B]as long as there is aBifunctor[M].Validationhappens to be a bifunctor, so you can do this:Scala’s type inference generally flows from left to right, so this is actually shorter:
And requires less annotation.