Skip to content

Commit

Permalink
Revert b1203f0, because it breaks bincompat
Browse files Browse the repository at this point in the history
  • Loading branch information
durban committed Dec 2, 2024
1 parent b1203f0 commit 30af095
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
8 changes: 3 additions & 5 deletions core/shared/src/main/scala/dev/tauri/choam/refs/RefLike.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ trait RefLike[A] {

def updWith[B, C](f: (A, B) => Axn[(A, C)]): Rxn[B, C]

// derivable (but primitive for performance):
// derived (but overridden for performance):

def upd[B, C](f: (A, B) => (A, C)): Rxn[B, C]
// Note: in theory this could be implemented as
// `updWith[B, C] { (a, b) => Axn.pure(f(a, b)) }`,
// but we rather have it as a primitive.
def upd[B, C](f: (A, B) => (A, C)): Rxn[B, C] =
updWith[B, C] { (a, b) => Axn.pure(f(a, b)) }

// derived:

Expand Down
3 changes: 1 addition & 2 deletions data/jvm/src/main/scala/dev/tauri/choam/data/Ttrie.scala
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ private final class Ttrie[K, V] private (
final def get: Axn[V] =
self.get.provide(key).map(_.getOrElse(default))

final def upd[B, C](f: (V, B) => (V, C)): B =#> C =
updWith[B, C] { (v, b) => Axn.pure(f(v, b)) }
// TODO: maybe override `upd` and/or `getAndSet` if we can make it faster than the default impl.

final def updWith[B, C](f: (V, B) => Axn[(V, C)]): B =#> C = {
getRefWithKey(key).flatMap { ref =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private final class SimpleMap[K, V] private (
final def get: Axn[V] =
self.get.provide(key).map(_.getOrElse(default))

final def upd[B, C](f: (V, B) => (V, C)): B =#> C = {
final override def upd[B, C](f: (V, B) => (V, C)): B =#> C = {
Rxn.computed[B, C] { (b: B) =>
repr.modify { hm =>
val currVal = hm.getOrElse(key, default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private final class SimpleOrderedMap[K, V] private (
final def get: Axn[V] =
self.get.provide(key).map(_.getOrElse(default))

final def upd[B, C](f: (V, B) => (V, C)): B =#> C = {
final override def upd[B, C](f: (V, B) => (V, C)): B =#> C = {
Rxn.computed[B, C] { (b: B) =>
repr.modify { am =>
val currVal = am.get(key).getOrElse(default)
Expand Down

0 comments on commit 30af095

Please sign in to comment.