Skip to content

Commit

Permalink
Update Semigroup docs for Map (#3071)
Browse files Browse the repository at this point in the history
I didn't understand that the values in Maps were also combined when two maps are combined - I thought the `"hello" -> 2` entry was simply _replacing_ the `"hello" -> 0` entry in the first map. Giving the first map's `"hello"` a value of `1` results in the combined map having a `"hello" -> 3` entry, showing that the values were combined.

After understanding that, I realized why my code couldn't find an implicit `Semigroup` for my Map - I didn't have an implicit `Semigroup` for my map's values.
  • Loading branch information
codingismy11to7 authored and kailuowang committed Sep 23, 2019
1 parent f739667 commit e8e6676
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/src/main/tut/typeclasses/semigroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ for `Map`s.
```tut:book:silent
import cats.implicits._
val map1 = Map("hello" -> 0, "world" -> 1)
val map1 = Map("hello" -> 1, "world" -> 1)
val map2 = Map("hello" -> 2, "cats" -> 3)
```

Expand Down

0 comments on commit e8e6676

Please sign in to comment.