usage example:
def div2(i: Int): Validation[String, Int] = if (i%2 == 0) Validation.success(i/2) else Validation.failure("odd") def div4(i: Int) = for { a <- div2(i) b <- div2(a) } yield b
a mistake . Cannot delete type scalaz.Validation[String,Int] in constructor of type M[_] , which is classified by a class of type scalaz.Bind
I assume the error is caused by the compiler, cannot find the Monad instance for Validation[String, Int]
I can do one for myself, for example:
object Instances { implicit def validationMonad[E] = new Monad[({type L[A] = Validation[E, A]})#L] { override def point[A](a: => A) = Validation.success(a) override def bind[A, B](fa: Validation[E, A])(f: A => Validation[E, B]) = fa bind f } }
but why doesn't he have Validation ? after all, Validation already has a bind method.
Also, I can no longer have import Validation._ and import Instances._ (this made me think ...), due to another complex error ...
ambiguous implicit values: something like both validationMonad (my instance) and the ValidationInstances1 method in the attribute ValidationInstances2 ... both correspond to some Functor of Validation ...
should i change the source of scalaz? or am I completely missing something?
please help ~
I am using scalaz 7.0.0-M2
scala monads scalaz scalaz7
Chris Aug 31 '12 at 8:40 2012-08-31 08:40
source share