-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add toNestedValidated and toNestedValidatedNel #1408
Conversation
Current coverage is 91.68% (diff: 100%)@@ master #1408 diff @@
==========================================
Files 240 240
Lines 3608 3610 +2
Methods 3540 3544 +4
Messages 0 0
Branches 67 65 -2
==========================================
+ Hits 3308 3310 +2
Misses 300 300
Partials 0 0
|
These seem good to me. At a minimum we should have tests for both methods. It doesn't look like we have a tutorial for |
82a5c98
to
726b4fe
Compare
3187feb
to
9a678ff
Compare
👍, looks good to me with the tests. |
This looks good, thanks @conniec. Maybe we can add the following example to import cats.data.{Nested, EitherT, ValidatedNel}
import cats.implicits._
type ErrorsOr[x] = ValidatedNel[String, x]
type OptionErrorsOr[x] = Nested[Option, ErrorsOr, x]
val ok = EitherT.right[Option, String, Int](Some(1))
val error = EitherT.left[Option, String, Int](Some("error"))
val none = EitherT[Option, String, Int](None)
val okV: OptionErrorsOr[Int] = ok.toNestedValidatedNel
val errorV: OptionErrorsOr[Int] = error.toNestedValidatedNel
val noneV: OptionErrorsOr[Int] = none.toNestedValidatedNel
(okV |@| okV |@| okV).map(_ + _ + _)
// OptionErrorsOr[Int] = Nested(Some(Valid(3)))
(okV |@| errorV |@| errorV).map(_ + _ + _)
// OptionErrorsOr[Int] = Nested(Some(Invalid(NonEmptyList(error, error))))
(ok |@| error |@| error).map(_ + _ + _)
// EitherT[Option,String,Int] = EitherT(Some(Left(error)))
(okV |@| errorV |@| noneV).map(_ + _ + _)
// OptionErrorsOr[Int] = Nested(None)
(ok |@| error |@| none).map(_ + _ + _)
// EitherT[Option,String,Int] = EitherT(Some(Left(error))) This might even be something worth adding to the |
@peterneyens Maybe we should open an issue for |
You're right, see #1425. |
Thanks for the help everyone! |
Issue: #1344
This is my first time contributing and am fairly new to these types so any feedback welcome. Would also like to add some examples if the code looks about right.