--
You received this message because you are subscribed to the Google Groups "scalaz" group.
To post to this group, send email to sca...@googlegroups.com.
To unsubscribe from this group, send email to scalaz+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scalaz?hl=en.
You mean when you want the X => Either[E, X] monad? There is no such thing as a monad for X => Validation[E, X]. Yes, we can.
scala> import scalaz._; import Scalaz._import scalaz._import Scalaz._scala> import Validation.Monad._import Validation.Monad._scala> "1".success[Exception] >>= (_.parseInt)res0: scalaz.Validation[Exception,Int] = Success(1)
Remarks for \/:
- scalaz.effect.IO.catchLeft may return \/ instead of scala.Either ?
- could have apply on object \/ to convert a scala Either to \/. And maybe a .\/ on scalaz.std.EitherOps
- could have \/.mapLeft(f) = swap.map(f).swap
Note that those functions exist just under different names: DisjunctionFunctions#fromEither and EitherOps#disjunction. I like aliasing fromEither/apply and disjunction/\/.
- could have \/.mapLeft(f) = swap.map(f).swapI tended to do bimap(f, identity) or disj.<-:(f) instead of the double swap. One problem with a mapLeft is that it might lead to filterLeft, flatMapLeft, etc.