Question: Recall that unlike Options where multiple errors are simply subsumed by a None, when we deal with multiple errors in Eithers, all but one are

Recall that unlike Options where multiple errors are simply subsumed by a None, when we deal with multiple errors in Eithers, all but one are lost. Implement a datatype to return back multiple errors. Pay close attention to situations which do and do not require recording of multiple errors. You may use the following definition for the purpose of defining your data type.

trait Partial[+A,+B]

case class Errors[+A](get: Seq[A]) extends Partial[A,Nothing]

case class Success[+B](get: B) extends Partial[Nothing,B]

Now, implement the following functions for this datatype, accumulating errors when meaningful to do so:

a) map

b) flatMap

c) getOrElse

d) orElse

e) map2

f) traverse

Finally:

g) Implement the Try function to convert a possible exception into a Partial

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!