Skip to content

Commit

Permalink
Merge pull request #3383 from Masynchin/simplify-modifyf
Browse files Browse the repository at this point in the history
Simplify KeyValueStore.modifyF
  • Loading branch information
alejandrohdezma authored Jul 28, 2024
2 parents 797c6f5 + 1a8962a commit 8193b2d
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait KeyValueStore[F[_], K, V] {
get(key).map(_.getOrElse(default))

final def modifyF(key: K)(f: Option[V] => F[Option[V]])(implicit F: FlatMap[F]): F[Option[V]] =
get(key).flatMap(maybeValue => f(maybeValue).flatTap(set(key, _)))
get(key).flatMap(f).flatTap(set(key, _))

final def put(key: K, value: V): F[Unit] =
set(key, Some(value))
Expand Down

0 comments on commit 8193b2d

Please sign in to comment.