scala - Accumulating only validation errors in Scalaz -
i beginner in work of functional programming , have sequence of validationnel[a,b] , accumulate errors new validationnel[a,b]. depends on fact b mutable info construction coming legacy code, , oververbose hold seq[b].
i know other posts cumulating errors , success possible through sequence method: processing list of scalaz6 validation
from understanding comes writing proper applicative , maybe proper traverse.
trait ma[m[_], a] extends pimpedtype[m[a]] masugar[m, a] { def sequence[n[_], b](implicit a: <:< n[b], t: traverse[m], n: applicative[n]): n[m[b]] = traverse((z: a) => (z: n[b])) def traverse[f[_],b](f: => f[b])(implicit a: applicative[f], t: traverse[m]): f[m[b]] = t.traverse(f, value) }
how start? when tried scalaz source code find out how implement applicative, got extremely confused. not able find out applicative allows accumulating both failures , success in validation.
late party, of scalaz 7.0.4, can this:
def takelastsuccess[a, b](seq: seq[validationnel[a, b]]) = { implicit val uselast = semigroup.lastsemigroup[b] seq reduceleft (_ +++ _) }
scala scalaz
No comments:
Post a Comment