@@ -372,11 +372,11 @@ public final <B> Option<P2<A,B>> bindProduct(final Option<B> ob) {
372
372
public final <B , C > Option <P3 <A ,B ,C >> bindProduct (final Option <B > ob , final Option <C > oc ) {
373
373
return bind (ob , oc , P .p3 ());
374
374
}
375
-
375
+
376
376
public final <B , C , D > Option <P4 <A ,B ,C ,D >> bindProduct (final Option <B > ob , final Option <C > oc , final Option <D > od ) {
377
377
return bind (ob , oc , od , P .p4 ());
378
378
}
379
-
379
+
380
380
public final <B ,C ,D ,E > Option <P5 <A ,B ,C ,D ,E >> bindProduct (final Option <B > ob , final Option <C > oc , final Option <D > od ,
381
381
final Option <E > oe ) {
382
382
return bind (ob , oc , od , oe , P .p5 ());
@@ -712,7 +712,7 @@ public static <A> Option<A> join(final Option<Option<A>> o) {
712
712
}
713
713
714
714
/**
715
- * Sequence through the option monad.
715
+ * Sequence a list through the option monad.
716
716
*
717
717
* @param a The list of option to sequence.
718
718
* @return The option of list after sequencing.
@@ -723,6 +723,16 @@ public static <A> Option<List<A>> sequence(final List<Option<A>> a) {
723
723
a .head ().bind (aa -> sequence (a .tail ()).map (cons_ (aa )));
724
724
}
725
725
726
+ /**
727
+ * Sequence a validation through the option monad.
728
+ *
729
+ * @param a The validation of option to sequence.
730
+ * @return The option of validation after sequencing.
731
+ */
732
+ public static <E , A > Option <Validation <E , A >> sequence (final Validation <E , Option <A >> a ) {
733
+ return a .traverseOption (identity ());
734
+ }
735
+
726
736
/**
727
737
* Returns an optional value that has a value of the given argument, if the given predicate holds
728
738
* on that argument, otherwise, returns no value.
0 commit comments