diff --git a/arrow-libs/core/arrow-core/api/arrow-core.api b/arrow-libs/core/arrow-core/api/arrow-core.api index 5afde1f9cf4..53fc79f2387 100644 --- a/arrow-libs/core/arrow-core/api/arrow-core.api +++ b/arrow-libs/core/arrow-core/api/arrow-core.api @@ -3201,15 +3201,11 @@ public final class arrow/core/raise/DefaultRaise : arrow/core/raise/Raise { public fun catch (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun invoke (Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public fun mapOrAccumulate (Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; public fun raise (Ljava/lang/Object;)Ljava/lang/Void; public fun recover (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; public fun recover (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun recover (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun shift (Ljava/lang/Object;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; } public final class arrow/core/raise/Effect { @@ -3273,7 +3269,6 @@ public final class arrow/core/raise/IorRaise : arrow/core/raise/Raise, arrow/typ public fun combine (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun invoke (Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public fun mapOrAccumulate (Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; public fun maybeCombine (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun raise (Ljava/lang/Object;)Ljava/lang/Void; @@ -3281,9 +3276,6 @@ public final class arrow/core/raise/IorRaise : arrow/core/raise/Raise, arrow/typ public fun recover (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun recover (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun shift (Ljava/lang/Object;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; } public final class arrow/core/raise/NullableRaise : arrow/core/raise/Raise { @@ -3326,8 +3318,6 @@ public final class arrow/core/raise/NullableRaise : arrow/core/raise/Raise { public fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun invoke-impl (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static fun invoke-impl (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public fun mapOrAccumulate (Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static fun mapOrAccumulate-impl (Larrow/core/raise/Raise;Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; public synthetic fun raise (Ljava/lang/Object;)Ljava/lang/Void; public fun raise (Ljava/lang/Void;)Ljava/lang/Void; public static fun raise-impl (Larrow/core/raise/Raise;Ljava/lang/Void;)Ljava/lang/Void; @@ -3343,12 +3333,6 @@ public final class arrow/core/raise/NullableRaise : arrow/core/raise/Raise { public fun toString ()Ljava/lang/String; public static fun toString-impl (Larrow/core/raise/Raise;)Ljava/lang/String; public final synthetic fun unbox-impl ()Larrow/core/raise/Raise; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; - public static fun zipOrAccumulate-impl (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public static fun zipOrAccumulate-impl (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public static fun zipOrAccumulate-impl (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; } public final class arrow/core/raise/OptionRaise : arrow/core/raise/Raise { @@ -3390,8 +3374,6 @@ public final class arrow/core/raise/OptionRaise : arrow/core/raise/Raise { public fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun invoke-impl (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static fun invoke-impl (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public fun mapOrAccumulate (Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static fun mapOrAccumulate-impl (Larrow/core/raise/Raise;Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; public fun raise (Larrow/core/None;)Ljava/lang/Void; public synthetic fun raise (Ljava/lang/Object;)Ljava/lang/Void; public static fun raise-impl (Larrow/core/raise/Raise;Larrow/core/None;)Ljava/lang/Void; @@ -3407,12 +3389,6 @@ public final class arrow/core/raise/OptionRaise : arrow/core/raise/Raise { public fun toString ()Ljava/lang/String; public static fun toString-impl (Larrow/core/raise/Raise;)Ljava/lang/String; public final synthetic fun unbox-impl ()Larrow/core/raise/Raise; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; - public static fun zipOrAccumulate-impl (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public static fun zipOrAccumulate-impl (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public static fun zipOrAccumulate-impl (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; } public abstract interface class arrow/core/raise/Raise { @@ -3430,15 +3406,11 @@ public abstract interface class arrow/core/raise/Raise { public abstract fun catch (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun invoke (Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public abstract fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun mapOrAccumulate (Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; public abstract fun raise (Ljava/lang/Object;)Ljava/lang/Void; public abstract fun recover (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; public abstract fun recover (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun recover (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun shift (Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public abstract fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public abstract fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; } public final class arrow/core/raise/Raise$DefaultImpls { @@ -3456,14 +3428,10 @@ public final class arrow/core/raise/Raise$DefaultImpls { public static fun catch (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun invoke (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static fun invoke (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun mapOrAccumulate (Larrow/core/raise/Raise;Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; public static fun recover (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; public static fun recover (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun recover (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun shift (Larrow/core/raise/Raise;Ljava/lang/Object;)Ljava/lang/Object; - public static fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public static fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public static fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; } public abstract interface annotation class arrow/core/raise/RaiseDSL : java/lang/annotation/Annotation { @@ -3474,9 +3442,23 @@ public final class arrow/core/raise/RaiseKt { public static final fun ensure (Larrow/core/raise/Raise;ZLkotlin/jvm/functions/Function0;)V public static final fun ensureNotNull (Larrow/core/raise/Raise;Ljava/lang/Object;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; public static final fun mapErrorNel (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun mapOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Ljava/lang/Iterable;Lkotlin/jvm/functions/Function2;)Ljava/util/List; public static final fun mapOrAccumulate (Larrow/core/raise/Raise;Ljava/lang/Iterable;Lkotlin/jvm/functions/Function2;)Ljava/util/List; public static final fun recover (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; public static final fun recover (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function10;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function9;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function8;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function7;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function6;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function10;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function9;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function8;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function7;)Ljava/lang/Object; + public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function6;)Ljava/lang/Object; public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; public static final fun zipOrAccumulate (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; @@ -3519,8 +3501,6 @@ public final class arrow/core/raise/ResultRaise : arrow/core/raise/Raise { public fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun invoke-impl (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static fun invoke-impl (Larrow/core/raise/Raise;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public fun mapOrAccumulate (Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static fun mapOrAccumulate-impl (Larrow/core/raise/Raise;Ljava/lang/Iterable;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function2;)Ljava/util/List; public synthetic fun raise (Ljava/lang/Object;)Ljava/lang/Void; public fun raise (Ljava/lang/Throwable;)Ljava/lang/Void; public static fun raise-impl (Larrow/core/raise/Raise;Ljava/lang/Throwable;)Ljava/lang/Void; @@ -3536,12 +3516,6 @@ public final class arrow/core/raise/ResultRaise : arrow/core/raise/Raise { public fun toString ()Ljava/lang/String; public static fun toString-impl (Larrow/core/raise/Raise;)Ljava/lang/String; public final synthetic fun unbox-impl ()Larrow/core/raise/Raise; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public fun zipOrAccumulate (Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; - public static fun zipOrAccumulate-impl (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function5;)Ljava/lang/Object; - public static fun zipOrAccumulate-impl (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Ljava/lang/Object; - public static fun zipOrAccumulate-impl (Larrow/core/raise/Raise;Larrow/typeclasses/Semigroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/lang/Object; } public abstract interface class arrow/typeclasses/Monoid : arrow/typeclasses/Semigroup { diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt index 258e493b3d4..fe16378142a 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt @@ -797,16 +797,16 @@ public sealed class Either { public fun isLeft(): Boolean { contract { - returns(true) implies (this@Either is Left) - returns(false) implies (this@Either is Right) + returns(true) implies (this@Either is Left<*>) + returns(false) implies (this@Either is Right<*>) } return this@Either is Left } public fun isRight(): Boolean { contract { - returns(true) implies (this@Either is Right) - returns(false) implies (this@Either is Left) + returns(true) implies (this@Either is Right<*>) + returns(false) implies (this@Either is Left<*>) } return this@Either is Right } @@ -970,7 +970,7 @@ public sealed class Either { contract { callsInPlace(action, InvocationKind.AT_MOST_ONCE) } - return also { if (it.isRight()) action(it.value) } + return also { if (it.isRight()) action(it.value as B) } } /** @@ -992,7 +992,7 @@ public sealed class Either { contract { callsInPlace(action, InvocationKind.AT_MOST_ONCE) } - return also { if (it.isLeft()) action(it.value) } + return also { if (it.isLeft()) action(it.value as A) } } /** diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Raise.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Raise.kt index 6ac9bc57cae..ff1306b253a 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Raise.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Raise.kt @@ -1,25 +1,21 @@ @file:OptIn(ExperimentalTypeInference::class, ExperimentalContracts::class) - +@file:JvmMultifileClass +@file:JvmName("RaiseKt") package arrow.core.raise import arrow.core.Either -import arrow.core.EmptyValue -import arrow.core.NonEmptyList import arrow.core.None import arrow.core.Option import arrow.core.Some import arrow.core.Validated import arrow.core.continuations.EffectScope -import arrow.core.emptyCombine import arrow.core.identity -import arrow.core.nel -import arrow.typeclasses.Semigroup import kotlin.contracts.ExperimentalContracts -import kotlin.contracts.InvocationKind import kotlin.contracts.InvocationKind.AT_MOST_ONCE import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract import kotlin.experimental.ExperimentalTypeInference +import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName @DslMarker @@ -313,89 +309,6 @@ public interface Raise { public fun EagerEffect.catch( @BuilderInference catch: Raise.(Throwable) -> A, ): A = fold({ catch(it) }, { raise(it) }, { it }) - - /** - * Accumulate the errors from running both [action1] and [action2] - * using the given [semigroup]. - */ - @RaiseDSL - public fun zipOrAccumulate( - semigroup: Semigroup<@UnsafeVariance R>, - @BuilderInference action1: Raise.() -> A, - @BuilderInference action2: Raise.() -> B, - @BuilderInference block: Raise.(A, B) -> C - ): C { - val result1 = recover(action1) { e1 -> - // try to execute the second - recover(action2) { e2 -> raise(semigroup.run { e1 + e2 }) } - // if the second succeeds, just raise the first one - raise(e1) - } - return block(result1, action2()) - } - - /** - * Accumulate the errors from running [action1], [action2], and [action3] - * using the given [semigroup]. - */ - @RaiseDSL - public fun zipOrAccumulate( - semigroup: Semigroup<@UnsafeVariance R>, - @BuilderInference action1: Raise.() -> A, - @BuilderInference action2: Raise.() -> B, - @BuilderInference action3: Raise.() -> C, - @BuilderInference block: Raise.(A, B, C) -> D - ): D = zipOrAccumulate( - semigroup, - { zipOrAccumulate(semigroup, action1, action2) { x, y -> x to y } }, - action3 - ) { xy, z -> block(xy.first, xy.second, z) } - - /** - * Accumulate the errors from running [action1], [action2], [action3], and [action4] - * using the given [semigroup]. - */ - @RaiseDSL - public fun zipOrAccumulate( - semigroup: Semigroup<@UnsafeVariance R>, - @BuilderInference action1: Raise.() -> A, - @BuilderInference action2: Raise.() -> B, - @BuilderInference action3: Raise.() -> C, - @BuilderInference action4: Raise.() -> D, - @BuilderInference block: Raise.(A, B, C, D) -> E - ): E = zipOrAccumulate( - semigroup, - { zipOrAccumulate(semigroup, action1, action2, action3) { x, y, z -> Triple(x, y, z) } }, - action4 - ) { xyz, z -> block(xyz.first, xyz.second, xyz.third, z) } - - /** - * Accumulate the errors obtained by executing the [block] - * over every element of [this] using the given [semigroup]. - */ - @RaiseDSL - public fun Iterable.mapOrAccumulate( - semigroup: Semigroup<@UnsafeVariance R>, - @BuilderInference block: Raise.(A) -> B - ): List { - // this could be implemented using [zipOrAccumulate], - // but we can have a faster implementation using [MutableList] - var error: Any? = EmptyValue - val results = mutableListOf() - forEach { - fold({ - block(it) - }, { newError -> - error = semigroup.emptyCombine(error, newError) - }, { - results.add(it) - }) - } - when (val e = error) { - is EmptyValue -> return results - else -> raise(EmptyValue.unbox(e)) - } - } } /** @@ -490,70 +403,3 @@ public inline fun Raise.ensureNotNull(value: B?, raise: () -> R) } return value ?: raise(raise()) } - -@RaiseDSL -public inline fun Raise>.mapErrorNel( - crossinline block: Raise.() -> A -): A = recover(block) { raise(it.nel()) } - -/** - * Accumulate the errors obtained by executing the [block] - * over every element of [list]. - */ -@RaiseDSL -public inline fun Raise>.mapOrAccumulate( - list: Iterable, - @BuilderInference crossinline block: Raise.(A) -> B -): List = - list.mapOrAccumulate(Semigroup.nonEmptyList()) { elt -> mapErrorNel { block(elt) } } - -/** - * Accumulate the errors from running both [action1] and [action2]. - */ -@RaiseDSL -public inline fun Raise>.zipOrAccumulate( - @BuilderInference crossinline action1: Raise.() -> A, - @BuilderInference crossinline action2: Raise.() -> B, - @BuilderInference crossinline block: Raise.(A, B) -> C -): C = zipOrAccumulate( - Semigroup.nonEmptyList(), - { mapErrorNel(action1) }, - { mapErrorNel(action2) }, - { x, y -> mapErrorNel { block(x, y) } } -) - -/** - * Accumulate the errors from running [action1], [action2], and [action3]. - */ -@RaiseDSL -public inline fun Raise>.zipOrAccumulate( - @BuilderInference crossinline action1: Raise.() -> A, - @BuilderInference crossinline action2: Raise.() -> B, - @BuilderInference crossinline action3: Raise.() -> C, - @BuilderInference crossinline block: Raise.(A, B, C) -> D -): D = zipOrAccumulate( - Semigroup.nonEmptyList(), - { mapErrorNel(action1) }, - { mapErrorNel(action2) }, - { mapErrorNel(action3) }, - { x, y, z -> mapErrorNel { block(x, y, z) } } -) - -/** - * Accumulate the errors from running [action1], [action2], [action3], and [action4]. - */ -@RaiseDSL -public inline fun Raise>.zipOrAccumulate( - @BuilderInference crossinline action1: Raise.() -> A, - @BuilderInference crossinline action2: Raise.() -> B, - @BuilderInference crossinline action3: Raise.() -> C, - @BuilderInference crossinline action4: Raise.() -> D, - @BuilderInference crossinline block: Raise.(A, B, C, D) -> E -): E = zipOrAccumulate( - Semigroup.nonEmptyList(), - { mapErrorNel(action1) }, - { mapErrorNel(action2) }, - { mapErrorNel(action3) }, - { mapErrorNel(action4) }, - { x, y, z, u -> mapErrorNel { block(x, y, z, u) } } -) diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/RaiseAccumulate.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/RaiseAccumulate.kt new file mode 100644 index 00000000000..431960c0d05 --- /dev/null +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/RaiseAccumulate.kt @@ -0,0 +1,570 @@ +@file:OptIn(ExperimentalTypeInference::class, ExperimentalContracts::class) +@file:JvmMultifileClass +@file:JvmName("RaiseKt") +package arrow.core.raise + +import arrow.core.Either +import arrow.core.EmptyValue +import arrow.core.NonEmptyList +import arrow.core.Tuple4 +import arrow.core.Tuple5 +import arrow.core.Tuple6 +import arrow.core.Tuple7 +import arrow.core.Tuple8 +import arrow.core.emptyCombine +import arrow.core.nel +import arrow.typeclasses.Semigroup +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract +import kotlin.experimental.ExperimentalTypeInference +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName + + +/** + * Accumulate the errors from running both [action1] and [action2] + * using the given [semigroup]. + */ +@RaiseDSL +public inline fun Raise.zipOrAccumulate( + semigroup: Semigroup<@UnsafeVariance R>, + @BuilderInference action1: Raise.() -> A, + @BuilderInference action2: Raise.() -> B, + @BuilderInference block: Raise.(A, B) -> C +): C { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + } + val result1 = either(action1) + val result2 = either(action2) + return when (result1) { + is Either.Right -> + when (result2) { + is Either.Right -> block(result1.value, result2.value) + is Either.Left -> raise(result2.value) + } + is Either.Left -> + when (result2) { + is Either.Right -> raise(result1.value) + is Either.Left -> raise(semigroup.run { result1.value + result2.value }) + } + } +} + +/** + * Accumulate the errors from running [action1], [action2], and [action3] + * using the given [semigroup]. + */ +@RaiseDSL +public inline fun Raise.zipOrAccumulate( + semigroup: Semigroup<@UnsafeVariance R>, + @BuilderInference action1: Raise.() -> A, + @BuilderInference action2: Raise.() -> B, + @BuilderInference action3: Raise.() -> C, + @BuilderInference block: Raise.(A, B, C) -> D +): D { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + semigroup, + { zipOrAccumulate(semigroup, action1, action2) { x, y -> x to y } }, + action3 + ) { xy, z -> block(xy.first, xy.second, z) } +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], and [action4] + * using the given [semigroup]. + */ +@RaiseDSL +public inline fun Raise.zipOrAccumulate( + semigroup: Semigroup<@UnsafeVariance R>, + @BuilderInference action1: Raise.() -> A, + @BuilderInference action2: Raise.() -> B, + @BuilderInference action3: Raise.() -> C, + @BuilderInference action4: Raise.() -> D, + @BuilderInference block: Raise.(A, B, C, D) -> E +): E { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + semigroup, + { zipOrAccumulate(semigroup, action1, action2, action3) { x, y, z -> Triple(x, y, z) } }, + action4 + ) { xyz, z -> block(xyz.first, xyz.second, xyz.third, z) } +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], and [action5] + * using the given [semigroup]. + */ +@RaiseDSL +public inline fun Raise.zipOrAccumulate( + semigroup: Semigroup<@UnsafeVariance R>, + @BuilderInference action1: Raise.() -> A, + @BuilderInference action2: Raise.() -> B, + @BuilderInference action3: Raise.() -> C, + @BuilderInference action4: Raise.() -> D, + @BuilderInference action5: Raise.() -> E, + @BuilderInference block: Raise.(A, B, C, D, E) -> F +): F { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + semigroup, + { zipOrAccumulate(semigroup, action1, action2, action3, action4) { x, y, z, u -> Tuple4(x, y, z, u) } }, + action5 + ) { xyzu, v -> block(xyzu.first, xyzu.second, xyzu.third, xyzu.fourth, v) } +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], [action5], and [action6] + * using the given [semigroup]. + */ +@RaiseDSL +public inline fun Raise.zipOrAccumulate( + semigroup: Semigroup<@UnsafeVariance R>, + @BuilderInference action1: Raise.() -> A, + @BuilderInference action2: Raise.() -> B, + @BuilderInference action3: Raise.() -> C, + @BuilderInference action4: Raise.() -> D, + @BuilderInference action5: Raise.() -> E, + @BuilderInference action6: Raise.() -> F, + @BuilderInference block: Raise.(A, B, C, D, E, F) -> G +): G { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + callsInPlace(action6, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + semigroup, + { zipOrAccumulate(semigroup, action1, action2, action3, action4, action5) { x, y, z, u, v -> Tuple5(x, y, z, u, v) } }, + action6 + ) { xyzuv, w -> block(xyzuv.first, xyzuv.second, xyzuv.third, xyzuv.fourth, xyzuv.fifth, w) } +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], [action5], [action6], and [action7] + * using the given [semigroup]. + */ +@RaiseDSL +public inline fun Raise.zipOrAccumulate( + semigroup: Semigroup<@UnsafeVariance R>, + @BuilderInference action1: Raise.() -> A, + @BuilderInference action2: Raise.() -> B, + @BuilderInference action3: Raise.() -> C, + @BuilderInference action4: Raise.() -> D, + @BuilderInference action5: Raise.() -> E, + @BuilderInference action6: Raise.() -> F, + @BuilderInference action7: Raise.() -> G, + @BuilderInference block: Raise.(A, B, C, D, E, F, G) -> H +): H { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + callsInPlace(action6, InvocationKind.EXACTLY_ONCE) + callsInPlace(action7, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + semigroup, + { zipOrAccumulate(semigroup, action1, action2, action3, action4, action5, action6) { x, y, z, u, v, w -> Tuple6(x, y, z, u, v, w) } }, + action7 + ) { xyzuvw, a -> block(xyzuvw.first, xyzuvw.second, xyzuvw.third, xyzuvw.fourth, xyzuvw.fifth, xyzuvw.sixth, a) } +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], [action5], [action6], [action7], and [action8] + * using the given [semigroup]. + */ +@RaiseDSL +public inline fun Raise.zipOrAccumulate( + semigroup: Semigroup<@UnsafeVariance R>, + @BuilderInference action1: Raise.() -> A, + @BuilderInference action2: Raise.() -> B, + @BuilderInference action3: Raise.() -> C, + @BuilderInference action4: Raise.() -> D, + @BuilderInference action5: Raise.() -> E, + @BuilderInference action6: Raise.() -> F, + @BuilderInference action7: Raise.() -> G, + @BuilderInference action8: Raise.() -> H, + @BuilderInference block: Raise.(A, B, C, D, E, F, G, H) -> I +): I { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + callsInPlace(action6, InvocationKind.EXACTLY_ONCE) + callsInPlace(action7, InvocationKind.EXACTLY_ONCE) + callsInPlace(action8, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + semigroup, + { zipOrAccumulate(semigroup, action1, action2, action3, action4, action5, action6, action7) { x, y, z, u, v, w, a -> Tuple7(x, y, z, u, v, w, a) } }, + action8 + ) { xyzuvwa, b -> block(xyzuvwa.first, xyzuvwa.second, xyzuvwa.third, xyzuvwa.fourth, xyzuvwa.fifth, xyzuvwa.sixth, xyzuvwa.seventh, b) } +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], [action5], [action6], [action7], [action8], and [action9] + * using the given [semigroup]. + */ +@RaiseDSL +public inline fun Raise.zipOrAccumulate( + semigroup: Semigroup<@UnsafeVariance R>, + @BuilderInference action1: Raise.() -> A, + @BuilderInference action2: Raise.() -> B, + @BuilderInference action3: Raise.() -> C, + @BuilderInference action4: Raise.() -> D, + @BuilderInference action5: Raise.() -> E, + @BuilderInference action6: Raise.() -> F, + @BuilderInference action7: Raise.() -> G, + @BuilderInference action8: Raise.() -> H, + @BuilderInference action9: Raise.() -> I, + @BuilderInference block: Raise.(A, B, C, D, E, F, G, H, I) -> J +): J { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + callsInPlace(action6, InvocationKind.EXACTLY_ONCE) + callsInPlace(action7, InvocationKind.EXACTLY_ONCE) + callsInPlace(action8, InvocationKind.EXACTLY_ONCE) + callsInPlace(action9, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + semigroup, + { zipOrAccumulate(semigroup, action1, action2, action3, action4, action5, action6, action7, action8) { x, y, z, u, v, w, a, b -> Tuple8(x, y, z, u, v, w, a, b) } }, + action9 + ) { xyzuvwab, c -> block(xyzuvwab.first, xyzuvwab.second, xyzuvwab.third, xyzuvwab.fourth, xyzuvwab.fifth, xyzuvwab.sixth, xyzuvwab.seventh, xyzuvwab.eighth, c) } +} + +/** + * Re-raise any errors in [block] in a [NonEmptyList]. + */ +@RaiseDSL +public inline fun Raise>.mapErrorNel( + crossinline block: Raise.() -> A +): A { + contract { + callsInPlace(block, InvocationKind.EXACTLY_ONCE) + } + return recover(block) { raise(it.nel()) } +} + +/** + * Accumulate the errors from running both [action1] and [action2]. + */ +@RaiseDSL +public inline fun Raise>.zipOrAccumulate( + @BuilderInference crossinline action1: Raise.() -> A, + @BuilderInference crossinline action2: Raise.() -> B, + @BuilderInference crossinline block: Raise.(A, B) -> C +): C { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + Semigroup.nonEmptyList(), + { mapErrorNel(action1) }, + { mapErrorNel(action2) }, + { x, y -> mapErrorNel { block(x, y) } } + ) +} + +/** + * Accumulate the errors from running [action1], [action2], and [action3]. + */ +@RaiseDSL +public inline fun Raise>.zipOrAccumulate( + @BuilderInference crossinline action1: Raise.() -> A, + @BuilderInference crossinline action2: Raise.() -> B, + @BuilderInference crossinline action3: Raise.() -> C, + @BuilderInference crossinline block: Raise.(A, B, C) -> D +): D { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + Semigroup.nonEmptyList(), + { mapErrorNel(action1) }, + { mapErrorNel(action2) }, + { mapErrorNel(action3) }, + { x, y, z -> mapErrorNel { block(x, y, z) } } + ) +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], and [action4]. + */ +@RaiseDSL +public inline fun Raise>.zipOrAccumulate( + @BuilderInference crossinline action1: Raise.() -> A, + @BuilderInference crossinline action2: Raise.() -> B, + @BuilderInference crossinline action3: Raise.() -> C, + @BuilderInference crossinline action4: Raise.() -> D, + @BuilderInference crossinline block: Raise.(A, B, C, D) -> E +): E { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + Semigroup.nonEmptyList(), + { mapErrorNel(action1) }, + { mapErrorNel(action2) }, + { mapErrorNel(action3) }, + { mapErrorNel(action4) }, + { x, y, z, u -> mapErrorNel { block(x, y, z, u) } } + ) +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], and [action5]. + */ +@RaiseDSL +public inline fun Raise>.zipOrAccumulate( + @BuilderInference crossinline action1: Raise.() -> A, + @BuilderInference crossinline action2: Raise.() -> B, + @BuilderInference crossinline action3: Raise.() -> C, + @BuilderInference crossinline action4: Raise.() -> D, + @BuilderInference crossinline action5: Raise.() -> E, + @BuilderInference crossinline block: Raise.(A, B, C, D, E) -> F +): F { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + Semigroup.nonEmptyList(), + { mapErrorNel(action1) }, + { mapErrorNel(action2) }, + { mapErrorNel(action3) }, + { mapErrorNel(action4) }, + { mapErrorNel(action5) }, + { x, y, z, u, v -> mapErrorNel { block(x, y, z, u, v) } } + ) +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], [action5], and [action6]. + */ +@RaiseDSL +public inline fun Raise>.zipOrAccumulate( + @BuilderInference crossinline action1: Raise.() -> A, + @BuilderInference crossinline action2: Raise.() -> B, + @BuilderInference crossinline action3: Raise.() -> C, + @BuilderInference crossinline action4: Raise.() -> D, + @BuilderInference crossinline action5: Raise.() -> E, + @BuilderInference crossinline action6: Raise.() -> F, + @BuilderInference crossinline block: Raise.(A, B, C, D, E, F) -> G +): G { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + callsInPlace(action6, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + Semigroup.nonEmptyList(), + { mapErrorNel(action1) }, + { mapErrorNel(action2) }, + { mapErrorNel(action3) }, + { mapErrorNel(action4) }, + { mapErrorNel(action5) }, + { mapErrorNel(action6) }, + { x, y, z, u, v, w -> mapErrorNel { block(x, y, z, u, v, w) } } + ) +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], [action5], [action6], and [action7]. + */ +@RaiseDSL +public inline fun Raise>.zipOrAccumulate( + @BuilderInference crossinline action1: Raise.() -> A, + @BuilderInference crossinline action2: Raise.() -> B, + @BuilderInference crossinline action3: Raise.() -> C, + @BuilderInference crossinline action4: Raise.() -> D, + @BuilderInference crossinline action5: Raise.() -> E, + @BuilderInference crossinline action6: Raise.() -> F, + @BuilderInference crossinline action7: Raise.() -> G, + @BuilderInference crossinline block: Raise.(A, B, C, D, E, F, G) -> H +): H { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + callsInPlace(action6, InvocationKind.EXACTLY_ONCE) + callsInPlace(action7, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + Semigroup.nonEmptyList(), + { mapErrorNel(action1) }, + { mapErrorNel(action2) }, + { mapErrorNel(action3) }, + { mapErrorNel(action4) }, + { mapErrorNel(action5) }, + { mapErrorNel(action6) }, + { mapErrorNel(action7) }, + { x, y, z, u, v, w, a -> mapErrorNel { block(x, y, z, u, v, w, a) } } + ) +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], [action5], [action6], [action7], and [action8]. + */ +@RaiseDSL +public inline fun Raise>.zipOrAccumulate( + @BuilderInference crossinline action1: Raise.() -> A, + @BuilderInference crossinline action2: Raise.() -> B, + @BuilderInference crossinline action3: Raise.() -> C, + @BuilderInference crossinline action4: Raise.() -> D, + @BuilderInference crossinline action5: Raise.() -> E, + @BuilderInference crossinline action6: Raise.() -> F, + @BuilderInference crossinline action7: Raise.() -> G, + @BuilderInference crossinline action8: Raise.() -> H, + @BuilderInference crossinline block: Raise.(A, B, C, D, E, F, G, H) -> I +): I { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + callsInPlace(action6, InvocationKind.EXACTLY_ONCE) + callsInPlace(action7, InvocationKind.EXACTLY_ONCE) + callsInPlace(action8, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + Semigroup.nonEmptyList(), + { mapErrorNel(action1) }, + { mapErrorNel(action2) }, + { mapErrorNel(action3) }, + { mapErrorNel(action4) }, + { mapErrorNel(action5) }, + { mapErrorNel(action6) }, + { mapErrorNel(action7) }, + { mapErrorNel(action8) }, + { x, y, z, u, v, w, a, b -> mapErrorNel { block(x, y, z, u, v, w, a, b) } } + ) +} + +/** + * Accumulate the errors from running [action1], [action2], [action3], [action4], [action5], [action6], [action7], [action8], and [action9]. + */ +@RaiseDSL +public inline fun Raise>.zipOrAccumulate( + @BuilderInference crossinline action1: Raise.() -> A, + @BuilderInference crossinline action2: Raise.() -> B, + @BuilderInference crossinline action3: Raise.() -> C, + @BuilderInference crossinline action4: Raise.() -> D, + @BuilderInference crossinline action5: Raise.() -> E, + @BuilderInference crossinline action6: Raise.() -> F, + @BuilderInference crossinline action7: Raise.() -> G, + @BuilderInference crossinline action8: Raise.() -> H, + @BuilderInference crossinline action9: Raise.() -> I, + @BuilderInference crossinline block: Raise.(A, B, C, D, E, F, G, H, I) -> J +): J { + contract { + callsInPlace(action1, InvocationKind.EXACTLY_ONCE) + callsInPlace(action2, InvocationKind.EXACTLY_ONCE) + callsInPlace(action3, InvocationKind.EXACTLY_ONCE) + callsInPlace(action4, InvocationKind.EXACTLY_ONCE) + callsInPlace(action5, InvocationKind.EXACTLY_ONCE) + callsInPlace(action6, InvocationKind.EXACTLY_ONCE) + callsInPlace(action7, InvocationKind.EXACTLY_ONCE) + callsInPlace(action8, InvocationKind.EXACTLY_ONCE) + callsInPlace(action9, InvocationKind.EXACTLY_ONCE) + } + return zipOrAccumulate( + Semigroup.nonEmptyList(), + { mapErrorNel(action1) }, + { mapErrorNel(action2) }, + { mapErrorNel(action3) }, + { mapErrorNel(action4) }, + { mapErrorNel(action5) }, + { mapErrorNel(action6) }, + { mapErrorNel(action7) }, + { mapErrorNel(action8) }, + { mapErrorNel(action9) }, + { x, y, z, u, v, w, a, b, c -> mapErrorNel { block(x, y, z, u, v, w, a, b, c) } } + ) +} + +/** + * Accumulate the errors obtained by executing the [block] + * over every element of [list] using the given [semigroup]. + */ +@RaiseDSL +public inline fun Raise.mapOrAccumulate( + semigroup: Semigroup<@UnsafeVariance R>, + list: Iterable, + @BuilderInference block: Raise.(A) -> B +): List { + // this could be implemented using [zipOrAccumulate], + // but we can have a faster implementation using [buildList] + var error: Any? = EmptyValue + val results = buildList { + list.forEach { + fold({ + block(it) + }, { newError -> + error = semigroup.emptyCombine(error, newError) + }, { + add(it) + }) + } + } + return when (val e = EmptyValue.unbox(error)) { + null -> results + else -> raise(e) + } +} + +/** + * Accumulate the errors obtained by executing the [block] + * over every element of [list]. + */ +@RaiseDSL +public inline fun Raise>.mapOrAccumulate( + list: Iterable, + @BuilderInference crossinline block: Raise.(A) -> B +): List = + mapOrAccumulate(Semigroup.nonEmptyList(), list) { elt -> mapErrorNel { block(elt) } }