Skip to content

Commit 1a43899

Browse files
authored
Merge pull request #4475 from mtomko/series/3.x
Clarify how `MapRef` can be total
2 parents 54782bb + 2222c6c commit 1a43899

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/std/mapref.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ the pairs can be sharded by key.
2727
Thus, multiple concurrent updates may be executed independently to each other,
2828
as long as their keys belong to different shards.
2929

30+
Since `MapRef` is a total map, constructors of `MapRef` either take a default
31+
value or return a `MapRef[F, K, Option[V]]`.
32+
3033
### In-Memory database
3134

3235
This is probably one of the most common uses of this datatype.
@@ -46,7 +49,7 @@ object DatabaseClient {
4649
def inMemory[Id, Data]: IO[DatabaseClient[IO, Id, Data]] =
4750
MapRef.ofShardedImmutableMap[IO, Id, Data](
4851
shardCount = 5 // Arbitrary number of shards just for demonstration.
49-
).map { mapRef =>
52+
).map { (mapRef: MapRef[IO, Id, Option[Data]]) =>
5053
new DatabaseClient[IO, Id, Data] {
5154
override def getDataById(id: Id): IO[Option[Data]] =
5255
mapRef(id).get

0 commit comments

Comments
 (0)