cats-effect icon indicating copy to clipboard operation
cats-effect copied to clipboard

Add `snapshot` to `MapRef`

Open iRevive opened this issue 1 year ago • 0 comments
trafficstars

Motivation

MapRef can be considered as a replacement for Ref[F, Map[K, V]]. However, currently, there is no way to retrieve all available values.

Why not add snapshot method directly to the MapRef trait?

Two reasons:

  • We cannot implement snapshot for the def fromSeqRefs[F[_]: Functor, K, V] (traverse requires Applicative)
  • For the majority of the implementations, the result type would be Map[K, Option[V]], which is suboptimal

iRevive avatar Oct 16 '24 08:10 iRevive