Skip to content
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

Deprecation of Semigroup and Monoid #2935

Merged
merged 37 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
25701ca
Start deprecation of Semigroup and Monoid
serras Feb 17, 2023
c04602d
Deprecation for EmptyValue
serras Feb 17, 2023
915b740
Update API files
serras Feb 17, 2023
848b423
Deprecation for map
serras Feb 17, 2023
42d32c5
Update API files
serras Feb 17, 2023
bb4234c
Deprecation for NonEmptyList, Option, and Pair
serras Feb 17, 2023
1fd6dde
Deprecation for Raise builders
serras Feb 17, 2023
c45c6d4
Merge branch 'main' into deprecate-semigroup-monoid
serras Feb 17, 2023
f47a982
Merge branch 'main' into deprecate-semigroup-monoid
serras Feb 23, 2023
5148d55
Deprecation for Ior and zips
serras Feb 23, 2023
570634d
Update API files
serras Feb 23, 2023
e58c82f
Merge branch 'main' into deprecate-semigroup-monoid
serras Feb 23, 2023
0ecbcb4
Update arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Op…
serras Feb 27, 2023
c50c804
Update arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Op…
serras Feb 27, 2023
1d509a8
Merge branch 'main' into deprecate-semigroup-monoid
serras Mar 2, 2023
b8e0086
Remove emptyCombine + add missing Validated#zip
serras Mar 2, 2023
1020548
Fix more merge woes
serras Mar 2, 2023
7deae73
Fix incorrect 'combine' implementation
serras Mar 3, 2023
316809f
Remove unnecessary combine
serras Mar 3, 2023
9f367da
More Either woes
serras Mar 3, 2023
21fa9e5
Merge remote-tracking branch 'origin/main' into deprecate-semigroup-m…
nomisRev Mar 7, 2023
bccec6e
Update PR, introduce Semigroup::combine, and revert Ior changes in fa…
nomisRev Mar 7, 2023
627a8a5
Merge remote-tracking branch 'origin/main' into deprecate-semigroup-m…
nomisRev Mar 8, 2023
5ff3a7b
Revert unrelated change
nomisRev Mar 8, 2023
58c9296
A few improvements
serras Mar 8, 2023
d0e4c81
Deprecate Semiring
serras Mar 8, 2023
212e706
Rework Laws
serras Mar 8, 2023
bc0f97c
Update API files
serras Mar 8, 2023
1f31084
GitHub Actions
serras Mar 8, 2023
38f362e
Update arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/It…
nomisRev Mar 8, 2023
bbe260a
Merge branch 'main' into deprecate-semigroup-monoid
serras Mar 9, 2023
439c8e3
Try to fix Native compilation
serras Mar 9, 2023
7779714
Deprecate Const, Endo, Semigroup constructors, and revert Either#comb…
nomisRev Mar 10, 2023
28ba065
Merge branch 'deprecate-semigroup-monoid' of github.com:arrow-kt/arro…
nomisRev Mar 10, 2023
b13ebe9
Merge remote-tracking branch 'origin/main' into deprecate-semigroup-m…
nomisRev Mar 10, 2023
cdd5e50
Update API files
nomisRev Mar 10, 2023
ac8e6a2
Retrigger CI
nomisRev Mar 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 57 additions & 15 deletions arrow-libs/core/arrow-core/api/arrow-core.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import arrow.core.Either.Companion.resolve
import arrow.core.Either.Left
import arrow.core.Either.Right
import arrow.core.Either.Right.Companion.unit
import arrow.core.computations.ResultEffect.bind
import arrow.core.continuations.Eager
import arrow.core.continuations.EagerEffect
import arrow.core.continuations.Effect
import arrow.core.continuations.Token
import arrow.core.raise.Raise
import arrow.core.raise.either
import arrow.typeclasses.Monoid
import arrow.typeclasses.MonoidDeprecation
import arrow.typeclasses.Semigroup
import arrow.typeclasses.SemigroupDeprecation
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
Expand Down Expand Up @@ -2293,18 +2292,25 @@ public operator fun <A : Comparable<A>, B : Comparable<B>> Either<A, B>.compareT
)

@Deprecated(
RedundantAPI + "Prefer zipOrAccumulate",
SemigroupDeprecation + "Prefer zipOrAccumulate",
ReplaceWith("Either.zipOrAccumulate({ a, bb -> SGA.run { a.combine(bb) } }, this, b) { a, bb -> SGB.run { a.combine(bb) } }")
)
public fun <A, B> Either<A, B>.combine(SGA: Semigroup<A>, SGB: Semigroup<B>, b: Either<A, B>): Either<A, B> =
Either.zipOrAccumulate({ a, bb -> SGA.run { a.combine(bb) } }, this, b) { a, bb -> SGB.run { a.combine(bb) } }

@Deprecated(
RedundantAPI + "Prefer explicit fold instead",
ReplaceWith("fold(Monoid.either(MA, MB))", "arrow.core.fold", "arrow.typeclasses.Monoid")
ReplaceWith("fold(initialB.right()) { x: Either<A, B>, y -> Either.zipOrAccumulate(combineA, x, y, combineB) }", "arrow.core.fold", "arrow.core.right")
)
public fun <A, B> Iterable<Either<A, B>>.combineAll(combineA: (A, A) -> A, initialB: B, combineB: (B, B) -> B): Either<A, B> =
serras marked this conversation as resolved.
Show resolved Hide resolved
fold(initialB.right()) { x: Either<A, B>, y -> Either.zipOrAccumulate(combineA, x, y, combineB) }

@Deprecated(
MonoidDeprecation,
ReplaceWith("combineAll({ x, y -> MA.run { x.combine(y) } }, MB.empty(), { x, y -> MB.run { x.combine(y) } })")
)
public fun <A, B> Iterable<Either<A, B>>.combineAll(MA: Monoid<A>, MB: Monoid<B>): Either<A, B> =
fold(Monoid.either(MA, MB))
combineAll({ x, y -> MA.run { x.combine(y) } }, MB.empty(), { x, y -> MB.run { x.combine(y) } })

/**
* Given [B] is a sub type of [C], re-type this value from Either<A, B> to Either<A, C>
Expand Down
Loading